@backstage/plugin-permission-common 0.7.4 → 0.7.5
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 +20 -0
- package/dist/index.d.ts +29 -29
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @backstage/plugin-permission-common
|
|
2
2
|
|
|
3
|
+
## 0.7.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 1e4f5e91b8e: Bump `zod` and `zod-to-json-schema` dependencies.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/config@1.0.7
|
|
10
|
+
- @backstage/errors@1.1.5
|
|
11
|
+
- @backstage/types@1.0.2
|
|
12
|
+
|
|
13
|
+
## 0.7.5-next.0
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- 1e4f5e91b8e: Bump `zod` and `zod-to-json-schema` dependencies.
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
- @backstage/config@1.0.7
|
|
20
|
+
- @backstage/errors@1.1.5
|
|
21
|
+
- @backstage/types@1.0.2
|
|
22
|
+
|
|
3
23
|
## 0.7.4
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -6,14 +6,14 @@ import { Config } from '@backstage/config';
|
|
|
6
6
|
* all permissions in the system.
|
|
7
7
|
* @public
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
type PermissionAttributes = {
|
|
10
10
|
action?: 'create' | 'read' | 'update' | 'delete';
|
|
11
11
|
};
|
|
12
12
|
/**
|
|
13
13
|
* Generic type for building {@link Permission} types.
|
|
14
14
|
* @public
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
type PermissionBase<TType extends string, TFields extends object> = {
|
|
17
17
|
/**
|
|
18
18
|
* The name of the permission.
|
|
19
19
|
*/
|
|
@@ -46,18 +46,18 @@ declare type PermissionBase<TType extends string, TFields extends object> = {
|
|
|
46
46
|
* evaluated using an authorization policy.
|
|
47
47
|
* @public
|
|
48
48
|
*/
|
|
49
|
-
|
|
49
|
+
type Permission = BasicPermission | ResourcePermission;
|
|
50
50
|
/**
|
|
51
51
|
* A standard {@link Permission} with no additional capabilities or restrictions.
|
|
52
52
|
* @public
|
|
53
53
|
*/
|
|
54
|
-
|
|
54
|
+
type BasicPermission = PermissionBase<'basic', {}>;
|
|
55
55
|
/**
|
|
56
56
|
* ResourcePermissions are {@link Permission}s that can be authorized based on
|
|
57
57
|
* characteristics of a resource such a catalog entity.
|
|
58
58
|
* @public
|
|
59
59
|
*/
|
|
60
|
-
|
|
60
|
+
type ResourcePermission<TResourceType extends string = string> = PermissionBase<'resource', {
|
|
61
61
|
/**
|
|
62
62
|
* Denotes the type of the resource whose resourceRef should be passed when
|
|
63
63
|
* authorizing.
|
|
@@ -76,7 +76,7 @@ interface PermissionAuthorizer {
|
|
|
76
76
|
* Options for authorization requests.
|
|
77
77
|
* @public
|
|
78
78
|
*/
|
|
79
|
-
|
|
79
|
+
type AuthorizeRequestOptions = {
|
|
80
80
|
token?: string;
|
|
81
81
|
};
|
|
82
82
|
|
|
@@ -85,14 +85,14 @@ declare type AuthorizeRequestOptions = {
|
|
|
85
85
|
* requests.
|
|
86
86
|
* @public
|
|
87
87
|
*/
|
|
88
|
-
|
|
88
|
+
type IdentifiedPermissionMessage<T> = T & {
|
|
89
89
|
id: string;
|
|
90
90
|
};
|
|
91
91
|
/**
|
|
92
92
|
* A batch of request or response items.
|
|
93
93
|
* @public
|
|
94
94
|
*/
|
|
95
|
-
|
|
95
|
+
type PermissionMessageBatch<T> = {
|
|
96
96
|
items: IdentifiedPermissionMessage<T>[];
|
|
97
97
|
};
|
|
98
98
|
/**
|
|
@@ -122,7 +122,7 @@ declare enum AuthorizeResult {
|
|
|
122
122
|
*
|
|
123
123
|
* @public
|
|
124
124
|
*/
|
|
125
|
-
|
|
125
|
+
type DefinitivePolicyDecision = {
|
|
126
126
|
result: AuthorizeResult.ALLOW | AuthorizeResult.DENY;
|
|
127
127
|
};
|
|
128
128
|
/**
|
|
@@ -136,7 +136,7 @@ declare type DefinitivePolicyDecision = {
|
|
|
136
136
|
*
|
|
137
137
|
* @public
|
|
138
138
|
*/
|
|
139
|
-
|
|
139
|
+
type ConditionalPolicyDecision = {
|
|
140
140
|
result: AuthorizeResult.CONDITIONAL;
|
|
141
141
|
pluginId: string;
|
|
142
142
|
resourceType: string;
|
|
@@ -147,7 +147,7 @@ declare type ConditionalPolicyDecision = {
|
|
|
147
147
|
*
|
|
148
148
|
* @public
|
|
149
149
|
*/
|
|
150
|
-
|
|
150
|
+
type PolicyDecision = DefinitivePolicyDecision | ConditionalPolicyDecision;
|
|
151
151
|
/**
|
|
152
152
|
* A condition returned with a CONDITIONAL authorization response.
|
|
153
153
|
*
|
|
@@ -156,7 +156,7 @@ declare type PolicyDecision = DefinitivePolicyDecision | ConditionalPolicyDecisi
|
|
|
156
156
|
* claims from a identity token.
|
|
157
157
|
* @public
|
|
158
158
|
*/
|
|
159
|
-
|
|
159
|
+
type PermissionCondition<TResourceType extends string = string, TParams extends PermissionRuleParams = PermissionRuleParams> = {
|
|
160
160
|
resourceType: TResourceType;
|
|
161
161
|
rule: string;
|
|
162
162
|
params?: TParams;
|
|
@@ -165,50 +165,50 @@ declare type PermissionCondition<TResourceType extends string = string, TParams
|
|
|
165
165
|
* Utility type to represent an array with 1 or more elements.
|
|
166
166
|
* @ignore
|
|
167
167
|
*/
|
|
168
|
-
|
|
168
|
+
type NonEmptyArray<T> = [T, ...T[]];
|
|
169
169
|
/**
|
|
170
170
|
* Represents a logical AND for the provided criteria.
|
|
171
171
|
* @public
|
|
172
172
|
*/
|
|
173
|
-
|
|
173
|
+
type AllOfCriteria<TQuery> = {
|
|
174
174
|
allOf: NonEmptyArray<PermissionCriteria<TQuery>>;
|
|
175
175
|
};
|
|
176
176
|
/**
|
|
177
177
|
* Represents a logical OR for the provided criteria.
|
|
178
178
|
* @public
|
|
179
179
|
*/
|
|
180
|
-
|
|
180
|
+
type AnyOfCriteria<TQuery> = {
|
|
181
181
|
anyOf: NonEmptyArray<PermissionCriteria<TQuery>>;
|
|
182
182
|
};
|
|
183
183
|
/**
|
|
184
184
|
* Represents a negation of the provided criteria.
|
|
185
185
|
* @public
|
|
186
186
|
*/
|
|
187
|
-
|
|
187
|
+
type NotCriteria<TQuery> = {
|
|
188
188
|
not: PermissionCriteria<TQuery>;
|
|
189
189
|
};
|
|
190
190
|
/**
|
|
191
191
|
* Composes several {@link PermissionCondition}s as criteria with a nested AND/OR structure.
|
|
192
192
|
* @public
|
|
193
193
|
*/
|
|
194
|
-
|
|
194
|
+
type PermissionCriteria<TQuery> = AllOfCriteria<TQuery> | AnyOfCriteria<TQuery> | NotCriteria<TQuery> | TQuery;
|
|
195
195
|
/**
|
|
196
196
|
* A parameter to a permission rule.
|
|
197
197
|
*
|
|
198
198
|
* @public
|
|
199
199
|
*/
|
|
200
|
-
|
|
200
|
+
type PermissionRuleParam = undefined | JsonPrimitive | JsonPrimitive[];
|
|
201
201
|
/**
|
|
202
202
|
* Types that can be used as parameters to permission rules.
|
|
203
203
|
*
|
|
204
204
|
* @public
|
|
205
205
|
*/
|
|
206
|
-
|
|
206
|
+
type PermissionRuleParams = undefined | Record<string, PermissionRuleParam>;
|
|
207
207
|
/**
|
|
208
208
|
* An individual request sent to the permission backend.
|
|
209
209
|
* @public
|
|
210
210
|
*/
|
|
211
|
-
|
|
211
|
+
type EvaluatePermissionRequest = {
|
|
212
212
|
permission: Permission;
|
|
213
213
|
resourceRef?: string;
|
|
214
214
|
};
|
|
@@ -216,7 +216,7 @@ declare type EvaluatePermissionRequest = {
|
|
|
216
216
|
* A batch of requests sent to the permission backend.
|
|
217
217
|
* @public
|
|
218
218
|
*/
|
|
219
|
-
|
|
219
|
+
type EvaluatePermissionRequestBatch = PermissionMessageBatch<EvaluatePermissionRequest>;
|
|
220
220
|
/**
|
|
221
221
|
* An individual response from the permission backend.
|
|
222
222
|
*
|
|
@@ -228,18 +228,18 @@ declare type EvaluatePermissionRequestBatch = PermissionMessageBatch<EvaluatePer
|
|
|
228
228
|
*
|
|
229
229
|
* @public
|
|
230
230
|
*/
|
|
231
|
-
|
|
231
|
+
type EvaluatePermissionResponse = PolicyDecision;
|
|
232
232
|
/**
|
|
233
233
|
* A batch of responses from the permission backend.
|
|
234
234
|
* @public
|
|
235
235
|
*/
|
|
236
|
-
|
|
236
|
+
type EvaluatePermissionResponseBatch = PermissionMessageBatch<EvaluatePermissionResponse>;
|
|
237
237
|
/**
|
|
238
238
|
* Request object for {@link PermissionEvaluator.authorize}. If a {@link ResourcePermission}
|
|
239
239
|
* is provided, it must include a corresponding `resourceRef`.
|
|
240
240
|
* @public
|
|
241
241
|
*/
|
|
242
|
-
|
|
242
|
+
type AuthorizePermissionRequest = {
|
|
243
243
|
permission: Exclude<Permission, ResourcePermission>;
|
|
244
244
|
resourceRef?: never;
|
|
245
245
|
} | {
|
|
@@ -250,12 +250,12 @@ declare type AuthorizePermissionRequest = {
|
|
|
250
250
|
* Response object for {@link PermissionEvaluator.authorize}.
|
|
251
251
|
* @public
|
|
252
252
|
*/
|
|
253
|
-
|
|
253
|
+
type AuthorizePermissionResponse = DefinitivePolicyDecision;
|
|
254
254
|
/**
|
|
255
255
|
* Request object for {@link PermissionEvaluator.authorizeConditional}.
|
|
256
256
|
* @public
|
|
257
257
|
*/
|
|
258
|
-
|
|
258
|
+
type QueryPermissionRequest = {
|
|
259
259
|
permission: ResourcePermission;
|
|
260
260
|
resourceRef?: never;
|
|
261
261
|
};
|
|
@@ -263,7 +263,7 @@ declare type QueryPermissionRequest = {
|
|
|
263
263
|
* Response object for {@link PermissionEvaluator.authorizeConditional}.
|
|
264
264
|
* @public
|
|
265
265
|
*/
|
|
266
|
-
|
|
266
|
+
type QueryPermissionResponse = PolicyDecision;
|
|
267
267
|
/**
|
|
268
268
|
* A client interacting with the permission backend can implement this evaluator interface.
|
|
269
269
|
*
|
|
@@ -289,7 +289,7 @@ interface PermissionEvaluator {
|
|
|
289
289
|
* The Backstage identity token should be defined if available.
|
|
290
290
|
* @public
|
|
291
291
|
*/
|
|
292
|
-
|
|
292
|
+
type EvaluatorRequestOptions = {
|
|
293
293
|
token?: string;
|
|
294
294
|
};
|
|
295
295
|
|
|
@@ -298,7 +298,7 @@ declare type EvaluatorRequestOptions = {
|
|
|
298
298
|
*
|
|
299
299
|
* @public
|
|
300
300
|
*/
|
|
301
|
-
|
|
301
|
+
type DiscoveryApi = {
|
|
302
302
|
getBaseUrl(pluginId: string): Promise<string>;
|
|
303
303
|
};
|
|
304
304
|
|
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.7.
|
|
4
|
+
"version": "0.7.5",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"publishConfig": {
|
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
"@backstage/types": "^1.0.2",
|
|
47
47
|
"cross-fetch": "^3.1.5",
|
|
48
48
|
"uuid": "^8.0.0",
|
|
49
|
-
"zod": "
|
|
49
|
+
"zod": "^3.21.4"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@backstage/cli": "^0.22.
|
|
52
|
+
"@backstage/cli": "^0.22.6",
|
|
53
53
|
"msw": "^1.0.0"
|
|
54
54
|
},
|
|
55
55
|
"module": "dist/index.esm.js"
|