@backstage/plugin-catalog-backend 1.9.1 → 1.9.2-next.1
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 +46 -0
- package/alpha/package.json +1 -1
- package/dist/alpha.cjs.js +2 -1
- package/dist/alpha.cjs.js.map +1 -1
- package/dist/cjs/{CatalogBuilder-6a9091b7.cjs.js → CatalogBuilder-99a535c6.cjs.js} +39 -21
- package/dist/cjs/CatalogBuilder-99a535c6.cjs.js.map +1 -0
- package/dist/index.cjs.js +2 -1
- package/dist/index.cjs.js.map +1 -1
- package/package.json +20 -19
- package/dist/cjs/CatalogBuilder-6a9091b7.cjs.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,51 @@
|
|
|
1
1
|
# @backstage/plugin-catalog-backend
|
|
2
2
|
|
|
3
|
+
## 1.9.2-next.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 77e04a2d55be: Replace getBearerToken with library function of same
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/backend-common@0.19.0-next.1
|
|
10
|
+
- @backstage/integration@1.5.0-next.0
|
|
11
|
+
- @backstage/errors@1.2.0-next.0
|
|
12
|
+
- @backstage/backend-plugin-api@0.5.3-next.1
|
|
13
|
+
- @backstage/catalog-model@1.4.0-next.0
|
|
14
|
+
- @backstage/backend-tasks@0.5.3-next.1
|
|
15
|
+
- @backstage/plugin-auth-node@0.2.15-next.1
|
|
16
|
+
- @backstage/plugin-catalog-node@1.3.7-next.1
|
|
17
|
+
- @backstage/plugin-permission-node@0.7.9-next.1
|
|
18
|
+
- @backstage/plugin-search-backend-module-catalog@0.1.2-next.1
|
|
19
|
+
- @backstage/catalog-client@1.4.2-next.1
|
|
20
|
+
- @backstage/plugin-permission-common@0.7.6-next.0
|
|
21
|
+
- @backstage/plugin-catalog-common@1.0.14-next.0
|
|
22
|
+
- @backstage/plugin-scaffolder-common@1.3.1-next.0
|
|
23
|
+
- @backstage/config@1.0.7
|
|
24
|
+
- @backstage/types@1.0.2
|
|
25
|
+
- @backstage/plugin-search-common@1.2.4-next.0
|
|
26
|
+
|
|
27
|
+
## 1.9.2-next.0
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- Updated dependencies
|
|
32
|
+
- @backstage/catalog-client@1.4.2-next.0
|
|
33
|
+
- @backstage/plugin-catalog-node@1.3.7-next.0
|
|
34
|
+
- @backstage/plugin-search-backend-module-catalog@0.1.2-next.0
|
|
35
|
+
- @backstage/backend-common@0.18.6-next.0
|
|
36
|
+
- @backstage/integration@1.4.5
|
|
37
|
+
- @backstage/config@1.0.7
|
|
38
|
+
- @backstage/backend-plugin-api@0.5.3-next.0
|
|
39
|
+
- @backstage/backend-tasks@0.5.3-next.0
|
|
40
|
+
- @backstage/catalog-model@1.3.0
|
|
41
|
+
- @backstage/errors@1.1.5
|
|
42
|
+
- @backstage/types@1.0.2
|
|
43
|
+
- @backstage/plugin-catalog-common@1.0.13
|
|
44
|
+
- @backstage/plugin-permission-common@0.7.5
|
|
45
|
+
- @backstage/plugin-permission-node@0.7.9-next.0
|
|
46
|
+
- @backstage/plugin-scaffolder-common@1.3.0
|
|
47
|
+
- @backstage/plugin-search-common@1.2.3
|
|
48
|
+
|
|
3
49
|
## 1.9.1
|
|
4
50
|
|
|
5
51
|
### Patch Changes
|
package/alpha/package.json
CHANGED
package/dist/alpha.cjs.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var alpha = require('@backstage/plugin-catalog-common/alpha');
|
|
6
6
|
var pluginPermissionNode = require('@backstage/plugin-permission-node');
|
|
7
|
-
var CatalogBuilder = require('./cjs/CatalogBuilder-
|
|
7
|
+
var CatalogBuilder = require('./cjs/CatalogBuilder-99a535c6.cjs.js');
|
|
8
8
|
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
9
9
|
var alpha$1 = require('@backstage/plugin-catalog-node/alpha');
|
|
10
10
|
var backendCommon = require('@backstage/backend-common');
|
|
@@ -34,6 +34,7 @@ require('@backstage/catalog-client');
|
|
|
34
34
|
require('express');
|
|
35
35
|
require('express-promise-router');
|
|
36
36
|
require('yn');
|
|
37
|
+
require('@backstage/plugin-auth-node');
|
|
37
38
|
require('@backstage/plugin-permission-common');
|
|
38
39
|
require('minimatch');
|
|
39
40
|
|
package/dist/alpha.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alpha.cjs.js","sources":["../src/permissions/conditionExports.ts","../src/service/CatalogPlugin.ts"],"sourcesContent":["/*\n * Copyright 2022 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 { RESOURCE_TYPE_CATALOG_ENTITY } from '@backstage/plugin-catalog-common/alpha';\nimport { createConditionExports } from '@backstage/plugin-permission-node';\nimport { permissionRules } from './rules';\n\nconst { conditions, createConditionalDecision } = createConditionExports({\n pluginId: 'catalog',\n resourceType: RESOURCE_TYPE_CATALOG_ENTITY,\n rules: permissionRules,\n});\n\n/**\n * These conditions are used when creating conditional decisions for catalog\n * entities that are returned by authorization policies.\n *\n * @alpha\n */\nexport const catalogConditions = conditions;\n\n/**\n * `createCatalogConditionalDecision` can be used when authoring policies to\n * create conditional decisions. It requires a permission of type\n * `ResourcePermission<'catalog-entity'>` to be passed as the first parameter.\n * It's recommended that you use the provided `isResourcePermission` and\n * `isPermission` helper methods to narrow the type of the permission passed to\n * the handle method as shown below.\n *\n * ```\n * // MyAuthorizationPolicy.ts\n * ...\n * import { createCatalogPolicyDecision } from '@backstage/plugin-catalog-backend';\n * import { RESOURCE_TYPE_CATALOG_ENTITY } from '@backstage/plugin-catalog-common';\n *\n * class MyAuthorizationPolicy implements PermissionPolicy {\n * async handle(request, user) {\n * ...\n *\n * if (isResourcePermission(request.permission, RESOURCE_TYPE_CATALOG_ENTITY)) {\n * return createCatalogConditionalDecision(\n * request.permission,\n * { anyOf: [...insert conditions here...] }\n * );\n * }\n *\n * ...\n * }\n * ```\n *\n * @alpha\n */\nexport const createCatalogConditionalDecision = createConditionalDecision;\n","/*\n * Copyright 2022 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 */\nimport {\n createBackendPlugin,\n coreServices,\n} from '@backstage/backend-plugin-api';\nimport { CatalogBuilder } from './CatalogBuilder';\nimport {\n CatalogProcessingExtensionPoint,\n catalogProcessingExtensionPoint,\n} from '@backstage/plugin-catalog-node/alpha';\nimport {\n CatalogProcessor,\n EntityProvider,\n} from '@backstage/plugin-catalog-node';\nimport { loggerToWinstonLogger } from '@backstage/backend-common';\n\nclass CatalogExtensionPointImpl implements CatalogProcessingExtensionPoint {\n #processors = new Array<CatalogProcessor>();\n #entityProviders = new Array<EntityProvider>();\n\n addProcessor(\n ...processors: Array<CatalogProcessor | Array<CatalogProcessor>>\n ): void {\n this.#processors.push(...processors.flat());\n }\n\n addEntityProvider(\n ...providers: Array<EntityProvider | Array<EntityProvider>>\n ): void {\n this.#entityProviders.push(...providers.flat());\n }\n\n get processors() {\n return this.#processors;\n }\n\n get entityProviders() {\n return this.#entityProviders;\n }\n}\n\n/**\n * Catalog plugin\n * @alpha\n */\nexport const catalogPlugin = createBackendPlugin({\n pluginId: 'catalog',\n register(env) {\n const processingExtensions = new CatalogExtensionPointImpl();\n // plugins depending on this API will be initialized before this plugins init method is executed.\n env.registerExtensionPoint(\n catalogProcessingExtensionPoint,\n processingExtensions,\n );\n\n env.registerInit({\n deps: {\n logger: coreServices.logger,\n config: coreServices.config,\n reader: coreServices.urlReader,\n permissions: coreServices.permissions,\n database: coreServices.database,\n httpRouter: coreServices.httpRouter,\n lifecycle: coreServices.lifecycle,\n scheduler: coreServices.scheduler,\n },\n async init({\n logger,\n config,\n reader,\n database,\n permissions,\n httpRouter,\n lifecycle,\n scheduler,\n }) {\n const winstonLogger = loggerToWinstonLogger(logger);\n const builder = await CatalogBuilder.create({\n config,\n reader,\n permissions,\n database,\n scheduler,\n logger: winstonLogger,\n });\n builder.addProcessor(...processingExtensions.processors);\n builder.addEntityProvider(...processingExtensions.entityProviders);\n const { processingEngine, router } = await builder.build();\n\n await processingEngine.start();\n lifecycle.addShutdownHook(() => processingEngine.stop());\n httpRouter.use(router);\n },\n });\n },\n});\n"],"names":["createConditionExports","RESOURCE_TYPE_CATALOG_ENTITY","permissionRules","createBackendPlugin","catalogProcessingExtensionPoint","coreServices","loggerToWinstonLogger","CatalogBuilder"],"mappings":"
|
|
1
|
+
{"version":3,"file":"alpha.cjs.js","sources":["../src/permissions/conditionExports.ts","../src/service/CatalogPlugin.ts"],"sourcesContent":["/*\n * Copyright 2022 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 { RESOURCE_TYPE_CATALOG_ENTITY } from '@backstage/plugin-catalog-common/alpha';\nimport { createConditionExports } from '@backstage/plugin-permission-node';\nimport { permissionRules } from './rules';\n\nconst { conditions, createConditionalDecision } = createConditionExports({\n pluginId: 'catalog',\n resourceType: RESOURCE_TYPE_CATALOG_ENTITY,\n rules: permissionRules,\n});\n\n/**\n * These conditions are used when creating conditional decisions for catalog\n * entities that are returned by authorization policies.\n *\n * @alpha\n */\nexport const catalogConditions = conditions;\n\n/**\n * `createCatalogConditionalDecision` can be used when authoring policies to\n * create conditional decisions. It requires a permission of type\n * `ResourcePermission<'catalog-entity'>` to be passed as the first parameter.\n * It's recommended that you use the provided `isResourcePermission` and\n * `isPermission` helper methods to narrow the type of the permission passed to\n * the handle method as shown below.\n *\n * ```\n * // MyAuthorizationPolicy.ts\n * ...\n * import { createCatalogPolicyDecision } from '@backstage/plugin-catalog-backend';\n * import { RESOURCE_TYPE_CATALOG_ENTITY } from '@backstage/plugin-catalog-common';\n *\n * class MyAuthorizationPolicy implements PermissionPolicy {\n * async handle(request, user) {\n * ...\n *\n * if (isResourcePermission(request.permission, RESOURCE_TYPE_CATALOG_ENTITY)) {\n * return createCatalogConditionalDecision(\n * request.permission,\n * { anyOf: [...insert conditions here...] }\n * );\n * }\n *\n * ...\n * }\n * ```\n *\n * @alpha\n */\nexport const createCatalogConditionalDecision = createConditionalDecision;\n","/*\n * Copyright 2022 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 */\nimport {\n createBackendPlugin,\n coreServices,\n} from '@backstage/backend-plugin-api';\nimport { CatalogBuilder } from './CatalogBuilder';\nimport {\n CatalogProcessingExtensionPoint,\n catalogProcessingExtensionPoint,\n} from '@backstage/plugin-catalog-node/alpha';\nimport {\n CatalogProcessor,\n EntityProvider,\n} from '@backstage/plugin-catalog-node';\nimport { loggerToWinstonLogger } from '@backstage/backend-common';\n\nclass CatalogExtensionPointImpl implements CatalogProcessingExtensionPoint {\n #processors = new Array<CatalogProcessor>();\n #entityProviders = new Array<EntityProvider>();\n\n addProcessor(\n ...processors: Array<CatalogProcessor | Array<CatalogProcessor>>\n ): void {\n this.#processors.push(...processors.flat());\n }\n\n addEntityProvider(\n ...providers: Array<EntityProvider | Array<EntityProvider>>\n ): void {\n this.#entityProviders.push(...providers.flat());\n }\n\n get processors() {\n return this.#processors;\n }\n\n get entityProviders() {\n return this.#entityProviders;\n }\n}\n\n/**\n * Catalog plugin\n * @alpha\n */\nexport const catalogPlugin = createBackendPlugin({\n pluginId: 'catalog',\n register(env) {\n const processingExtensions = new CatalogExtensionPointImpl();\n // plugins depending on this API will be initialized before this plugins init method is executed.\n env.registerExtensionPoint(\n catalogProcessingExtensionPoint,\n processingExtensions,\n );\n\n env.registerInit({\n deps: {\n logger: coreServices.logger,\n config: coreServices.config,\n reader: coreServices.urlReader,\n permissions: coreServices.permissions,\n database: coreServices.database,\n httpRouter: coreServices.httpRouter,\n lifecycle: coreServices.lifecycle,\n scheduler: coreServices.scheduler,\n },\n async init({\n logger,\n config,\n reader,\n database,\n permissions,\n httpRouter,\n lifecycle,\n scheduler,\n }) {\n const winstonLogger = loggerToWinstonLogger(logger);\n const builder = await CatalogBuilder.create({\n config,\n reader,\n permissions,\n database,\n scheduler,\n logger: winstonLogger,\n });\n builder.addProcessor(...processingExtensions.processors);\n builder.addEntityProvider(...processingExtensions.entityProviders);\n const { processingEngine, router } = await builder.build();\n\n await processingEngine.start();\n lifecycle.addShutdownHook(() => processingEngine.stop());\n httpRouter.use(router);\n },\n });\n },\n});\n"],"names":["createConditionExports","RESOURCE_TYPE_CATALOG_ENTITY","permissionRules","createBackendPlugin","catalogProcessingExtensionPoint","coreServices","loggerToWinstonLogger","CatalogBuilder"],"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AA,CAAA;AAEzD,QAAA,MAAM,iBAAiB,KAAM,EAAA,CAAA;AAC7B,QAAA,SAAA,CAAU,eAAgB,CAAA,MAAM,gBAAiB,CAAA,IAAA,EAAM,CAAA,CAAA;AACvD,QAAA,UAAA,CAAW,IAAI,MAAM,CAAA,CAAA;AAAA,OACvB;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;;;;;;;"}
|
|
@@ -27,6 +27,7 @@ var catalogClient = require('@backstage/catalog-client');
|
|
|
27
27
|
var express = require('express');
|
|
28
28
|
var Router = require('express-promise-router');
|
|
29
29
|
var yn = require('yn');
|
|
30
|
+
var pluginAuthNode = require('@backstage/plugin-auth-node');
|
|
30
31
|
var alpha = require('@backstage/plugin-catalog-common/alpha');
|
|
31
32
|
var pluginPermissionCommon = require('@backstage/plugin-permission-common');
|
|
32
33
|
var minimatch = require('minimatch');
|
|
@@ -3402,7 +3403,7 @@ async function createRouter(options) {
|
|
|
3402
3403
|
if (refreshService) {
|
|
3403
3404
|
router.post("/refresh", async (req, res) => {
|
|
3404
3405
|
const refreshOptions = req.body;
|
|
3405
|
-
refreshOptions.authorizationToken =
|
|
3406
|
+
refreshOptions.authorizationToken = pluginAuthNode.getBearerTokenFromAuthorizationHeader(
|
|
3406
3407
|
req.header("authorization")
|
|
3407
3408
|
);
|
|
3408
3409
|
await refreshService.refresh(refreshOptions);
|
|
@@ -3419,7 +3420,9 @@ async function createRouter(options) {
|
|
|
3419
3420
|
fields: parseEntityTransformParams(req.query),
|
|
3420
3421
|
order: parseEntityOrderParams(req.query),
|
|
3421
3422
|
pagination: parseEntityPaginationParams(req.query),
|
|
3422
|
-
authorizationToken:
|
|
3423
|
+
authorizationToken: pluginAuthNode.getBearerTokenFromAuthorizationHeader(
|
|
3424
|
+
req.header("authorization")
|
|
3425
|
+
)
|
|
3423
3426
|
});
|
|
3424
3427
|
if (pageInfo.hasNextPage) {
|
|
3425
3428
|
const url = new URL(`http://ignored${req.url}`);
|
|
@@ -3431,7 +3434,9 @@ async function createRouter(options) {
|
|
|
3431
3434
|
}).get("/entities/by-query", async (req, res) => {
|
|
3432
3435
|
const { items, pageInfo, totalItems } = await entitiesCatalog.queryEntities({
|
|
3433
3436
|
...parseQueryEntitiesParams(req.query),
|
|
3434
|
-
authorizationToken:
|
|
3437
|
+
authorizationToken: pluginAuthNode.getBearerTokenFromAuthorizationHeader(
|
|
3438
|
+
req.header("authorization")
|
|
3439
|
+
)
|
|
3435
3440
|
});
|
|
3436
3441
|
res.json({
|
|
3437
3442
|
items,
|
|
@@ -3449,7 +3454,9 @@ async function createRouter(options) {
|
|
|
3449
3454
|
const { uid } = req.params;
|
|
3450
3455
|
const { entities } = await entitiesCatalog.entities({
|
|
3451
3456
|
filter: basicEntityFilter({ "metadata.uid": uid }),
|
|
3452
|
-
authorizationToken:
|
|
3457
|
+
authorizationToken: pluginAuthNode.getBearerTokenFromAuthorizationHeader(
|
|
3458
|
+
req.header("authorization")
|
|
3459
|
+
)
|
|
3453
3460
|
});
|
|
3454
3461
|
if (!entities.length) {
|
|
3455
3462
|
throw new errors.NotFoundError(`No entity with uid ${uid}`);
|
|
@@ -3458,7 +3465,9 @@ async function createRouter(options) {
|
|
|
3458
3465
|
}).delete("/entities/by-uid/:uid", async (req, res) => {
|
|
3459
3466
|
const { uid } = req.params;
|
|
3460
3467
|
await entitiesCatalog.removeEntityByUid(uid, {
|
|
3461
|
-
authorizationToken:
|
|
3468
|
+
authorizationToken: pluginAuthNode.getBearerTokenFromAuthorizationHeader(
|
|
3469
|
+
req.header("authorization")
|
|
3470
|
+
)
|
|
3462
3471
|
});
|
|
3463
3472
|
res.status(204).end();
|
|
3464
3473
|
}).get("/entities/by-name/:kind/:namespace/:name", async (req, res) => {
|
|
@@ -3469,7 +3478,9 @@ async function createRouter(options) {
|
|
|
3469
3478
|
"metadata.namespace": namespace,
|
|
3470
3479
|
"metadata.name": name
|
|
3471
3480
|
}),
|
|
3472
|
-
authorizationToken:
|
|
3481
|
+
authorizationToken: pluginAuthNode.getBearerTokenFromAuthorizationHeader(
|
|
3482
|
+
req.header("authorization")
|
|
3483
|
+
)
|
|
3473
3484
|
});
|
|
3474
3485
|
if (!entities.length) {
|
|
3475
3486
|
throw new errors.NotFoundError(
|
|
@@ -3483,13 +3494,17 @@ async function createRouter(options) {
|
|
|
3483
3494
|
const { kind, namespace, name } = req.params;
|
|
3484
3495
|
const entityRef = catalogModel.stringifyEntityRef({ kind, namespace, name });
|
|
3485
3496
|
const response = await entitiesCatalog.entityAncestry(entityRef, {
|
|
3486
|
-
authorizationToken:
|
|
3497
|
+
authorizationToken: pluginAuthNode.getBearerTokenFromAuthorizationHeader(
|
|
3498
|
+
req.header("authorization")
|
|
3499
|
+
)
|
|
3487
3500
|
});
|
|
3488
3501
|
res.status(200).json(response);
|
|
3489
3502
|
}
|
|
3490
3503
|
).post("/entities/by-refs", async (req, res) => {
|
|
3491
3504
|
const request = entitiesBatchRequest(req);
|
|
3492
|
-
const token =
|
|
3505
|
+
const token = pluginAuthNode.getBearerTokenFromAuthorizationHeader(
|
|
3506
|
+
req.header("authorization")
|
|
3507
|
+
);
|
|
3493
3508
|
const response = await entitiesCatalog.entitiesBatch({
|
|
3494
3509
|
entityRefs: request.entityRefs,
|
|
3495
3510
|
fields: parseEntityTransformParams(req.query, request.fields),
|
|
@@ -3500,7 +3515,9 @@ async function createRouter(options) {
|
|
|
3500
3515
|
const response = await entitiesCatalog.facets({
|
|
3501
3516
|
filter: parseEntityFilterParams(req.query),
|
|
3502
3517
|
facets: parseEntityFacetParams(req.query),
|
|
3503
|
-
authorizationToken:
|
|
3518
|
+
authorizationToken: pluginAuthNode.getBearerTokenFromAuthorizationHeader(
|
|
3519
|
+
req.header("authorization")
|
|
3520
|
+
)
|
|
3504
3521
|
});
|
|
3505
3522
|
res.status(200).json(response);
|
|
3506
3523
|
});
|
|
@@ -3513,25 +3530,33 @@ async function createRouter(options) {
|
|
|
3513
3530
|
disallowReadonlyMode(readonlyEnabled);
|
|
3514
3531
|
}
|
|
3515
3532
|
const output = await locationService.createLocation(location, dryRun, {
|
|
3516
|
-
authorizationToken:
|
|
3533
|
+
authorizationToken: pluginAuthNode.getBearerTokenFromAuthorizationHeader(
|
|
3534
|
+
req.header("authorization")
|
|
3535
|
+
)
|
|
3517
3536
|
});
|
|
3518
3537
|
res.status(201).json(output);
|
|
3519
3538
|
}).get("/locations", async (req, res) => {
|
|
3520
3539
|
const locations = await locationService.listLocations({
|
|
3521
|
-
authorizationToken:
|
|
3540
|
+
authorizationToken: pluginAuthNode.getBearerTokenFromAuthorizationHeader(
|
|
3541
|
+
req.header("authorization")
|
|
3542
|
+
)
|
|
3522
3543
|
});
|
|
3523
3544
|
res.status(200).json(locations.map((l) => ({ data: l })));
|
|
3524
3545
|
}).get("/locations/:id", async (req, res) => {
|
|
3525
3546
|
const { id } = req.params;
|
|
3526
3547
|
const output = await locationService.getLocation(id, {
|
|
3527
|
-
authorizationToken:
|
|
3548
|
+
authorizationToken: pluginAuthNode.getBearerTokenFromAuthorizationHeader(
|
|
3549
|
+
req.header("authorization")
|
|
3550
|
+
)
|
|
3528
3551
|
});
|
|
3529
3552
|
res.status(200).json(output);
|
|
3530
3553
|
}).delete("/locations/:id", async (req, res) => {
|
|
3531
3554
|
disallowReadonlyMode(readonlyEnabled);
|
|
3532
3555
|
const { id } = req.params;
|
|
3533
3556
|
await locationService.deleteLocation(id, {
|
|
3534
|
-
authorizationToken:
|
|
3557
|
+
authorizationToken: pluginAuthNode.getBearerTokenFromAuthorizationHeader(
|
|
3558
|
+
req.header("authorization")
|
|
3559
|
+
)
|
|
3535
3560
|
});
|
|
3536
3561
|
res.status(204).end();
|
|
3537
3562
|
});
|
|
@@ -3598,13 +3623,6 @@ async function createRouter(options) {
|
|
|
3598
3623
|
router.use(backendCommon.errorHandler());
|
|
3599
3624
|
return router;
|
|
3600
3625
|
}
|
|
3601
|
-
function getBearerToken(authorizationHeader) {
|
|
3602
|
-
if (typeof authorizationHeader !== "string") {
|
|
3603
|
-
return void 0;
|
|
3604
|
-
}
|
|
3605
|
-
const matches = authorizationHeader.match(/Bearer\s+(\S+)/i);
|
|
3606
|
-
return matches == null ? void 0 : matches[1];
|
|
3607
|
-
}
|
|
3608
3626
|
|
|
3609
3627
|
class DefaultRefreshService {
|
|
3610
3628
|
constructor(options) {
|
|
@@ -5059,4 +5077,4 @@ exports.createCatalogPermissionRule = createCatalogPermissionRule;
|
|
|
5059
5077
|
exports.createRandomProcessingInterval = createRandomProcessingInterval;
|
|
5060
5078
|
exports.parseEntityYaml = parseEntityYaml;
|
|
5061
5079
|
exports.permissionRules = permissionRules;
|
|
5062
|
-
//# sourceMappingURL=CatalogBuilder-
|
|
5080
|
+
//# sourceMappingURL=CatalogBuilder-99a535c6.cjs.js.map
|