@backstage/plugin-proxy-backend 0.5.10-next.1 → 0.5.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/dist/index.d.ts +2 -0
- package/dist/plugin.cjs.js +9 -1
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/service/router.cjs.js +4 -1
- package/dist/service/router.cjs.js.map +1 -1
- package/package.json +11 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @backstage/plugin-proxy-backend
|
|
2
2
|
|
|
3
|
+
## 0.5.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 11b001c: Added `proxyEndpointsExtensionPoint` to allow addition of proxy configuration through an extension point in the new backend system.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/plugin-proxy-node@0.1.0
|
|
10
|
+
- @backstage/types@1.2.1
|
|
11
|
+
- @backstage/backend-plugin-api@1.1.1
|
|
12
|
+
- @backstage/config@1.3.2
|
|
13
|
+
|
|
3
14
|
## 0.5.10-next.1
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
|
|
|
2
2
|
import { RootConfigService, DiscoveryService } from '@backstage/backend-plugin-api';
|
|
3
3
|
import express from 'express';
|
|
4
4
|
import { Logger } from 'winston';
|
|
5
|
+
import { ProxyConfig } from '@backstage/plugin-proxy-node/alpha';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* The proxy backend plugin.
|
|
@@ -20,6 +21,7 @@ interface RouterOptions {
|
|
|
20
21
|
discovery: DiscoveryService;
|
|
21
22
|
skipInvalidProxies?: boolean;
|
|
22
23
|
reviveConsumedRequestBodies?: boolean;
|
|
24
|
+
additionalEndpoints?: ProxyConfig;
|
|
23
25
|
}
|
|
24
26
|
/**
|
|
25
27
|
* Creates a new
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -3,10 +3,17 @@
|
|
|
3
3
|
var backendCommon = require('@backstage/backend-common');
|
|
4
4
|
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
5
5
|
var router = require('./service/router.cjs.js');
|
|
6
|
+
var alpha = require('@backstage/plugin-proxy-node/alpha');
|
|
6
7
|
|
|
7
8
|
const proxyPlugin = backendPluginApi.createBackendPlugin({
|
|
8
9
|
pluginId: "proxy",
|
|
9
10
|
register(env) {
|
|
11
|
+
const additionalEndpoints = {};
|
|
12
|
+
env.registerExtensionPoint(alpha.proxyEndpointsExtensionPoint, {
|
|
13
|
+
addProxyEndpoints(endpoints) {
|
|
14
|
+
Object.assign(additionalEndpoints, endpoints);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
10
17
|
env.registerInit({
|
|
11
18
|
deps: {
|
|
12
19
|
config: backendPluginApi.coreServices.rootConfig,
|
|
@@ -19,7 +26,8 @@ const proxyPlugin = backendPluginApi.createBackendPlugin({
|
|
|
19
26
|
config,
|
|
20
27
|
discovery,
|
|
21
28
|
logger: backendCommon.loggerToWinstonLogger(logger),
|
|
22
|
-
httpRouterService: httpRouter
|
|
29
|
+
httpRouterService: httpRouter,
|
|
30
|
+
additionalEndpoints
|
|
23
31
|
});
|
|
24
32
|
}
|
|
25
33
|
});
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["../src/plugin.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { loggerToWinstonLogger } from '@backstage/backend-common';\nimport {\n createBackendPlugin,\n coreServices,\n} from '@backstage/backend-plugin-api';\nimport { createRouterInternal } from './service/router';\n\n/**\n * The proxy backend plugin.\n *\n * @public\n */\nexport const proxyPlugin = createBackendPlugin({\n pluginId: 'proxy',\n register(env) {\n env.registerInit({\n deps: {\n config: coreServices.rootConfig,\n discovery: coreServices.discovery,\n logger: coreServices.logger,\n httpRouter: coreServices.httpRouter,\n },\n async init({ config, discovery, logger, httpRouter }) {\n await createRouterInternal({\n config,\n discovery,\n logger: loggerToWinstonLogger(logger),\n httpRouterService: httpRouter,\n });\n },\n });\n },\n});\n"],"names":["createBackendPlugin","coreServices","createRouterInternal","loggerToWinstonLogger"],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["../src/plugin.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { loggerToWinstonLogger } from '@backstage/backend-common';\nimport {\n createBackendPlugin,\n coreServices,\n} from '@backstage/backend-plugin-api';\nimport { createRouterInternal } from './service/router';\nimport { proxyEndpointsExtensionPoint } from '@backstage/plugin-proxy-node/alpha';\n\n/**\n * The proxy backend plugin.\n *\n * @public\n */\nexport const proxyPlugin = createBackendPlugin({\n pluginId: 'proxy',\n register(env) {\n const additionalEndpoints = {};\n\n env.registerExtensionPoint(proxyEndpointsExtensionPoint, {\n addProxyEndpoints(endpoints) {\n Object.assign(additionalEndpoints, endpoints);\n },\n });\n env.registerInit({\n deps: {\n config: coreServices.rootConfig,\n discovery: coreServices.discovery,\n logger: coreServices.logger,\n httpRouter: coreServices.httpRouter,\n },\n async init({ config, discovery, logger, httpRouter }) {\n await createRouterInternal({\n config,\n discovery,\n logger: loggerToWinstonLogger(logger),\n httpRouterService: httpRouter,\n additionalEndpoints,\n });\n },\n });\n },\n});\n"],"names":["createBackendPlugin","proxyEndpointsExtensionPoint","coreServices","createRouterInternal","loggerToWinstonLogger"],"mappings":";;;;;;;AA6BO,MAAM,cAAcA,oCAAoB,CAAA;AAAA,EAC7C,QAAU,EAAA,OAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,MAAM,sBAAsB,EAAC;AAE7B,IAAA,GAAA,CAAI,uBAAuBC,kCAA8B,EAAA;AAAA,MACvD,kBAAkB,SAAW,EAAA;AAC3B,QAAO,MAAA,CAAA,MAAA,CAAO,qBAAqB,SAAS,CAAA;AAAA;AAC9C,KACD,CAAA;AACD,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,QAAQC,6BAAa,CAAA,UAAA;AAAA,QACrB,WAAWA,6BAAa,CAAA,SAAA;AAAA,QACxB,QAAQA,6BAAa,CAAA,MAAA;AAAA,QACrB,YAAYA,6BAAa,CAAA;AAAA,OAC3B;AAAA,MACA,MAAM,IAAK,CAAA,EAAE,QAAQ,SAAW,EAAA,MAAA,EAAQ,YAAc,EAAA;AACpD,QAAA,MAAMC,2BAAqB,CAAA;AAAA,UACzB,MAAA;AAAA,UACA,SAAA;AAAA,UACA,MAAA,EAAQC,oCAAsB,MAAM,CAAA;AAAA,UACpC,iBAAmB,EAAA,UAAA;AAAA,UACnB;AAAA,SACD,CAAA;AAAA;AACH,KACD,CAAA;AAAA;AAEL,CAAC;;;;"}
|
|
@@ -160,7 +160,10 @@ async function createRouterInternal(options) {
|
|
|
160
160
|
};
|
|
161
161
|
const externalUrl = await options.discovery.getExternalBaseUrl("proxy");
|
|
162
162
|
const { pathname: pathPrefix } = new URL(externalUrl);
|
|
163
|
-
const proxyConfig =
|
|
163
|
+
const proxyConfig = {
|
|
164
|
+
...options.additionalEndpoints ?? {},
|
|
165
|
+
...readProxyConfig(options.config, options.logger)
|
|
166
|
+
};
|
|
164
167
|
configureMiddlewares(
|
|
165
168
|
proxyOptions,
|
|
166
169
|
currentRouter,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.cjs.js","sources":["../../src/service/router.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport express from 'express';\nimport Router from 'express-promise-router';\nimport {\n createProxyMiddleware,\n fixRequestBody,\n Options,\n RequestHandler,\n} from 'http-proxy-middleware';\nimport { Logger } from 'winston';\nimport http from 'http';\nimport { JsonObject } from '@backstage/types';\nimport {\n DiscoveryService,\n HttpRouterService,\n RootConfigService,\n} from '@backstage/backend-plugin-api';\n\n// A list of headers that are always forwarded to the proxy targets.\nconst safeForwardHeaders = [\n // https://fetch.spec.whatwg.org/#cors-safelisted-request-header\n 'cache-control',\n 'content-language',\n 'content-length',\n 'content-type',\n 'expires',\n 'last-modified',\n 'pragma',\n\n // host is overridden by default. if changeOrigin is configured to false,\n // we assume this is a intentional and should also be forwarded.\n 'host',\n\n // other headers that we assume to be ok\n 'accept',\n 'accept-language',\n 'user-agent',\n];\n\n/**\n * @public\n * @deprecated Please migrate to the new backend system as this will be removed in the future.\n */\nexport interface RouterOptions {\n logger: Logger;\n config: RootConfigService;\n discovery: DiscoveryService;\n skipInvalidProxies?: boolean;\n reviveConsumedRequestBodies?: boolean;\n}\n\nexport interface ProxyConfig extends Options {\n allowedMethods?: string[];\n allowedHeaders?: string[];\n reviveRequestBody?: boolean;\n}\n\n// Creates a proxy middleware, possibly with defaults added on top of the\n// given config.\nexport function buildMiddleware(\n pathPrefix: string,\n logger: Logger,\n route: string,\n config: string | ProxyConfig,\n reviveConsumedRequestBodies?: boolean,\n httpRouterService?: HttpRouterService,\n): RequestHandler {\n let fullConfig: ProxyConfig;\n let credentialsPolicy: string;\n if (typeof config === 'string') {\n fullConfig = { target: config };\n credentialsPolicy = 'require';\n } else {\n const { credentials, ...rest } = config as any;\n fullConfig = rest;\n credentialsPolicy = credentials ?? 'require';\n }\n\n const credentialsPolicyCandidates = [\n 'require',\n 'forward',\n 'dangerously-allow-unauthenticated',\n ];\n if (!credentialsPolicyCandidates.includes(credentialsPolicy)) {\n const valid = credentialsPolicyCandidates.map(c => `'${c}'`).join(', ');\n throw new Error(\n `Unknown credentials policy '${credentialsPolicy}' for proxy route '${route}'; expected one of ${valid}`,\n );\n }\n\n if (credentialsPolicy === 'dangerously-allow-unauthenticated') {\n httpRouterService?.addAuthPolicy({\n path: route,\n allow: 'unauthenticated',\n });\n }\n\n // Validate that target is a valid URL.\n const targetType = typeof fullConfig.target;\n if (targetType !== 'string') {\n throw new Error(\n `Proxy target for route \"${route}\" must be a string, but is of type ${targetType}`,\n );\n }\n try {\n // eslint-disable-next-line no-new\n new URL(fullConfig.target! as string);\n } catch {\n throw new Error(\n `Proxy target is not a valid URL: ${fullConfig.target ?? ''}`,\n );\n }\n\n // Default is to do a path rewrite that strips out the proxy's path prefix\n // and the rest of the route.\n if (fullConfig.pathRewrite === undefined) {\n let routeWithSlash = route.endsWith('/') ? route : `${route}/`;\n\n if (!pathPrefix.endsWith('/') && !routeWithSlash.startsWith('/')) {\n // Need to insert a / between pathPrefix and routeWithSlash\n routeWithSlash = `/${routeWithSlash}`;\n } else if (pathPrefix.endsWith('/') && routeWithSlash.startsWith('/')) {\n // Never expect this to happen at this point in time as\n // pathPrefix is set using `getExternalBaseUrl` which \"Returns the\n // external HTTP base backend URL for a given plugin,\n // **without a trailing slash.**\". But in case this changes in future, we\n // need to drop a / on either pathPrefix or routeWithSlash\n routeWithSlash = routeWithSlash.substring(1);\n }\n\n // The ? makes the slash optional for the rewrite, so that a base path without an ending slash\n // will also be matched (e.g. '/sample' and then requesting just '/api/proxy/sample' without an\n // ending slash). Otherwise the target gets called with the full '/api/proxy/sample' path\n // appended.\n fullConfig.pathRewrite = {\n [`^${pathPrefix}${routeWithSlash}?`]: '/',\n };\n }\n\n // Default is to update the Host header to the target\n if (fullConfig.changeOrigin === undefined) {\n fullConfig.changeOrigin = true;\n }\n\n // Attach the logger to the proxy config\n fullConfig.logProvider = () => logger;\n // http-proxy-middleware uses this log level to check if it should log the\n // requests that it proxies. Setting this to the most verbose log level\n // ensures that it always logs these requests. Our logger ends up deciding\n // if the logs are displayed or not.\n fullConfig.logLevel = 'debug';\n\n // Only return the allowed HTTP headers to not forward unwanted secret headers\n const requestHeaderAllowList = new Set<string>(\n [\n // allow all safe headers\n ...safeForwardHeaders,\n\n // allow all headers that are set by the proxy\n ...((fullConfig.headers && Object.keys(fullConfig.headers)) || []),\n\n // allow all configured headers\n ...(fullConfig.allowedHeaders || []),\n ].map(h => h.toLocaleLowerCase()),\n );\n\n if (credentialsPolicy === 'forward') {\n requestHeaderAllowList.add('authorization');\n }\n\n // Use the custom middleware filter to do two things:\n // 1. Remove any headers not in the allow list to stop them being forwarded\n // 2. Only permit the allowed HTTP methods if configured\n //\n // We are filtering the proxy request headers here rather than in\n // `onProxyReq` because when global-agent is enabled then `onProxyReq`\n // fires _after_ the agent has already sent the headers to the proxy\n // target, causing a ERR_HTTP_HEADERS_SENT crash\n const filter = (_pathname: string, req: http.IncomingMessage): boolean => {\n const headerNames = Object.keys(req.headers);\n headerNames.forEach(h => {\n if (!requestHeaderAllowList.has(h.toLocaleLowerCase())) {\n delete req.headers[h];\n }\n });\n\n return fullConfig?.allowedMethods?.includes(req.method!) ?? true;\n };\n // Makes http-proxy-middleware logs look nicer and include the mount path\n filter.toString = () => route;\n\n // Only forward the allowed HTTP headers to not forward unwanted secret headers\n const responseHeaderAllowList = new Set<string>(\n [\n // allow all safe headers\n ...safeForwardHeaders,\n\n // allow all configured headers\n ...(fullConfig.allowedHeaders || []),\n ].map(h => h.toLocaleLowerCase()),\n );\n\n // only forward the allowed headers in backend->client\n fullConfig.onProxyRes = (proxyRes: http.IncomingMessage) => {\n const headerNames = Object.keys(proxyRes.headers);\n\n headerNames.forEach(h => {\n if (!responseHeaderAllowList.has(h.toLocaleLowerCase())) {\n delete proxyRes.headers[h];\n }\n });\n };\n\n if (reviveConsumedRequestBodies) {\n fullConfig.onProxyReq = fixRequestBody;\n }\n\n return createProxyMiddleware(filter, fullConfig);\n}\n\nfunction readProxyConfig(config: Config, logger: Logger): JsonObject {\n const endpoints = config\n .getOptionalConfig('proxy.endpoints')\n ?.get<JsonObject>();\n if (endpoints) {\n return endpoints;\n }\n\n const root = config.getOptionalConfig('proxy')?.get<JsonObject>();\n if (!root) {\n return {};\n }\n\n const rootEndpoints = Object.fromEntries(\n Object.entries(root).filter(([key]) => key.startsWith('/')),\n );\n if (Object.keys(rootEndpoints).length === 0) {\n return {};\n }\n\n logger.warn(\n \"Configuring proxy endpoints in the root 'proxy' configuration is deprecated. Move this configuration to 'proxy.endpoints' instead.\",\n );\n\n return rootEndpoints;\n}\n\n/**\n * Creates a new\n * {@link https://expressjs.com/en/api.html#router | \"express router\"} that\n * proxies each target configured under the `proxy.endpoints` key of the config.\n *\n * @remarks\n *\n * Example configuration:\n *\n * ```yaml\n * proxy:\n * endpoints:\n * # Option 1: Simple URL String\n * simple-example: http://simple.example.com:8080\n * # Option 2: `http-proxy-middleware` compatible object\n * '/larger-example/v1':\n * target: http://larger.example.com:8080/svc.v1\n * headers:\n * Authorization: Bearer ${EXAMPLE_AUTH_TOKEN}\n * ```\n *\n * @see https://backstage.io/docs/plugins/proxying\n * @public\n * @deprecated Please migrate to the new backend system as this will be removed in the future.\n */\nexport async function createRouter(\n options: RouterOptions,\n): Promise<express.Router> {\n return createRouterInternal(options);\n}\n\nexport async function createRouterInternal(\n options: RouterOptions & { httpRouterService?: HttpRouterService },\n): Promise<express.Router> {\n const router = Router();\n let currentRouter = Router();\n\n const skipInvalidProxies =\n options.skipInvalidProxies ??\n options.config.getOptionalBoolean('proxy.skipInvalidProxies') ??\n false;\n const reviveConsumedRequestBodies =\n options.reviveConsumedRequestBodies ??\n options.config.getOptionalBoolean('proxy.reviveConsumedRequestBodies') ??\n false;\n const proxyOptions = {\n skipInvalidProxies,\n reviveConsumedRequestBodies,\n logger: options.logger,\n };\n\n const externalUrl = await options.discovery.getExternalBaseUrl('proxy');\n const { pathname: pathPrefix } = new URL(externalUrl);\n\n const proxyConfig = readProxyConfig(options.config, options.logger);\n configureMiddlewares(\n proxyOptions,\n currentRouter,\n pathPrefix,\n proxyConfig,\n options.httpRouterService,\n );\n router.use((...args) => currentRouter(...args));\n\n if (options.config.subscribe) {\n let currentKey = JSON.stringify(proxyConfig);\n\n options.config.subscribe(() => {\n const newProxyConfig = readProxyConfig(options.config, options.logger);\n const newKey = JSON.stringify(newProxyConfig);\n\n if (currentKey !== newKey) {\n currentKey = newKey;\n currentRouter = Router();\n configureMiddlewares(\n proxyOptions,\n currentRouter,\n pathPrefix,\n newProxyConfig,\n options.httpRouterService,\n );\n }\n });\n }\n\n options.httpRouterService?.use(router);\n return router;\n}\n\nfunction configureMiddlewares(\n options: {\n reviveConsumedRequestBodies: boolean;\n skipInvalidProxies: boolean;\n logger: Logger;\n },\n router: express.Router,\n pathPrefix: string,\n proxyConfig: any,\n httpRouterService?: HttpRouterService,\n) {\n Object.entries<any>(proxyConfig).forEach(([route, proxyRouteConfig]) => {\n try {\n router.use(\n route,\n buildMiddleware(\n pathPrefix,\n options.logger,\n route,\n proxyRouteConfig,\n options.reviveConsumedRequestBodies,\n httpRouterService,\n ),\n );\n } catch (e) {\n if (options.skipInvalidProxies) {\n options.logger.warn(`skipped configuring ${route} due to ${e.message}`);\n } else {\n throw e;\n }\n }\n });\n}\n"],"names":["fixRequestBody","createProxyMiddleware","Router"],"mappings":";;;;;;;;;AAmCA,MAAM,kBAAqB,GAAA;AAAA;AAAA,EAEzB,eAAA;AAAA,EACA,kBAAA;AAAA,EACA,gBAAA;AAAA,EACA,cAAA;AAAA,EACA,SAAA;AAAA,EACA,eAAA;AAAA,EACA,QAAA;AAAA;AAAA;AAAA,EAIA,MAAA;AAAA;AAAA,EAGA,QAAA;AAAA,EACA,iBAAA;AAAA,EACA;AACF,CAAA;AAsBO,SAAS,gBACd,UACA,EAAA,MAAA,EACA,KACA,EAAA,MAAA,EACA,6BACA,iBACgB,EAAA;AAChB,EAAI,IAAA,UAAA;AACJ,EAAI,IAAA,iBAAA;AACJ,EAAI,IAAA,OAAO,WAAW,QAAU,EAAA;AAC9B,IAAa,UAAA,GAAA,EAAE,QAAQ,MAAO,EAAA;AAC9B,IAAoB,iBAAA,GAAA,SAAA;AAAA,GACf,MAAA;AACL,IAAA,MAAM,EAAE,WAAA,EAAa,GAAG,IAAA,EAAS,GAAA,MAAA;AACjC,IAAa,UAAA,GAAA,IAAA;AACb,IAAA,iBAAA,GAAoB,WAAe,IAAA,SAAA;AAAA;AAGrC,EAAA,MAAM,2BAA8B,GAAA;AAAA,IAClC,SAAA;AAAA,IACA,SAAA;AAAA,IACA;AAAA,GACF;AACA,EAAA,IAAI,CAAC,2BAAA,CAA4B,QAAS,CAAA,iBAAiB,CAAG,EAAA;AAC5D,IAAM,MAAA,KAAA,GAAQ,4BAA4B,GAAI,CAAA,CAAA,CAAA,KAAK,IAAI,CAAC,CAAA,CAAA,CAAG,CAAE,CAAA,IAAA,CAAK,IAAI,CAAA;AACtE,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAA+B,4BAAA,EAAA,iBAAiB,CAAsB,mBAAA,EAAA,KAAK,sBAAsB,KAAK,CAAA;AAAA,KACxG;AAAA;AAGF,EAAA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;AACrE,MAAM,MAAA,MAAA,GAAS,IAAK,CAAA,SAAA,CAAU,cAAc,CAAA;AAE5C,MAAA,IAAI,eAAe,MAAQ,EAAA;AACzB,QAAa,UAAA,GAAA,MAAA;AACb,QAAA,aAAA,GAAgBA,uBAAO,EAAA;AACvB,QAAA,oBAAA;AAAA,UACE,YAAA;AAAA,UACA,aAAA;AAAA,UACA,UAAA;AAAA,UACA,cAAA;AAAA,UACA,OAAQ,CAAA;AAAA,SACV;AAAA;AACF,KACD,CAAA;AAAA;AAGH,EAAQ,OAAA,CAAA,iBAAA,EAAmB,IAAI,MAAM,CAAA;AACrC,EAAO,OAAA,MAAA;AACT;AAEA,SAAS,oBACP,CAAA,OAAA,EAKA,MACA,EAAA,UAAA,EACA,aACA,iBACA,EAAA;AACA,EAAO,MAAA,CAAA,OAAA,CAAa,WAAW,CAAE,CAAA,OAAA,CAAQ,CAAC,CAAC,KAAA,EAAO,gBAAgB,CAAM,KAAA;AACtE,IAAI,IAAA;AACF,MAAO,MAAA,CAAA,GAAA;AAAA,QACL,KAAA;AAAA,QACA,eAAA;AAAA,UACE,UAAA;AAAA,UACA,OAAQ,CAAA,MAAA;AAAA,UACR,KAAA;AAAA,UACA,gBAAA;AAAA,UACA,OAAQ,CAAA,2BAAA;AAAA,UACR;AAAA;AACF,OACF;AAAA,aACO,CAAG,EAAA;AACV,MAAA,IAAI,QAAQ,kBAAoB,EAAA;AAC9B,QAAA,OAAA,CAAQ,OAAO,IAAK,CAAA,CAAA,oBAAA,EAAuB,KAAK,CAAW,QAAA,EAAA,CAAA,CAAE,OAAO,CAAE,CAAA,CAAA;AAAA,OACjE,MAAA;AACL,QAAM,MAAA,CAAA;AAAA;AACR;AACF,GACD,CAAA;AACH;;;;;;"}
|
|
1
|
+
{"version":3,"file":"router.cjs.js","sources":["../../src/service/router.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport express from 'express';\nimport Router from 'express-promise-router';\nimport {\n createProxyMiddleware,\n fixRequestBody,\n RequestHandler,\n} from 'http-proxy-middleware';\nimport { Logger } from 'winston';\nimport http from 'http';\nimport { JsonObject } from '@backstage/types';\nimport {\n DiscoveryService,\n HttpRouterService,\n RootConfigService,\n} from '@backstage/backend-plugin-api';\nimport { ProxyConfig } from '@backstage/plugin-proxy-node/alpha';\n\n// A list of headers that are always forwarded to the proxy targets.\nconst safeForwardHeaders = [\n // https://fetch.spec.whatwg.org/#cors-safelisted-request-header\n 'cache-control',\n 'content-language',\n 'content-length',\n 'content-type',\n 'expires',\n 'last-modified',\n 'pragma',\n\n // host is overridden by default. if changeOrigin is configured to false,\n // we assume this is a intentional and should also be forwarded.\n 'host',\n\n // other headers that we assume to be ok\n 'accept',\n 'accept-language',\n 'user-agent',\n];\n\n/**\n * @public\n * @deprecated Please migrate to the new backend system as this will be removed in the future.\n */\nexport interface RouterOptions {\n logger: Logger;\n config: RootConfigService;\n discovery: DiscoveryService;\n skipInvalidProxies?: boolean;\n reviveConsumedRequestBodies?: boolean;\n additionalEndpoints?: ProxyConfig;\n}\n\n// Creates a proxy middleware, possibly with defaults added on top of the\n// given config.\nexport function buildMiddleware(\n pathPrefix: string,\n logger: Logger,\n route: string,\n config: string | ProxyConfig,\n reviveConsumedRequestBodies?: boolean,\n httpRouterService?: HttpRouterService,\n): RequestHandler {\n let fullConfig: ProxyConfig;\n let credentialsPolicy: string;\n if (typeof config === 'string') {\n fullConfig = { target: config };\n credentialsPolicy = 'require';\n } else {\n const { credentials, ...rest } = config;\n fullConfig = rest;\n credentialsPolicy = credentials ?? 'require';\n }\n\n const credentialsPolicyCandidates = [\n 'require',\n 'forward',\n 'dangerously-allow-unauthenticated',\n ];\n if (!credentialsPolicyCandidates.includes(credentialsPolicy)) {\n const valid = credentialsPolicyCandidates.map(c => `'${c}'`).join(', ');\n throw new Error(\n `Unknown credentials policy '${credentialsPolicy}' for proxy route '${route}'; expected one of ${valid}`,\n );\n }\n\n if (credentialsPolicy === 'dangerously-allow-unauthenticated') {\n httpRouterService?.addAuthPolicy({\n path: route,\n allow: 'unauthenticated',\n });\n }\n\n // Validate that target is a valid URL.\n const targetType = typeof fullConfig.target;\n if (targetType !== 'string') {\n throw new Error(\n `Proxy target for route \"${route}\" must be a string, but is of type ${targetType}`,\n );\n }\n try {\n // eslint-disable-next-line no-new\n new URL(fullConfig.target! as string);\n } catch {\n throw new Error(\n `Proxy target is not a valid URL: ${fullConfig.target ?? ''}`,\n );\n }\n\n // Default is to do a path rewrite that strips out the proxy's path prefix\n // and the rest of the route.\n if (fullConfig.pathRewrite === undefined) {\n let routeWithSlash = route.endsWith('/') ? route : `${route}/`;\n\n if (!pathPrefix.endsWith('/') && !routeWithSlash.startsWith('/')) {\n // Need to insert a / between pathPrefix and routeWithSlash\n routeWithSlash = `/${routeWithSlash}`;\n } else if (pathPrefix.endsWith('/') && routeWithSlash.startsWith('/')) {\n // Never expect this to happen at this point in time as\n // pathPrefix is set using `getExternalBaseUrl` which \"Returns the\n // external HTTP base backend URL for a given plugin,\n // **without a trailing slash.**\". But in case this changes in future, we\n // need to drop a / on either pathPrefix or routeWithSlash\n routeWithSlash = routeWithSlash.substring(1);\n }\n\n // The ? makes the slash optional for the rewrite, so that a base path without an ending slash\n // will also be matched (e.g. '/sample' and then requesting just '/api/proxy/sample' without an\n // ending slash). Otherwise the target gets called with the full '/api/proxy/sample' path\n // appended.\n fullConfig.pathRewrite = {\n [`^${pathPrefix}${routeWithSlash}?`]: '/',\n };\n }\n\n // Default is to update the Host header to the target\n if (fullConfig.changeOrigin === undefined) {\n fullConfig.changeOrigin = true;\n }\n\n // Attach the logger to the proxy config\n fullConfig.logProvider = () => logger;\n // http-proxy-middleware uses this log level to check if it should log the\n // requests that it proxies. Setting this to the most verbose log level\n // ensures that it always logs these requests. Our logger ends up deciding\n // if the logs are displayed or not.\n fullConfig.logLevel = 'debug';\n\n // Only return the allowed HTTP headers to not forward unwanted secret headers\n const requestHeaderAllowList = new Set<string>(\n [\n // allow all safe headers\n ...safeForwardHeaders,\n\n // allow all headers that are set by the proxy\n ...((fullConfig.headers && Object.keys(fullConfig.headers)) || []),\n\n // allow all configured headers\n ...(fullConfig.allowedHeaders || []),\n ].map(h => h.toLocaleLowerCase()),\n );\n\n if (credentialsPolicy === 'forward') {\n requestHeaderAllowList.add('authorization');\n }\n\n // Use the custom middleware filter to do two things:\n // 1. Remove any headers not in the allow list to stop them being forwarded\n // 2. Only permit the allowed HTTP methods if configured\n //\n // We are filtering the proxy request headers here rather than in\n // `onProxyReq` because when global-agent is enabled then `onProxyReq`\n // fires _after_ the agent has already sent the headers to the proxy\n // target, causing a ERR_HTTP_HEADERS_SENT crash\n const filter = (_pathname: string, req: http.IncomingMessage): boolean => {\n const headerNames = Object.keys(req.headers);\n headerNames.forEach(h => {\n if (!requestHeaderAllowList.has(h.toLocaleLowerCase())) {\n delete req.headers[h];\n }\n });\n\n return fullConfig?.allowedMethods?.includes(req.method!) ?? true;\n };\n // Makes http-proxy-middleware logs look nicer and include the mount path\n filter.toString = () => route;\n\n // Only forward the allowed HTTP headers to not forward unwanted secret headers\n const responseHeaderAllowList = new Set<string>(\n [\n // allow all safe headers\n ...safeForwardHeaders,\n\n // allow all configured headers\n ...(fullConfig.allowedHeaders || []),\n ].map(h => h.toLocaleLowerCase()),\n );\n\n // only forward the allowed headers in backend->client\n fullConfig.onProxyRes = (proxyRes: http.IncomingMessage) => {\n const headerNames = Object.keys(proxyRes.headers);\n\n headerNames.forEach(h => {\n if (!responseHeaderAllowList.has(h.toLocaleLowerCase())) {\n delete proxyRes.headers[h];\n }\n });\n };\n\n if (reviveConsumedRequestBodies) {\n fullConfig.onProxyReq = fixRequestBody;\n }\n\n return createProxyMiddleware(filter, fullConfig);\n}\n\nfunction readProxyConfig(config: Config, logger: Logger): JsonObject {\n const endpoints = config\n .getOptionalConfig('proxy.endpoints')\n ?.get<JsonObject>();\n if (endpoints) {\n return endpoints;\n }\n\n const root = config.getOptionalConfig('proxy')?.get<JsonObject>();\n if (!root) {\n return {};\n }\n\n const rootEndpoints = Object.fromEntries(\n Object.entries(root).filter(([key]) => key.startsWith('/')),\n );\n if (Object.keys(rootEndpoints).length === 0) {\n return {};\n }\n\n logger.warn(\n \"Configuring proxy endpoints in the root 'proxy' configuration is deprecated. Move this configuration to 'proxy.endpoints' instead.\",\n );\n\n return rootEndpoints;\n}\n\n/**\n * Creates a new\n * {@link https://expressjs.com/en/api.html#router | \"express router\"} that\n * proxies each target configured under the `proxy.endpoints` key of the config.\n *\n * @remarks\n *\n * Example configuration:\n *\n * ```yaml\n * proxy:\n * endpoints:\n * # Option 1: Simple URL String\n * simple-example: http://simple.example.com:8080\n * # Option 2: `http-proxy-middleware` compatible object\n * '/larger-example/v1':\n * target: http://larger.example.com:8080/svc.v1\n * headers:\n * Authorization: Bearer ${EXAMPLE_AUTH_TOKEN}\n * ```\n *\n * @see https://backstage.io/docs/plugins/proxying\n * @public\n * @deprecated Please migrate to the new backend system as this will be removed in the future.\n */\nexport async function createRouter(\n options: RouterOptions,\n): Promise<express.Router> {\n return createRouterInternal(options);\n}\n\nexport async function createRouterInternal(\n options: RouterOptions & { httpRouterService?: HttpRouterService },\n): Promise<express.Router> {\n const router = Router();\n let currentRouter = Router();\n\n const skipInvalidProxies =\n options.skipInvalidProxies ??\n options.config.getOptionalBoolean('proxy.skipInvalidProxies') ??\n false;\n const reviveConsumedRequestBodies =\n options.reviveConsumedRequestBodies ??\n options.config.getOptionalBoolean('proxy.reviveConsumedRequestBodies') ??\n false;\n const proxyOptions = {\n skipInvalidProxies,\n reviveConsumedRequestBodies,\n logger: options.logger,\n };\n\n const externalUrl = await options.discovery.getExternalBaseUrl('proxy');\n const { pathname: pathPrefix } = new URL(externalUrl);\n\n const proxyConfig: ProxyConfig = {\n ...(options.additionalEndpoints ?? {}),\n ...readProxyConfig(options.config, options.logger),\n };\n\n configureMiddlewares(\n proxyOptions,\n currentRouter,\n pathPrefix,\n proxyConfig,\n options.httpRouterService,\n );\n router.use((...args) => currentRouter(...args));\n\n if (options.config.subscribe) {\n let currentKey = JSON.stringify(proxyConfig);\n\n options.config.subscribe(() => {\n const newProxyConfig = readProxyConfig(options.config, options.logger);\n const newKey = JSON.stringify(newProxyConfig);\n\n if (currentKey !== newKey) {\n currentKey = newKey;\n currentRouter = Router();\n configureMiddlewares(\n proxyOptions,\n currentRouter,\n pathPrefix,\n newProxyConfig,\n options.httpRouterService,\n );\n }\n });\n }\n\n options.httpRouterService?.use(router);\n return router;\n}\n\nfunction configureMiddlewares(\n options: {\n reviveConsumedRequestBodies: boolean;\n skipInvalidProxies: boolean;\n logger: Logger;\n },\n router: express.Router,\n pathPrefix: string,\n proxyConfig: ProxyConfig,\n httpRouterService?: HttpRouterService,\n) {\n Object.entries(proxyConfig).forEach(([route, proxyRouteConfig]) => {\n try {\n router.use(\n route,\n buildMiddleware(\n pathPrefix,\n options.logger,\n route,\n proxyRouteConfig,\n options.reviveConsumedRequestBodies,\n httpRouterService,\n ),\n );\n } catch (e) {\n if (options.skipInvalidProxies) {\n options.logger.warn(`skipped configuring ${route} due to ${e.message}`);\n } else {\n throw e;\n }\n }\n });\n}\n"],"names":["fixRequestBody","createProxyMiddleware","Router"],"mappings":";;;;;;;;;AAmCA,MAAM,kBAAqB,GAAA;AAAA;AAAA,EAEzB,eAAA;AAAA,EACA,kBAAA;AAAA,EACA,gBAAA;AAAA,EACA,cAAA;AAAA,EACA,SAAA;AAAA,EACA,eAAA;AAAA,EACA,QAAA;AAAA;AAAA;AAAA,EAIA,MAAA;AAAA;AAAA,EAGA,QAAA;AAA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AAA;AAAA,UACA,OAAQ,CAAA;AAAA,SACV;AAAA;AACF,KACD,CAAA;AAAA;AAGH,EAAQ,OAAA,CAAA,iBAAA,EAAmB,IAAI,MAAM,CAAA;AACrC,EAAO,OAAA,MAAA;AACT;AAEA,SAAS,oBACP,CAAA,OAAA,EAKA,MACA,EAAA,UAAA,EACA,aACA,iBACA,EAAA;AACA,EAAO,MAAA,CAAA,OAAA,CAAQ,WAAW,CAAE,CAAA,OAAA,CAAQ,CAAC,CAAC,KAAA,EAAO,gBAAgB,CAAM,KAAA;AACjE,IAAI,IAAA;AACF,MAAO,MAAA,CAAA,GAAA;AAAA,QACL,KAAA;AAAA,QACA,eAAA;AAAA,UACE,UAAA;AAAA,UACA,OAAQ,CAAA,MAAA;AAAA,UACR,KAAA;AAAA,UACA,gBAAA;AAAA,UACA,OAAQ,CAAA,2BAAA;AAAA,UACR;AAAA;AACF,OACF;AAAA,aACO,CAAG,EAAA;AACV,MAAA,IAAI,QAAQ,kBAAoB,EAAA;AAC9B,QAAA,OAAA,CAAQ,OAAO,IAAK,CAAA,CAAA,oBAAA,EAAuB,KAAK,CAAW,QAAA,EAAA,CAAA,CAAE,OAAO,CAAE,CAAA,CAAA;AAAA,OACjE,MAAA;AACL,QAAM,MAAA,CAAA;AAAA;AACR;AACF,GACD,CAAA;AACH;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-proxy-backend",
|
|
3
|
-
"version": "0.5.10
|
|
3
|
+
"version": "0.5.10",
|
|
4
4
|
"description": "A Backstage backend plugin that helps you set up proxy endpoints in the backend",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "backend-plugin",
|
|
@@ -64,9 +64,10 @@
|
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
66
|
"@backstage/backend-common": "^0.25.0",
|
|
67
|
-
"@backstage/backend-plugin-api": "1.1.1
|
|
68
|
-
"@backstage/config": "1.3.2
|
|
69
|
-
"@backstage/
|
|
67
|
+
"@backstage/backend-plugin-api": "^1.1.1",
|
|
68
|
+
"@backstage/config": "^1.3.2",
|
|
69
|
+
"@backstage/plugin-proxy-node": "^0.1.0",
|
|
70
|
+
"@backstage/types": "^1.2.1",
|
|
70
71
|
"@types/express": "^4.17.6",
|
|
71
72
|
"express": "^4.17.1",
|
|
72
73
|
"express-promise-router": "^4.1.0",
|
|
@@ -79,12 +80,12 @@
|
|
|
79
80
|
"yup": "^1.0.0"
|
|
80
81
|
},
|
|
81
82
|
"devDependencies": {
|
|
82
|
-
"@backstage/backend-app-api": "1.1.1
|
|
83
|
-
"@backstage/backend-defaults": "0.7.0
|
|
84
|
-
"@backstage/backend-test-utils": "1.2.1
|
|
85
|
-
"@backstage/cli": "0.29.5
|
|
86
|
-
"@backstage/config-loader": "1.9.5
|
|
87
|
-
"@backstage/errors": "1.2.7
|
|
83
|
+
"@backstage/backend-app-api": "^1.1.1",
|
|
84
|
+
"@backstage/backend-defaults": "^0.7.0",
|
|
85
|
+
"@backstage/backend-test-utils": "^1.2.1",
|
|
86
|
+
"@backstage/cli": "^0.29.5",
|
|
87
|
+
"@backstage/config-loader": "^1.9.5",
|
|
88
|
+
"@backstage/errors": "^1.2.7",
|
|
88
89
|
"@types/http-proxy-middleware": "^1.0.0",
|
|
89
90
|
"@types/yup": "^0.32.0",
|
|
90
91
|
"msw": "^2.0.0"
|