@backstage/plugin-catalog-backend 1.0.0 → 1.1.0-next.2
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 +84 -0
- package/README.md +1 -2
- package/alpha/package.json +1 -1
- package/dist/index.alpha.d.ts +59 -32
- package/dist/index.beta.d.ts +14 -11
- package/dist/index.cjs.js +245 -152
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +14 -11
- package/package.json +15 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,87 @@
|
|
|
1
1
|
# @backstage/plugin-catalog-backend
|
|
2
2
|
|
|
3
|
+
## 1.1.0-next.2
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- bf82edf4c9: Added `/validate-entity` endpoint
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 8592cacfd3: Fixed an issue where sometimes entities would have stale relations "stuck" and
|
|
12
|
+
not getting removed as expected, after the other end of the relation had stopped
|
|
13
|
+
referring to them.
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
- @backstage/catalog-model@1.0.1-next.1
|
|
16
|
+
|
|
17
|
+
## 1.1.0-next.1
|
|
18
|
+
|
|
19
|
+
### Minor Changes
|
|
20
|
+
|
|
21
|
+
- 8012ac46a0: **BREAKING (alpha api):** Replace `createCatalogPolicyDecision` export with `createCatalogConditionalDecision`, which accepts a permission parameter of type `ResourcePermission<'catalog-entity'>` along with conditions. The permission passed is expected to be the handled permission in `PermissionPolicy#handle`, whose type must first be narrowed using methods like `isPermission` and `isResourcePermission`:
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
class TestPermissionPolicy implements PermissionPolicy {
|
|
25
|
+
async handle(
|
|
26
|
+
request: PolicyQuery<Permission>,
|
|
27
|
+
_user?: BackstageIdentityResponse,
|
|
28
|
+
): Promise<PolicyDecision> {
|
|
29
|
+
if (
|
|
30
|
+
// Narrow type of `request.permission` to `ResourcePermission<'catalog-entity'>
|
|
31
|
+
isResourcePermission(request.permission, RESOURCE_TYPE_CATALOG_ENTITY)
|
|
32
|
+
) {
|
|
33
|
+
return createCatalogConditionalDecision(
|
|
34
|
+
request.permission,
|
|
35
|
+
catalogConditions.isEntityOwner(
|
|
36
|
+
_user?.identity.ownershipEntityRefs ?? [],
|
|
37
|
+
),
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
result: AuthorizeResult.ALLOW,
|
|
43
|
+
};
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
- 8012ac46a0: **BREAKING:** Mark CatalogBuilder#addPermissionRules as @alpha.
|
|
47
|
+
- fb02d2d94d: export `locationSpecToLocationEntity`
|
|
48
|
+
|
|
49
|
+
### Patch Changes
|
|
50
|
+
|
|
51
|
+
- ada4446733: Specify type of `visibilityPermission` property on collators and collator factories.
|
|
52
|
+
- 1691c6c5c2: Clarify that config locations that emit User and Group kinds now need to declare so in the `catalog.locations.[].rules`
|
|
53
|
+
- 8012ac46a0: Handle changes to @alpha permission-related types.
|
|
54
|
+
|
|
55
|
+
- All exported permission rules and conditions now have a `resourceType`.
|
|
56
|
+
- `createCatalogConditionalDecision` now expects supplied conditions to have the appropriate `resourceType`.
|
|
57
|
+
- `createCatalogPermissionRule` now expects `resourceType` as part of the supplied rule object.
|
|
58
|
+
- Introduce new `CatalogPermissionRule` convenience type.
|
|
59
|
+
|
|
60
|
+
- Updated dependencies
|
|
61
|
+
- @backstage/integration@1.1.0-next.1
|
|
62
|
+
- @backstage/plugin-permission-common@0.6.0-next.0
|
|
63
|
+
- @backstage/plugin-permission-node@0.6.0-next.1
|
|
64
|
+
- @backstage/plugin-catalog-common@1.0.1-next.1
|
|
65
|
+
- @backstage/backend-common@0.13.2-next.1
|
|
66
|
+
- @backstage/plugin-search-common@0.3.3-next.1
|
|
67
|
+
|
|
68
|
+
## 1.0.1-next.0
|
|
69
|
+
|
|
70
|
+
### Patch Changes
|
|
71
|
+
|
|
72
|
+
- 9fe24b0fc8: Adjust the error messages when entities fail validation, to clearly state what entity that failed it
|
|
73
|
+
- 95408dbe99: Enable internal batching of very large deletions, to not run into SQL binding limits
|
|
74
|
+
- ffec894ed0: add gitlab to AnnotateScmSlugEntityProcessor
|
|
75
|
+
- Updated dependencies
|
|
76
|
+
- @backstage/catalog-model@1.0.1-next.0
|
|
77
|
+
- @backstage/plugin-search-common@0.3.3-next.0
|
|
78
|
+
- @backstage/backend-common@0.13.2-next.0
|
|
79
|
+
- @backstage/integration@1.0.1-next.0
|
|
80
|
+
- @backstage/catalog-client@1.0.1-next.0
|
|
81
|
+
- @backstage/plugin-scaffolder-common@1.0.1-next.0
|
|
82
|
+
- @backstage/plugin-permission-node@0.5.6-next.0
|
|
83
|
+
- @backstage/plugin-catalog-common@1.0.1-next.0
|
|
84
|
+
|
|
3
85
|
## 1.0.0
|
|
4
86
|
|
|
5
87
|
### Major Changes
|
|
@@ -1377,6 +1459,8 @@
|
|
|
1377
1459
|
locations:
|
|
1378
1460
|
- type: github-multi-org
|
|
1379
1461
|
target: https://github.myorg.com
|
|
1462
|
+
rules:
|
|
1463
|
+
- allow: [User, Group]
|
|
1380
1464
|
|
|
1381
1465
|
processors:
|
|
1382
1466
|
githubMultiOrg:
|
package/README.md
CHANGED
|
@@ -27,8 +27,7 @@ restoring the plugin, if you previously removed it.
|
|
|
27
27
|
|
|
28
28
|
```bash
|
|
29
29
|
# From your Backstage root directory
|
|
30
|
-
|
|
31
|
-
yarn add @backstage/plugin-catalog-backend
|
|
30
|
+
yarn add --cwd packages/backend @backstage/plugin-catalog-backend
|
|
32
31
|
```
|
|
33
32
|
|
|
34
33
|
### Adding the plugin to your `packages/backend`
|
package/alpha/package.json
CHANGED
package/dist/index.alpha.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { CatalogApi } from '@backstage/catalog-client';
|
|
10
10
|
import { CatalogEntityDocument } from '@backstage/plugin-catalog-common';
|
|
11
11
|
import { CompoundEntityRef } from '@backstage/catalog-model';
|
|
12
|
-
import { ConditionalPolicyDecision } from '@backstage/plugin-permission-
|
|
12
|
+
import { ConditionalPolicyDecision } from '@backstage/plugin-permission-common';
|
|
13
13
|
import { Conditions } from '@backstage/plugin-permission-node';
|
|
14
14
|
import { Config } from '@backstage/config';
|
|
15
15
|
import { DocumentCollatorFactory } from '@backstage/plugin-search-common';
|
|
@@ -17,6 +17,7 @@ import { Entity } from '@backstage/catalog-model';
|
|
|
17
17
|
import { EntityPolicy } from '@backstage/catalog-model';
|
|
18
18
|
import { GetEntitiesRequest } from '@backstage/catalog-client';
|
|
19
19
|
import { JsonValue } from '@backstage/types';
|
|
20
|
+
import { LocationEntityV1alpha1 } from '@backstage/catalog-model';
|
|
20
21
|
import { Logger } from 'winston';
|
|
21
22
|
import { Permission } from '@backstage/plugin-permission-common';
|
|
22
23
|
import { PermissionAuthorizer } from '@backstage/plugin-permission-common';
|
|
@@ -26,6 +27,7 @@ import { PermissionRule } from '@backstage/plugin-permission-node';
|
|
|
26
27
|
import { PluginDatabaseManager } from '@backstage/backend-common';
|
|
27
28
|
import { PluginEndpointDiscovery } from '@backstage/backend-common';
|
|
28
29
|
import { Readable } from 'stream';
|
|
30
|
+
import { ResourcePermission } from '@backstage/plugin-permission-common';
|
|
29
31
|
import { Router } from 'express';
|
|
30
32
|
import { ScmIntegrationRegistry } from '@backstage/integration';
|
|
31
33
|
import { TokenManager } from '@backstage/backend-common';
|
|
@@ -269,8 +271,9 @@ export declare class CatalogBuilder {
|
|
|
269
271
|
* {@link @backstage/plugin-permission-node#PermissionRule}.
|
|
270
272
|
*
|
|
271
273
|
* @param permissionRules - Additional permission rules
|
|
274
|
+
* @alpha
|
|
272
275
|
*/
|
|
273
|
-
addPermissionRules(...permissionRules:
|
|
276
|
+
addPermissionRules(...permissionRules: CatalogPermissionRule[]): void;
|
|
274
277
|
/**
|
|
275
278
|
* Wires up and returns all of the component parts of the catalog
|
|
276
279
|
*/
|
|
@@ -285,18 +288,18 @@ export declare class CatalogBuilder {
|
|
|
285
288
|
}
|
|
286
289
|
|
|
287
290
|
/**
|
|
288
|
-
* These conditions are used when creating conditional decisions
|
|
289
|
-
* by authorization policies.
|
|
291
|
+
* These conditions are used when creating conditional decisions for catalog
|
|
292
|
+
* entities that are returned by authorization policies.
|
|
290
293
|
*
|
|
291
294
|
* @alpha
|
|
292
295
|
*/
|
|
293
296
|
export declare const catalogConditions: Conditions< {
|
|
294
|
-
hasAnnotation: PermissionRule<Entity, EntitiesSearchFilter, [annotation: string]>;
|
|
295
|
-
hasLabel: PermissionRule<Entity, EntitiesSearchFilter, [label: string]>;
|
|
296
|
-
hasMetadata: PermissionRule<Entity, EntitiesSearchFilter, [key: string, value?: string | undefined]>;
|
|
297
|
-
hasSpec: PermissionRule<Entity, EntitiesSearchFilter, [key: string, value?: string | undefined]>;
|
|
298
|
-
isEntityKind: PermissionRule<Entity, EntitiesSearchFilter, [kinds: string[]]>;
|
|
299
|
-
isEntityOwner: PermissionRule<Entity, EntitiesSearchFilter, [claims: string[]]>;
|
|
297
|
+
hasAnnotation: PermissionRule<Entity, EntitiesSearchFilter, "catalog-entity", [annotation: string]>;
|
|
298
|
+
hasLabel: PermissionRule<Entity, EntitiesSearchFilter, "catalog-entity", [label: string]>;
|
|
299
|
+
hasMetadata: PermissionRule<Entity, EntitiesSearchFilter, "catalog-entity", [key: string, value?: string | undefined]>;
|
|
300
|
+
hasSpec: PermissionRule<Entity, EntitiesSearchFilter, "catalog-entity", [key: string, value?: string | undefined]>;
|
|
301
|
+
isEntityKind: PermissionRule<Entity, EntitiesSearchFilter, "catalog-entity", [kinds: string[]]>;
|
|
302
|
+
isEntityOwner: PermissionRule<Entity, EntitiesSearchFilter, "catalog-entity", [claims: string[]]>;
|
|
300
303
|
}>;
|
|
301
304
|
|
|
302
305
|
/** @public */
|
|
@@ -308,6 +311,15 @@ export declare type CatalogEnvironment = {
|
|
|
308
311
|
permissions: PermissionAuthorizer;
|
|
309
312
|
};
|
|
310
313
|
|
|
314
|
+
/**
|
|
315
|
+
* Convenience type for {@link @backstage/plugin-permission-node#PermissionRule}
|
|
316
|
+
* instances with the correct resource type, resource, and filter to work with
|
|
317
|
+
* the catalog.
|
|
318
|
+
*
|
|
319
|
+
* @alpha
|
|
320
|
+
*/
|
|
321
|
+
export declare type CatalogPermissionRule<TParams extends unknown[] = unknown[]> = PermissionRule<Entity, EntitiesSearchFilter, 'catalog-entity', TParams>;
|
|
322
|
+
|
|
311
323
|
/** @public */
|
|
312
324
|
export declare interface CatalogProcessingEngine {
|
|
313
325
|
start(): Promise<void>;
|
|
@@ -465,37 +477,46 @@ export declare class CodeOwnersProcessor implements CatalogProcessor {
|
|
|
465
477
|
}
|
|
466
478
|
|
|
467
479
|
/**
|
|
468
|
-
*
|
|
469
|
-
*
|
|
470
|
-
* catalog-
|
|
471
|
-
*
|
|
472
|
-
*
|
|
473
|
-
|
|
474
|
-
export declare const createCatalogPermissionRule: <TParams extends unknown[]>(rule: PermissionRule<Entity, EntitiesSearchFilter, TParams>) => PermissionRule<Entity, EntitiesSearchFilter, TParams>;
|
|
475
|
-
|
|
476
|
-
/**
|
|
477
|
-
* `createCatalogPolicyDecision` can be used when authoring policies to create
|
|
478
|
-
* conditional decisions.
|
|
480
|
+
* `createCatalogConditionalDecision` can be used when authoring policies to
|
|
481
|
+
* create conditional decisions. It requires a permission of type
|
|
482
|
+
* `ResourcePermission<'catalog-entity'>` to be passed as the first parameter.
|
|
483
|
+
* It's recommended that you use the provided `isResourcePermission` and
|
|
484
|
+
* `isPermission` helper methods to narrow the type of the permission passed to
|
|
485
|
+
* the handle method as shown below.
|
|
479
486
|
*
|
|
480
487
|
* ```
|
|
481
488
|
* // MyAuthorizationPolicy.ts
|
|
482
489
|
* ...
|
|
483
490
|
* import { createCatalogPolicyDecision } from '@backstage/plugin-catalog-backend';
|
|
491
|
+
* import { RESOURCE_TYPE_CATALOG_ENTITY } from '@backstage/plugin-catalog-common';
|
|
484
492
|
*
|
|
485
493
|
* class MyAuthorizationPolicy implements PermissionPolicy {
|
|
486
494
|
* async handle(request, user) {
|
|
487
495
|
* ...
|
|
488
496
|
*
|
|
489
|
-
*
|
|
490
|
-
*
|
|
491
|
-
*
|
|
492
|
-
*
|
|
497
|
+
* if (isResourcePermission(request.permission, RESOURCE_TYPE_CATALOG_ENTITY)) {
|
|
498
|
+
* return createCatalogConditionalDecision(
|
|
499
|
+
* request.permission,
|
|
500
|
+
* { anyOf: [...insert conditions here...] }
|
|
501
|
+
* );
|
|
502
|
+
* }
|
|
503
|
+
*
|
|
504
|
+
* ...
|
|
493
505
|
* }
|
|
494
506
|
* ```
|
|
495
507
|
*
|
|
496
508
|
* @alpha
|
|
497
509
|
*/
|
|
498
|
-
export declare const
|
|
510
|
+
export declare const createCatalogConditionalDecision: (permission: ResourcePermission<"catalog-entity">, conditions: PermissionCriteria<PermissionCondition<"catalog-entity", unknown[]>>) => ConditionalPolicyDecision;
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* Helper function for creating correctly-typed
|
|
514
|
+
* {@link @backstage/plugin-permission-node#PermissionRule}s for the
|
|
515
|
+
* catalog-backend.
|
|
516
|
+
*
|
|
517
|
+
* @alpha
|
|
518
|
+
*/
|
|
519
|
+
export declare const createCatalogPermissionRule: <TParams extends unknown[]>(rule: PermissionRule<Entity, EntitiesSearchFilter, "catalog-entity", TParams>) => PermissionRule<Entity, EntitiesSearchFilter, "catalog-entity", TParams>;
|
|
499
520
|
|
|
500
521
|
/**
|
|
501
522
|
* Creates a function that returns a random processing interval between minSeconds and maxSeconds.
|
|
@@ -716,6 +737,12 @@ export declare type LocationSpec = {
|
|
|
716
737
|
presence?: 'optional' | 'required';
|
|
717
738
|
};
|
|
718
739
|
|
|
740
|
+
/** @public */
|
|
741
|
+
export declare function locationSpecToLocationEntity(opts: {
|
|
742
|
+
location: LocationSpec;
|
|
743
|
+
parentEntity?: Entity;
|
|
744
|
+
}): LocationEntityV1alpha1;
|
|
745
|
+
|
|
719
746
|
/** @public */
|
|
720
747
|
export declare function parseEntityYaml(data: Buffer, location: LocationSpec): Iterable<CatalogProcessorResult>;
|
|
721
748
|
|
|
@@ -726,12 +753,12 @@ export declare function parseEntityYaml(data: Buffer, location: LocationSpec): I
|
|
|
726
753
|
* @alpha
|
|
727
754
|
*/
|
|
728
755
|
export declare const permissionRules: {
|
|
729
|
-
hasAnnotation: PermissionRule<Entity, EntitiesSearchFilter, [annotation: string]>;
|
|
730
|
-
hasLabel: PermissionRule<Entity, EntitiesSearchFilter, [label: string]>;
|
|
731
|
-
hasMetadata: PermissionRule<Entity, EntitiesSearchFilter, [key: string, value?: string | undefined]>;
|
|
732
|
-
hasSpec: PermissionRule<Entity, EntitiesSearchFilter, [key: string, value?: string | undefined]>;
|
|
733
|
-
isEntityKind: PermissionRule<Entity, EntitiesSearchFilter, [kinds: string[]]>;
|
|
734
|
-
isEntityOwner: PermissionRule<Entity, EntitiesSearchFilter, [claims: string[]]>;
|
|
756
|
+
hasAnnotation: PermissionRule<Entity, EntitiesSearchFilter, "catalog-entity", [annotation: string]>;
|
|
757
|
+
hasLabel: PermissionRule<Entity, EntitiesSearchFilter, "catalog-entity", [label: string]>;
|
|
758
|
+
hasMetadata: PermissionRule<Entity, EntitiesSearchFilter, "catalog-entity", [key: string, value?: string | undefined]>;
|
|
759
|
+
hasSpec: PermissionRule<Entity, EntitiesSearchFilter, "catalog-entity", [key: string, value?: string | undefined]>;
|
|
760
|
+
isEntityKind: PermissionRule<Entity, EntitiesSearchFilter, "catalog-entity", [kinds: string[]]>;
|
|
761
|
+
isEntityOwner: PermissionRule<Entity, EntitiesSearchFilter, "catalog-entity", [claims: string[]]>;
|
|
735
762
|
};
|
|
736
763
|
|
|
737
764
|
/**
|
package/dist/index.beta.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { CatalogApi } from '@backstage/catalog-client';
|
|
10
10
|
import { CatalogEntityDocument } from '@backstage/plugin-catalog-common';
|
|
11
11
|
import { CompoundEntityRef } from '@backstage/catalog-model';
|
|
12
|
-
import { ConditionalPolicyDecision } from '@backstage/plugin-permission-
|
|
12
|
+
import { ConditionalPolicyDecision } from '@backstage/plugin-permission-common';
|
|
13
13
|
import { Conditions } from '@backstage/plugin-permission-node';
|
|
14
14
|
import { Config } from '@backstage/config';
|
|
15
15
|
import { DocumentCollatorFactory } from '@backstage/plugin-search-common';
|
|
@@ -17,6 +17,7 @@ import { Entity } from '@backstage/catalog-model';
|
|
|
17
17
|
import { EntityPolicy } from '@backstage/catalog-model';
|
|
18
18
|
import { GetEntitiesRequest } from '@backstage/catalog-client';
|
|
19
19
|
import { JsonValue } from '@backstage/types';
|
|
20
|
+
import { LocationEntityV1alpha1 } from '@backstage/catalog-model';
|
|
20
21
|
import { Logger } from 'winston';
|
|
21
22
|
import { Permission } from '@backstage/plugin-permission-common';
|
|
22
23
|
import { PermissionAuthorizer } from '@backstage/plugin-permission-common';
|
|
@@ -26,6 +27,7 @@ import { PermissionRule } from '@backstage/plugin-permission-node';
|
|
|
26
27
|
import { PluginDatabaseManager } from '@backstage/backend-common';
|
|
27
28
|
import { PluginEndpointDiscovery } from '@backstage/backend-common';
|
|
28
29
|
import { Readable } from 'stream';
|
|
30
|
+
import { ResourcePermission } from '@backstage/plugin-permission-common';
|
|
29
31
|
import { Router } from 'express';
|
|
30
32
|
import { ScmIntegrationRegistry } from '@backstage/integration';
|
|
31
33
|
import { TokenManager } from '@backstage/backend-common';
|
|
@@ -263,14 +265,7 @@ export declare class CatalogBuilder {
|
|
|
263
265
|
* @param parser - The custom parser
|
|
264
266
|
*/
|
|
265
267
|
setEntityDataParser(parser: CatalogProcessorParser): CatalogBuilder;
|
|
266
|
-
|
|
267
|
-
* Adds additional permission rules. Permission rules are used to evaluate
|
|
268
|
-
* catalog resources against queries. See
|
|
269
|
-
* {@link @backstage/plugin-permission-node#PermissionRule}.
|
|
270
|
-
*
|
|
271
|
-
* @param permissionRules - Additional permission rules
|
|
272
|
-
*/
|
|
273
|
-
addPermissionRules(...permissionRules: PermissionRule<Entity, EntitiesSearchFilter, unknown[]>[]): void;
|
|
268
|
+
/* Excluded from this release type: addPermissionRules */
|
|
274
269
|
/**
|
|
275
270
|
* Wires up and returns all of the component parts of the catalog
|
|
276
271
|
*/
|
|
@@ -295,6 +290,8 @@ export declare type CatalogEnvironment = {
|
|
|
295
290
|
permissions: PermissionAuthorizer;
|
|
296
291
|
};
|
|
297
292
|
|
|
293
|
+
/* Excluded from this release type: CatalogPermissionRule */
|
|
294
|
+
|
|
298
295
|
/** @public */
|
|
299
296
|
export declare interface CatalogProcessingEngine {
|
|
300
297
|
start(): Promise<void>;
|
|
@@ -451,9 +448,9 @@ export declare class CodeOwnersProcessor implements CatalogProcessor {
|
|
|
451
448
|
preProcessEntity(entity: Entity, location: LocationSpec): Promise<Entity>;
|
|
452
449
|
}
|
|
453
450
|
|
|
454
|
-
/* Excluded from this release type:
|
|
451
|
+
/* Excluded from this release type: createCatalogConditionalDecision */
|
|
455
452
|
|
|
456
|
-
/* Excluded from this release type:
|
|
453
|
+
/* Excluded from this release type: createCatalogPermissionRule */
|
|
457
454
|
|
|
458
455
|
/**
|
|
459
456
|
* Creates a function that returns a random processing interval between minSeconds and maxSeconds.
|
|
@@ -674,6 +671,12 @@ export declare type LocationSpec = {
|
|
|
674
671
|
presence?: 'optional' | 'required';
|
|
675
672
|
};
|
|
676
673
|
|
|
674
|
+
/** @public */
|
|
675
|
+
export declare function locationSpecToLocationEntity(opts: {
|
|
676
|
+
location: LocationSpec;
|
|
677
|
+
parentEntity?: Entity;
|
|
678
|
+
}): LocationEntityV1alpha1;
|
|
679
|
+
|
|
677
680
|
/** @public */
|
|
678
681
|
export declare function parseEntityYaml(data: Buffer, location: LocationSpec): Iterable<CatalogProcessorResult>;
|
|
679
682
|
|