@backstage/plugin-permission-common 0.0.0-nightly-20220216022224 → 0.0.0-nightly-20220217022146
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 +4 -2
- package/package.json +13 -10
- package/dist/index.d.ts +0 -206
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @backstage/plugin-permission-common
|
|
2
2
|
|
|
3
|
-
## 0.0.0-nightly-
|
|
3
|
+
## 0.0.0-nightly-20220217022146
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
@@ -9,8 +9,10 @@
|
|
|
9
9
|
### Patch Changes
|
|
10
10
|
|
|
11
11
|
- 1ed305728b: Bump `node-fetch` to version 2.6.7 and `cross-fetch` to version 3.1.5
|
|
12
|
+
- c77c5c7eb6: Added `backstage.role` to `package.json`
|
|
12
13
|
- Updated dependencies
|
|
13
|
-
- @backstage/errors@0.0.0-nightly-
|
|
14
|
+
- @backstage/errors@0.0.0-nightly-20220217022146
|
|
15
|
+
- @backstage/config@0.0.0-nightly-20220217022146
|
|
14
16
|
|
|
15
17
|
## 0.4.0
|
|
16
18
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-permission-common",
|
|
3
3
|
"description": "Isomorphic types and client for Backstage permissions and authorization",
|
|
4
|
-
"version": "0.0.0-nightly-
|
|
4
|
+
"version": "0.0.0-nightly-20220217022146",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"publishConfig": {
|
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
"module": "dist/index.esm.js",
|
|
11
11
|
"types": "dist/index.d.ts"
|
|
12
12
|
},
|
|
13
|
+
"backstage": {
|
|
14
|
+
"role": "common-library"
|
|
15
|
+
},
|
|
13
16
|
"homepage": "https://backstage.io",
|
|
14
17
|
"repository": {
|
|
15
18
|
"type": "git",
|
|
@@ -27,25 +30,25 @@
|
|
|
27
30
|
],
|
|
28
31
|
"configSchema": "config.d.ts",
|
|
29
32
|
"scripts": {
|
|
30
|
-
"build": "backstage-cli build",
|
|
31
|
-
"lint": "backstage-cli lint",
|
|
32
|
-
"test": "backstage-cli test",
|
|
33
|
-
"prepack": "backstage-cli prepack",
|
|
34
|
-
"postpack": "backstage-cli postpack",
|
|
35
|
-
"clean": "backstage-cli clean"
|
|
33
|
+
"build": "backstage-cli package build",
|
|
34
|
+
"lint": "backstage-cli package lint",
|
|
35
|
+
"test": "backstage-cli package test",
|
|
36
|
+
"prepack": "backstage-cli package prepack",
|
|
37
|
+
"postpack": "backstage-cli package postpack",
|
|
38
|
+
"clean": "backstage-cli package clean"
|
|
36
39
|
},
|
|
37
40
|
"bugs": {
|
|
38
41
|
"url": "https://github.com/backstage/backstage/issues"
|
|
39
42
|
},
|
|
40
43
|
"dependencies": {
|
|
41
|
-
"@backstage/config": "^0.
|
|
42
|
-
"@backstage/errors": "^0.0.0-nightly-
|
|
44
|
+
"@backstage/config": "^0.0.0-nightly-20220217022146",
|
|
45
|
+
"@backstage/errors": "^0.0.0-nightly-20220217022146",
|
|
43
46
|
"cross-fetch": "^3.1.5",
|
|
44
47
|
"uuid": "^8.0.0",
|
|
45
48
|
"zod": "^3.11.6"
|
|
46
49
|
},
|
|
47
50
|
"devDependencies": {
|
|
48
|
-
"@backstage/cli": "^0.0.0-nightly-
|
|
51
|
+
"@backstage/cli": "^0.0.0-nightly-20220217022146",
|
|
49
52
|
"@types/jest": "^26.0.7",
|
|
50
53
|
"msw": "^0.35.0"
|
|
51
54
|
},
|
package/dist/index.d.ts
DELETED
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
import { Config } from '@backstage/config';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* The attributes related to a given permission; these should be generic and widely applicable to
|
|
5
|
-
* all permissions in the system.
|
|
6
|
-
* @public
|
|
7
|
-
*/
|
|
8
|
-
declare type PermissionAttributes = {
|
|
9
|
-
action?: 'create' | 'read' | 'update' | 'delete';
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* A permission that can be checked through authorization.
|
|
13
|
-
*
|
|
14
|
-
* Permissions are the "what" part of authorization, the action to be performed. This may be reading
|
|
15
|
-
* an entity from the catalog, executing a software template, or any other action a plugin author
|
|
16
|
-
* may wish to protect.
|
|
17
|
-
*
|
|
18
|
-
* To evaluate authorization, a permission is paired with a Backstage identity (the "who") and
|
|
19
|
-
* evaluated using an authorization policy.
|
|
20
|
-
* @public
|
|
21
|
-
*/
|
|
22
|
-
declare type Permission = {
|
|
23
|
-
name: string;
|
|
24
|
-
attributes: PermissionAttributes;
|
|
25
|
-
resourceType?: string;
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* A client interacting with the permission backend can implement this authorizer interface.
|
|
29
|
-
* @public
|
|
30
|
-
*/
|
|
31
|
-
interface PermissionAuthorizer {
|
|
32
|
-
authorize(queries: AuthorizeQuery[], options?: AuthorizeRequestOptions): Promise<AuthorizeDecision[]>;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Options for authorization requests.
|
|
36
|
-
* @public
|
|
37
|
-
*/
|
|
38
|
-
declare type AuthorizeRequestOptions = {
|
|
39
|
-
token?: string;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* A request with a UUID identifier, so that batched responses can be matched up with the original
|
|
44
|
-
* requests.
|
|
45
|
-
* @public
|
|
46
|
-
*/
|
|
47
|
-
declare type Identified<T> = T & {
|
|
48
|
-
id: string;
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* The result of an authorization request.
|
|
52
|
-
* @public
|
|
53
|
-
*/
|
|
54
|
-
declare enum AuthorizeResult {
|
|
55
|
-
/**
|
|
56
|
-
* The authorization request is denied.
|
|
57
|
-
*/
|
|
58
|
-
DENY = "DENY",
|
|
59
|
-
/**
|
|
60
|
-
* The authorization request is allowed.
|
|
61
|
-
*/
|
|
62
|
-
ALLOW = "ALLOW",
|
|
63
|
-
/**
|
|
64
|
-
* The authorization request is allowed if the provided conditions are met.
|
|
65
|
-
*/
|
|
66
|
-
CONDITIONAL = "CONDITIONAL"
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* An individual authorization request for {@link PermissionClient#authorize}.
|
|
70
|
-
* @public
|
|
71
|
-
*/
|
|
72
|
-
declare type AuthorizeQuery = {
|
|
73
|
-
permission: Permission;
|
|
74
|
-
resourceRef?: string;
|
|
75
|
-
};
|
|
76
|
-
/**
|
|
77
|
-
* A batch of authorization requests from {@link PermissionClient#authorize}.
|
|
78
|
-
* @public
|
|
79
|
-
*/
|
|
80
|
-
declare type AuthorizeRequest = {
|
|
81
|
-
items: Identified<AuthorizeQuery>[];
|
|
82
|
-
};
|
|
83
|
-
/**
|
|
84
|
-
* A condition returned with a CONDITIONAL authorization response.
|
|
85
|
-
*
|
|
86
|
-
* Conditions are a reference to a rule defined by a plugin, and parameters to apply the rule. For
|
|
87
|
-
* example, a rule might be `isOwner` from the catalog-backend, and params may be a list of entity
|
|
88
|
-
* claims from a identity token.
|
|
89
|
-
* @public
|
|
90
|
-
*/
|
|
91
|
-
declare type PermissionCondition<TParams extends unknown[] = unknown[]> = {
|
|
92
|
-
rule: string;
|
|
93
|
-
params: TParams;
|
|
94
|
-
};
|
|
95
|
-
/**
|
|
96
|
-
* Utility type to represent an array with 1 or more elements.
|
|
97
|
-
* @ignore
|
|
98
|
-
*/
|
|
99
|
-
declare type NonEmptyArray<T> = [T, ...T[]];
|
|
100
|
-
/**
|
|
101
|
-
* Represnts a logical AND for the provided criteria.
|
|
102
|
-
* @public
|
|
103
|
-
*/
|
|
104
|
-
declare type AllOfCriteria<TQuery> = {
|
|
105
|
-
allOf: NonEmptyArray<PermissionCriteria<TQuery>>;
|
|
106
|
-
};
|
|
107
|
-
/**
|
|
108
|
-
* Represnts a logical OR for the provided criteria.
|
|
109
|
-
* @public
|
|
110
|
-
*/
|
|
111
|
-
declare type AnyOfCriteria<TQuery> = {
|
|
112
|
-
anyOf: NonEmptyArray<PermissionCriteria<TQuery>>;
|
|
113
|
-
};
|
|
114
|
-
/**
|
|
115
|
-
* Represents a negation of the provided criteria.
|
|
116
|
-
* @public
|
|
117
|
-
*/
|
|
118
|
-
declare type NotCriteria<TQuery> = {
|
|
119
|
-
not: PermissionCriteria<TQuery>;
|
|
120
|
-
};
|
|
121
|
-
/**
|
|
122
|
-
* Composes several {@link PermissionCondition}s as criteria with a nested AND/OR structure.
|
|
123
|
-
* @public
|
|
124
|
-
*/
|
|
125
|
-
declare type PermissionCriteria<TQuery> = AllOfCriteria<TQuery> | AnyOfCriteria<TQuery> | NotCriteria<TQuery> | TQuery;
|
|
126
|
-
/**
|
|
127
|
-
* An individual authorization response from {@link PermissionClient#authorize}.
|
|
128
|
-
* @public
|
|
129
|
-
*/
|
|
130
|
-
declare type AuthorizeDecision = {
|
|
131
|
-
result: AuthorizeResult.ALLOW | AuthorizeResult.DENY;
|
|
132
|
-
} | {
|
|
133
|
-
result: AuthorizeResult.CONDITIONAL;
|
|
134
|
-
conditions: PermissionCriteria<PermissionCondition>;
|
|
135
|
-
};
|
|
136
|
-
/**
|
|
137
|
-
* A batch of authorization responses from {@link PermissionClient#authorize}.
|
|
138
|
-
* @public
|
|
139
|
-
*/
|
|
140
|
-
declare type AuthorizeResponse = {
|
|
141
|
-
items: Identified<AuthorizeDecision>[];
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* This is a copy of the core DiscoveryApi, to avoid importing core.
|
|
146
|
-
*
|
|
147
|
-
* @public
|
|
148
|
-
*/
|
|
149
|
-
declare type DiscoveryApi = {
|
|
150
|
-
getBaseUrl(pluginId: string): Promise<string>;
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Check if a given permission is related to a create action.
|
|
155
|
-
* @public
|
|
156
|
-
*/
|
|
157
|
-
declare function isCreatePermission(permission: Permission): boolean;
|
|
158
|
-
/**
|
|
159
|
-
* Check if a given permission is related to a read action.
|
|
160
|
-
* @public
|
|
161
|
-
*/
|
|
162
|
-
declare function isReadPermission(permission: Permission): boolean;
|
|
163
|
-
/**
|
|
164
|
-
* Check if a given permission is related to an update action.
|
|
165
|
-
* @public
|
|
166
|
-
*/
|
|
167
|
-
declare function isUpdatePermission(permission: Permission): boolean;
|
|
168
|
-
/**
|
|
169
|
-
* Check if a given permission is related to a delete action.
|
|
170
|
-
* @public
|
|
171
|
-
*/
|
|
172
|
-
declare function isDeletePermission(permission: Permission): boolean;
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* An isomorphic client for requesting authorization for Backstage permissions.
|
|
176
|
-
* @public
|
|
177
|
-
*/
|
|
178
|
-
declare class PermissionClient implements PermissionAuthorizer {
|
|
179
|
-
private readonly enabled;
|
|
180
|
-
private readonly discovery;
|
|
181
|
-
constructor(options: {
|
|
182
|
-
discovery: DiscoveryApi;
|
|
183
|
-
config: Config;
|
|
184
|
-
});
|
|
185
|
-
/**
|
|
186
|
-
* Request authorization from the permission-backend for the given set of permissions.
|
|
187
|
-
*
|
|
188
|
-
* Authorization requests check that a given Backstage user can perform a protected operation,
|
|
189
|
-
* potentially for a specific resource (such as a catalog entity). The Backstage identity token
|
|
190
|
-
* should be included in the `options` if available.
|
|
191
|
-
*
|
|
192
|
-
* Permissions can be imported from plugins exposing them, such as `catalogEntityReadPermission`.
|
|
193
|
-
*
|
|
194
|
-
* The response will be either ALLOW or DENY when either the permission has no resourceType, or a
|
|
195
|
-
* resourceRef is provided in the request. For permissions with a resourceType, CONDITIONAL may be
|
|
196
|
-
* returned if no resourceRef is provided in the request. Conditional responses are intended only
|
|
197
|
-
* for backends which have access to the data source for permissioned resources, so that filters
|
|
198
|
-
* can be applied when loading collections of resources.
|
|
199
|
-
* @public
|
|
200
|
-
*/
|
|
201
|
-
authorize(queries: AuthorizeQuery[], options?: AuthorizeRequestOptions): Promise<AuthorizeDecision[]>;
|
|
202
|
-
private getAuthorizationHeader;
|
|
203
|
-
private assertValidResponse;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
export { AllOfCriteria, AnyOfCriteria, AuthorizeDecision, AuthorizeQuery, AuthorizeRequest, AuthorizeRequestOptions, AuthorizeResponse, AuthorizeResult, DiscoveryApi, Identified, NotCriteria, Permission, PermissionAttributes, PermissionAuthorizer, PermissionClient, PermissionCondition, PermissionCriteria, isCreatePermission, isDeletePermission, isReadPermission, isUpdatePermission };
|