@backstage/plugin-catalog-backend 1.1.0-next.2 → 1.1.0-next.3
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 +12 -0
- package/alpha/package.json +1 -1
- package/dist/index.alpha.d.ts +2 -3
- package/dist/index.beta.d.ts +2 -3
- package/dist/index.cjs.js +32 -23
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +2 -3
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @backstage/plugin-catalog-backend
|
|
2
2
|
|
|
3
|
+
## 1.1.0-next.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 23646e51a5: Use new `PermissionEvaluator#authorizeConditional` method when retrieving permission conditions.
|
|
8
|
+
- 48405ed232: Added `spec.profile.displayName` to search index for Group kinds
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
- @backstage/plugin-permission-common@0.6.0-next.1
|
|
11
|
+
- @backstage/plugin-permission-node@0.6.0-next.2
|
|
12
|
+
- @backstage/backend-common@0.13.2-next.2
|
|
13
|
+
- @backstage/integration@1.1.0-next.2
|
|
14
|
+
|
|
3
15
|
## 1.1.0-next.2
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/alpha/package.json
CHANGED
package/dist/index.alpha.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ import { Permission } from '@backstage/plugin-permission-common';
|
|
|
23
23
|
import { PermissionAuthorizer } from '@backstage/plugin-permission-common';
|
|
24
24
|
import { PermissionCondition } from '@backstage/plugin-permission-common';
|
|
25
25
|
import { PermissionCriteria } from '@backstage/plugin-permission-common';
|
|
26
|
+
import { PermissionEvaluator } from '@backstage/plugin-permission-common';
|
|
26
27
|
import { PermissionRule } from '@backstage/plugin-permission-node';
|
|
27
28
|
import { PluginDatabaseManager } from '@backstage/backend-common';
|
|
28
29
|
import { PluginEndpointDiscovery } from '@backstage/backend-common';
|
|
@@ -308,7 +309,7 @@ export declare type CatalogEnvironment = {
|
|
|
308
309
|
database: PluginDatabaseManager;
|
|
309
310
|
config: Config;
|
|
310
311
|
reader: UrlReader;
|
|
311
|
-
permissions: PermissionAuthorizer;
|
|
312
|
+
permissions: PermissionEvaluator | PermissionAuthorizer;
|
|
312
313
|
};
|
|
313
314
|
|
|
314
315
|
/**
|
|
@@ -572,8 +573,6 @@ export declare class DefaultCatalogCollatorFactory implements DocumentCollatorFa
|
|
|
572
573
|
private constructor();
|
|
573
574
|
getCollator(): Promise<Readable>;
|
|
574
575
|
private applyArgsToFormat;
|
|
575
|
-
private isUserEntity;
|
|
576
|
-
private getDocumentText;
|
|
577
576
|
private execute;
|
|
578
577
|
}
|
|
579
578
|
|
package/dist/index.beta.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ import { Permission } from '@backstage/plugin-permission-common';
|
|
|
23
23
|
import { PermissionAuthorizer } from '@backstage/plugin-permission-common';
|
|
24
24
|
import { PermissionCondition } from '@backstage/plugin-permission-common';
|
|
25
25
|
import { PermissionCriteria } from '@backstage/plugin-permission-common';
|
|
26
|
+
import { PermissionEvaluator } from '@backstage/plugin-permission-common';
|
|
26
27
|
import { PermissionRule } from '@backstage/plugin-permission-node';
|
|
27
28
|
import { PluginDatabaseManager } from '@backstage/backend-common';
|
|
28
29
|
import { PluginEndpointDiscovery } from '@backstage/backend-common';
|
|
@@ -287,7 +288,7 @@ export declare type CatalogEnvironment = {
|
|
|
287
288
|
database: PluginDatabaseManager;
|
|
288
289
|
config: Config;
|
|
289
290
|
reader: UrlReader;
|
|
290
|
-
permissions: PermissionAuthorizer;
|
|
291
|
+
permissions: PermissionEvaluator | PermissionAuthorizer;
|
|
291
292
|
};
|
|
292
293
|
|
|
293
294
|
/* Excluded from this release type: CatalogPermissionRule */
|
|
@@ -506,8 +507,6 @@ export declare class DefaultCatalogCollatorFactory implements DocumentCollatorFa
|
|
|
506
507
|
private constructor();
|
|
507
508
|
getCollator(): Promise<Readable>;
|
|
508
509
|
private applyArgsToFormat;
|
|
509
|
-
private isUserEntity;
|
|
510
|
-
private getDocumentText;
|
|
511
510
|
private execute;
|
|
512
511
|
}
|
|
513
512
|
|
package/dist/index.cjs.js
CHANGED
|
@@ -781,6 +781,24 @@ function createRandomProcessingInterval(options) {
|
|
|
781
781
|
};
|
|
782
782
|
}
|
|
783
783
|
|
|
784
|
+
function isUserEntity(entity) {
|
|
785
|
+
return entity.kind.toLocaleUpperCase("en-US") === "USER";
|
|
786
|
+
}
|
|
787
|
+
function isGroupEntity(entity) {
|
|
788
|
+
return entity.kind.toLocaleUpperCase("en-US") === "GROUP";
|
|
789
|
+
}
|
|
790
|
+
function getDocumentText(entity) {
|
|
791
|
+
var _a, _b;
|
|
792
|
+
const documentTexts = [];
|
|
793
|
+
documentTexts.push(entity.metadata.description || "");
|
|
794
|
+
if (isUserEntity(entity) || isGroupEntity(entity)) {
|
|
795
|
+
if ((_b = (_a = entity.spec) == null ? void 0 : _a.profile) == null ? void 0 : _b.displayName) {
|
|
796
|
+
documentTexts.push(entity.spec.profile.displayName);
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
return documentTexts.join(" : ");
|
|
800
|
+
}
|
|
801
|
+
|
|
784
802
|
class DefaultCatalogCollatorFactory {
|
|
785
803
|
constructor(options) {
|
|
786
804
|
this.type = "software-catalog";
|
|
@@ -812,22 +830,6 @@ class DefaultCatalogCollatorFactory {
|
|
|
812
830
|
}
|
|
813
831
|
return formatted.toLowerCase();
|
|
814
832
|
}
|
|
815
|
-
isUserEntity(entity) {
|
|
816
|
-
return entity.kind.toLocaleUpperCase("en-US") === "USER";
|
|
817
|
-
}
|
|
818
|
-
getDocumentText(entity) {
|
|
819
|
-
var _a, _b, _c, _d, _e, _f;
|
|
820
|
-
let documentText = entity.metadata.description || "";
|
|
821
|
-
if (this.isUserEntity(entity)) {
|
|
822
|
-
if (((_b = (_a = entity.spec) == null ? void 0 : _a.profile) == null ? void 0 : _b.displayName) && documentText) {
|
|
823
|
-
const displayName = (_d = (_c = entity.spec) == null ? void 0 : _c.profile) == null ? void 0 : _d.displayName;
|
|
824
|
-
documentText = displayName.concat(" : ", documentText);
|
|
825
|
-
} else {
|
|
826
|
-
documentText = ((_f = (_e = entity.spec) == null ? void 0 : _e.profile) == null ? void 0 : _f.displayName) || documentText;
|
|
827
|
-
}
|
|
828
|
-
}
|
|
829
|
-
return documentText;
|
|
830
|
-
}
|
|
831
833
|
async *execute() {
|
|
832
834
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
833
835
|
const { token } = await this.tokenManager.getToken();
|
|
@@ -849,7 +851,7 @@ class DefaultCatalogCollatorFactory {
|
|
|
849
851
|
kind: entity.kind,
|
|
850
852
|
name: entity.metadata.name
|
|
851
853
|
}),
|
|
852
|
-
text:
|
|
854
|
+
text: getDocumentText(entity),
|
|
853
855
|
componentType: ((_c = (_b = entity.spec) == null ? void 0 : _b.type) == null ? void 0 : _c.toString()) || "other",
|
|
854
856
|
type: ((_e = (_d = entity.spec) == null ? void 0 : _d.type) == null ? void 0 : _e.toString()) || "other",
|
|
855
857
|
namespace: entity.metadata.namespace || "default",
|
|
@@ -3243,7 +3245,7 @@ class AuthorizedEntitiesCatalog {
|
|
|
3243
3245
|
this.transformConditions = transformConditions;
|
|
3244
3246
|
}
|
|
3245
3247
|
async entities(request) {
|
|
3246
|
-
const authorizeDecision = (await this.permissionApi.
|
|
3248
|
+
const authorizeDecision = (await this.permissionApi.authorizeConditional([{ permission: pluginCatalogCommon.catalogEntityReadPermission }], { token: request == null ? void 0 : request.authorizationToken }))[0];
|
|
3247
3249
|
if (authorizeDecision.result === pluginPermissionCommon.AuthorizeResult.DENY) {
|
|
3248
3250
|
return {
|
|
3249
3251
|
entities: [],
|
|
@@ -3260,7 +3262,7 @@ class AuthorizedEntitiesCatalog {
|
|
|
3260
3262
|
return this.entitiesCatalog.entities(request);
|
|
3261
3263
|
}
|
|
3262
3264
|
async removeEntityByUid(uid, options) {
|
|
3263
|
-
const authorizeResponse = (await this.permissionApi.
|
|
3265
|
+
const authorizeResponse = (await this.permissionApi.authorizeConditional([{ permission: pluginCatalogCommon.catalogEntityDeletePermission }], { token: options == null ? void 0 : options.authorizationToken }))[0];
|
|
3264
3266
|
if (authorizeResponse.result === pluginPermissionCommon.AuthorizeResult.DENY) {
|
|
3265
3267
|
throw new errors.NotAllowedError();
|
|
3266
3268
|
}
|
|
@@ -3299,7 +3301,7 @@ class AuthorizedEntitiesCatalog {
|
|
|
3299
3301
|
};
|
|
3300
3302
|
}
|
|
3301
3303
|
async facets(request) {
|
|
3302
|
-
const authorizeDecision = (await this.permissionApi.
|
|
3304
|
+
const authorizeDecision = (await this.permissionApi.authorizeConditional([{ permission: pluginCatalogCommon.catalogEntityReadPermission }], { token: request == null ? void 0 : request.authorizationToken }))[0];
|
|
3303
3305
|
if (authorizeDecision.result === pluginPermissionCommon.AuthorizeResult.DENY) {
|
|
3304
3306
|
return {
|
|
3305
3307
|
facets: Object.fromEntries(request.facets.map((f) => [f, []]))
|
|
@@ -3472,7 +3474,14 @@ class CatalogBuilder {
|
|
|
3472
3474
|
policy
|
|
3473
3475
|
});
|
|
3474
3476
|
const unauthorizedEntitiesCatalog = new DefaultEntitiesCatalog(dbClient);
|
|
3475
|
-
|
|
3477
|
+
let permissionEvaluator;
|
|
3478
|
+
if ("query" in permissions) {
|
|
3479
|
+
permissionEvaluator = permissions;
|
|
3480
|
+
} else {
|
|
3481
|
+
logger.warn("PermissionAuthorizer is deprecated. Please use an instance of PermissionEvaluator instead of PermissionAuthorizer in PluginEnvironment#permissions");
|
|
3482
|
+
permissionEvaluator = pluginPermissionCommon.toPermissionEvaluator(permissions);
|
|
3483
|
+
}
|
|
3484
|
+
const entitiesCatalog = new AuthorizedEntitiesCatalog(unauthorizedEntitiesCatalog, permissionEvaluator, pluginPermissionNode.createConditionTransformer(this.permissionRules));
|
|
3476
3485
|
const permissionIntegrationRouter = pluginPermissionNode.createPermissionIntegrationRouter({
|
|
3477
3486
|
resourceType: pluginCatalogCommon.RESOURCE_TYPE_CATALOG_ENTITY,
|
|
3478
3487
|
getResources: async (resourceRefs) => {
|
|
@@ -3499,8 +3508,8 @@ class CatalogBuilder {
|
|
|
3499
3508
|
const entityProviders = lodash__default["default"].uniqBy([...this.entityProviders, locationStore, configLocationProvider], (provider) => provider.getProviderName());
|
|
3500
3509
|
const processingEngine = new DefaultCatalogProcessingEngine(logger, processingDatabase, orchestrator, stitcher, () => crypto.createHash("sha1"));
|
|
3501
3510
|
const locationAnalyzer = (_b = this.locationAnalyzer) != null ? _b : new RepoLocationAnalyzer(logger, integrations);
|
|
3502
|
-
const locationService = new AuthorizedLocationService(new DefaultLocationService(locationStore, orchestrator),
|
|
3503
|
-
const refreshService = new AuthorizedRefreshService(new DefaultRefreshService({ database: processingDatabase }),
|
|
3511
|
+
const locationService = new AuthorizedLocationService(new DefaultLocationService(locationStore, orchestrator), permissionEvaluator);
|
|
3512
|
+
const refreshService = new AuthorizedRefreshService(new DefaultRefreshService({ database: processingDatabase }), permissionEvaluator);
|
|
3504
3513
|
const router = await createRouter({
|
|
3505
3514
|
entitiesCatalog,
|
|
3506
3515
|
locationAnalyzer,
|