@backstage-community/plugin-rbac-common 1.12.2 → 1.12.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 +6 -0
- package/dist/index.d.ts +84 -0
- package/dist/permissions.cjs.js.map +1 -1
- package/dist/permissions.esm.js.map +1 -1
- package/dist/types.cjs.js.map +1 -1
- package/dist/types.esm.js.map +1 -1
- package/package.json +12 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
## @backstage-community/plugin-rbac-common [1.8.2](https://github.com/janus-idp/backstage-plugins/compare/@backstage-community/plugin-rbac-common@1.8.1...@backstage-community/plugin-rbac-common@1.8.2) (2024-08-06)
|
|
2
2
|
|
|
3
|
+
## 1.12.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4b3653a: Clean up api report warnings and remove unnecessary files
|
|
8
|
+
|
|
3
9
|
## 1.12.2
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
import { NotAllowedError } from '@backstage/errors';
|
|
2
2
|
import { PermissionAttributes, ConditionalPolicyDecision, ResourcePermission } from '@backstage/plugin-permission-common';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* @public
|
|
6
|
+
* 'rest' created via REST API
|
|
7
|
+
* 'csv-file' created via policies-csv-file with defined path in the application configuration
|
|
8
|
+
* 'configuration' created from application configuration
|
|
9
|
+
* 'legacy'; preexisting policies
|
|
10
|
+
*/
|
|
4
11
|
type Source = string;
|
|
12
|
+
/**
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
5
15
|
type PermissionPolicyMetadata = {
|
|
6
16
|
source: Source;
|
|
7
17
|
};
|
|
18
|
+
/**
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
8
21
|
type RoleMetadata = {
|
|
9
22
|
description?: string;
|
|
10
23
|
source?: Source;
|
|
@@ -13,84 +26,155 @@ type RoleMetadata = {
|
|
|
13
26
|
lastModified?: string;
|
|
14
27
|
createdAt?: string;
|
|
15
28
|
};
|
|
29
|
+
/**
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
16
32
|
type Policy = {
|
|
17
33
|
permission?: string;
|
|
18
34
|
policy?: string;
|
|
19
35
|
};
|
|
36
|
+
/**
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
20
39
|
type RoleBasedPolicy = Policy & {
|
|
21
40
|
entityReference?: string;
|
|
22
41
|
effect?: string;
|
|
23
42
|
metadata?: PermissionPolicyMetadata;
|
|
24
43
|
};
|
|
44
|
+
/**
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
25
47
|
type Role = {
|
|
26
48
|
memberReferences: string[];
|
|
27
49
|
name: string;
|
|
28
50
|
metadata?: RoleMetadata;
|
|
29
51
|
};
|
|
52
|
+
/**
|
|
53
|
+
* @public
|
|
54
|
+
*/
|
|
30
55
|
type UpdatePolicy = {
|
|
31
56
|
oldPolicy: Policy;
|
|
32
57
|
newPolicy: Policy;
|
|
33
58
|
};
|
|
59
|
+
/**
|
|
60
|
+
* @public
|
|
61
|
+
*/
|
|
34
62
|
type NamedPolicy = {
|
|
35
63
|
name: string;
|
|
36
64
|
policy: string;
|
|
37
65
|
};
|
|
66
|
+
/**
|
|
67
|
+
* @public
|
|
68
|
+
*/
|
|
38
69
|
type ResourcedPolicy = NamedPolicy & {
|
|
39
70
|
resourceType: string;
|
|
40
71
|
};
|
|
72
|
+
/**
|
|
73
|
+
* @public
|
|
74
|
+
*/
|
|
41
75
|
type PolicyDetails = NamedPolicy | ResourcedPolicy;
|
|
76
|
+
/**
|
|
77
|
+
* @public
|
|
78
|
+
*/
|
|
42
79
|
declare function isResourcedPolicy(policy: PolicyDetails): policy is ResourcedPolicy;
|
|
80
|
+
/**
|
|
81
|
+
* @public
|
|
82
|
+
*/
|
|
43
83
|
type PluginPermissionMetaData = {
|
|
44
84
|
pluginId: string;
|
|
45
85
|
policies: PolicyDetails[];
|
|
46
86
|
};
|
|
87
|
+
/**
|
|
88
|
+
* @public
|
|
89
|
+
*/
|
|
47
90
|
type NonEmptyArray<T> = [T, ...T[]];
|
|
91
|
+
/**
|
|
92
|
+
* @public
|
|
93
|
+
* Permission framework attributes action has values: 'create' | 'read' | 'update' | 'delete' | undefined.
|
|
94
|
+
* But we are introducing an action named "use" when action does not exist('undefined') to avoid
|
|
95
|
+
* a more complicated model with multiple policy and request shapes.
|
|
96
|
+
*/
|
|
48
97
|
declare const PermissionActionValues: readonly ["create", "read", "update", "delete", "use"];
|
|
98
|
+
/**
|
|
99
|
+
* @public
|
|
100
|
+
*/
|
|
49
101
|
type PermissionAction = (typeof PermissionActionValues)[number];
|
|
102
|
+
/**
|
|
103
|
+
* @public
|
|
104
|
+
*/
|
|
50
105
|
declare const toPermissionAction: (attr: PermissionAttributes) => PermissionAction;
|
|
106
|
+
/**
|
|
107
|
+
* @public
|
|
108
|
+
*/
|
|
51
109
|
declare function isValidPermissionAction(action: string): action is PermissionAction;
|
|
110
|
+
/**
|
|
111
|
+
* @public
|
|
112
|
+
*/
|
|
52
113
|
type PermissionInfo = {
|
|
53
114
|
name: string;
|
|
54
115
|
action: PermissionAction;
|
|
55
116
|
};
|
|
117
|
+
/**
|
|
118
|
+
* @public
|
|
119
|
+
* Frontend should use RoleConditionalPolicyDecision<PermissionAction>
|
|
120
|
+
*/
|
|
56
121
|
type RoleConditionalPolicyDecision<T extends PermissionAction | PermissionInfo> = ConditionalPolicyDecision & {
|
|
57
122
|
id: number;
|
|
58
123
|
roleEntityRef: string;
|
|
59
124
|
permissionMapping: T[];
|
|
60
125
|
};
|
|
126
|
+
/**
|
|
127
|
+
* @public
|
|
128
|
+
*/
|
|
61
129
|
declare const ConditionalAliases: {
|
|
62
130
|
readonly CURRENT_USER: "currentUser";
|
|
63
131
|
readonly OWNER_REFS: "ownerRefs";
|
|
64
132
|
};
|
|
133
|
+
/**
|
|
134
|
+
* @public
|
|
135
|
+
*/
|
|
65
136
|
declare const CONDITION_ALIAS_SIGN = "$";
|
|
137
|
+
/**
|
|
138
|
+
* @public
|
|
139
|
+
* UnauthorizedError should be uniformely used for authorization errors.
|
|
140
|
+
*/
|
|
66
141
|
declare class UnauthorizedError extends NotAllowedError {
|
|
67
142
|
constructor();
|
|
68
143
|
}
|
|
69
144
|
|
|
145
|
+
/**
|
|
146
|
+
* @public
|
|
147
|
+
*/
|
|
70
148
|
declare const RESOURCE_TYPE_POLICY_ENTITY = "policy-entity";
|
|
71
149
|
/**
|
|
150
|
+
* @public
|
|
72
151
|
* Convenience type for permission entity
|
|
73
152
|
*/
|
|
74
153
|
type PolicyEntityPermission = ResourcePermission<typeof RESOURCE_TYPE_POLICY_ENTITY>;
|
|
75
154
|
/**
|
|
155
|
+
* @public
|
|
76
156
|
* This permission is used to authorize actions that involve reading
|
|
77
157
|
* permission policies.
|
|
78
158
|
*/
|
|
79
159
|
declare const policyEntityReadPermission: ResourcePermission<"policy-entity">;
|
|
80
160
|
/**
|
|
161
|
+
* @public
|
|
81
162
|
* This permission is used to authorize the creation of new permission policies.
|
|
82
163
|
*/
|
|
83
164
|
declare const policyEntityCreatePermission: ResourcePermission<"policy-entity">;
|
|
84
165
|
/**
|
|
166
|
+
* @public
|
|
85
167
|
* This permission is used to authorize actions that involve removing permission
|
|
86
168
|
* policies.
|
|
87
169
|
*/
|
|
88
170
|
declare const policyEntityDeletePermission: ResourcePermission<"policy-entity">;
|
|
89
171
|
/**
|
|
172
|
+
* @public
|
|
90
173
|
* This permission is used to authorize updating permission policies
|
|
91
174
|
*/
|
|
92
175
|
declare const policyEntityUpdatePermission: ResourcePermission<"policy-entity">;
|
|
93
176
|
/**
|
|
177
|
+
* @public
|
|
94
178
|
* List of all permissions on permission polices.
|
|
95
179
|
*/
|
|
96
180
|
declare const policyEntityPermissions: ResourcePermission<"policy-entity">[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permissions.cjs.js","sources":["../src/permissions.ts"],"sourcesContent":["/*\n * Copyright 2024 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 createPermission,\n ResourcePermission,\n} from '@backstage/plugin-permission-common';\n\nexport const RESOURCE_TYPE_POLICY_ENTITY = 'policy-entity';\n\n/**\n * Convenience type for permission entity\n */\nexport type PolicyEntityPermission = ResourcePermission<\n typeof RESOURCE_TYPE_POLICY_ENTITY\n>;\n\n/**\n * This permission is used to authorize actions that involve reading\n * permission policies.\n */\nexport const policyEntityReadPermission = createPermission({\n name: 'policy.entity.read',\n attributes: {\n action: 'read',\n },\n resourceType: RESOURCE_TYPE_POLICY_ENTITY,\n});\n\n/**\n * This permission is used to authorize the creation of new permission policies.\n */\nexport const policyEntityCreatePermission = createPermission({\n name: 'policy.entity.create',\n attributes: {\n action: 'create',\n },\n resourceType: RESOURCE_TYPE_POLICY_ENTITY,\n});\n\n/**\n * This permission is used to authorize actions that involve removing permission\n * policies.\n */\nexport const policyEntityDeletePermission = createPermission({\n name: 'policy.entity.delete',\n attributes: {\n action: 'delete',\n },\n resourceType: RESOURCE_TYPE_POLICY_ENTITY,\n});\n\n/**\n * This permission is used to authorize updating permission policies\n */\nexport const policyEntityUpdatePermission = createPermission({\n name: 'policy.entity.update',\n attributes: {\n action: 'update',\n },\n resourceType: RESOURCE_TYPE_POLICY_ENTITY,\n});\n\n/**\n * List of all permissions on permission polices.\n */\nexport const policyEntityPermissions = [\n policyEntityReadPermission,\n policyEntityCreatePermission,\n policyEntityDeletePermission,\n policyEntityUpdatePermission,\n];\n"],"names":["createPermission"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"permissions.cjs.js","sources":["../src/permissions.ts"],"sourcesContent":["/*\n * Copyright 2024 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 createPermission,\n ResourcePermission,\n} from '@backstage/plugin-permission-common';\n\n/**\n * @public\n */\nexport const RESOURCE_TYPE_POLICY_ENTITY = 'policy-entity';\n\n/**\n * @public\n * Convenience type for permission entity\n */\nexport type PolicyEntityPermission = ResourcePermission<\n typeof RESOURCE_TYPE_POLICY_ENTITY\n>;\n\n/**\n * @public\n * This permission is used to authorize actions that involve reading\n * permission policies.\n */\nexport const policyEntityReadPermission = createPermission({\n name: 'policy.entity.read',\n attributes: {\n action: 'read',\n },\n resourceType: RESOURCE_TYPE_POLICY_ENTITY,\n});\n\n/**\n * @public\n * This permission is used to authorize the creation of new permission policies.\n */\nexport const policyEntityCreatePermission = createPermission({\n name: 'policy.entity.create',\n attributes: {\n action: 'create',\n },\n resourceType: RESOURCE_TYPE_POLICY_ENTITY,\n});\n\n/**\n * @public\n * This permission is used to authorize actions that involve removing permission\n * policies.\n */\nexport const policyEntityDeletePermission = createPermission({\n name: 'policy.entity.delete',\n attributes: {\n action: 'delete',\n },\n resourceType: RESOURCE_TYPE_POLICY_ENTITY,\n});\n\n/**\n * @public\n * This permission is used to authorize updating permission policies\n */\nexport const policyEntityUpdatePermission = createPermission({\n name: 'policy.entity.update',\n attributes: {\n action: 'update',\n },\n resourceType: RESOURCE_TYPE_POLICY_ENTITY,\n});\n\n/**\n * @public\n * List of all permissions on permission polices.\n */\nexport const policyEntityPermissions = [\n policyEntityReadPermission,\n policyEntityCreatePermission,\n policyEntityDeletePermission,\n policyEntityUpdatePermission,\n];\n"],"names":["createPermission"],"mappings":";;;;AAuBO,MAAM,2BAA8B,GAAA;AAepC,MAAM,6BAA6BA,uCAAiB,CAAA;AAAA,EACzD,IAAM,EAAA,oBAAA;AAAA,EACN,UAAY,EAAA;AAAA,IACV,MAAQ,EAAA;AAAA,GACV;AAAA,EACA,YAAc,EAAA;AAChB,CAAC;AAMM,MAAM,+BAA+BA,uCAAiB,CAAA;AAAA,EAC3D,IAAM,EAAA,sBAAA;AAAA,EACN,UAAY,EAAA;AAAA,IACV,MAAQ,EAAA;AAAA,GACV;AAAA,EACA,YAAc,EAAA;AAChB,CAAC;AAOM,MAAM,+BAA+BA,uCAAiB,CAAA;AAAA,EAC3D,IAAM,EAAA,sBAAA;AAAA,EACN,UAAY,EAAA;AAAA,IACV,MAAQ,EAAA;AAAA,GACV;AAAA,EACA,YAAc,EAAA;AAChB,CAAC;AAMM,MAAM,+BAA+BA,uCAAiB,CAAA;AAAA,EAC3D,IAAM,EAAA,sBAAA;AAAA,EACN,UAAY,EAAA;AAAA,IACV,MAAQ,EAAA;AAAA,GACV;AAAA,EACA,YAAc,EAAA;AAChB,CAAC;AAMM,MAAM,uBAA0B,GAAA;AAAA,EACrC,0BAAA;AAAA,EACA,4BAAA;AAAA,EACA,4BAAA;AAAA,EACA;AACF;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permissions.esm.js","sources":["../src/permissions.ts"],"sourcesContent":["/*\n * Copyright 2024 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 createPermission,\n ResourcePermission,\n} from '@backstage/plugin-permission-common';\n\nexport const RESOURCE_TYPE_POLICY_ENTITY = 'policy-entity';\n\n/**\n * Convenience type for permission entity\n */\nexport type PolicyEntityPermission = ResourcePermission<\n typeof RESOURCE_TYPE_POLICY_ENTITY\n>;\n\n/**\n * This permission is used to authorize actions that involve reading\n * permission policies.\n */\nexport const policyEntityReadPermission = createPermission({\n name: 'policy.entity.read',\n attributes: {\n action: 'read',\n },\n resourceType: RESOURCE_TYPE_POLICY_ENTITY,\n});\n\n/**\n * This permission is used to authorize the creation of new permission policies.\n */\nexport const policyEntityCreatePermission = createPermission({\n name: 'policy.entity.create',\n attributes: {\n action: 'create',\n },\n resourceType: RESOURCE_TYPE_POLICY_ENTITY,\n});\n\n/**\n * This permission is used to authorize actions that involve removing permission\n * policies.\n */\nexport const policyEntityDeletePermission = createPermission({\n name: 'policy.entity.delete',\n attributes: {\n action: 'delete',\n },\n resourceType: RESOURCE_TYPE_POLICY_ENTITY,\n});\n\n/**\n * This permission is used to authorize updating permission policies\n */\nexport const policyEntityUpdatePermission = createPermission({\n name: 'policy.entity.update',\n attributes: {\n action: 'update',\n },\n resourceType: RESOURCE_TYPE_POLICY_ENTITY,\n});\n\n/**\n * List of all permissions on permission polices.\n */\nexport const policyEntityPermissions = [\n policyEntityReadPermission,\n policyEntityCreatePermission,\n policyEntityDeletePermission,\n policyEntityUpdatePermission,\n];\n"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"permissions.esm.js","sources":["../src/permissions.ts"],"sourcesContent":["/*\n * Copyright 2024 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 createPermission,\n ResourcePermission,\n} from '@backstage/plugin-permission-common';\n\n/**\n * @public\n */\nexport const RESOURCE_TYPE_POLICY_ENTITY = 'policy-entity';\n\n/**\n * @public\n * Convenience type for permission entity\n */\nexport type PolicyEntityPermission = ResourcePermission<\n typeof RESOURCE_TYPE_POLICY_ENTITY\n>;\n\n/**\n * @public\n * This permission is used to authorize actions that involve reading\n * permission policies.\n */\nexport const policyEntityReadPermission = createPermission({\n name: 'policy.entity.read',\n attributes: {\n action: 'read',\n },\n resourceType: RESOURCE_TYPE_POLICY_ENTITY,\n});\n\n/**\n * @public\n * This permission is used to authorize the creation of new permission policies.\n */\nexport const policyEntityCreatePermission = createPermission({\n name: 'policy.entity.create',\n attributes: {\n action: 'create',\n },\n resourceType: RESOURCE_TYPE_POLICY_ENTITY,\n});\n\n/**\n * @public\n * This permission is used to authorize actions that involve removing permission\n * policies.\n */\nexport const policyEntityDeletePermission = createPermission({\n name: 'policy.entity.delete',\n attributes: {\n action: 'delete',\n },\n resourceType: RESOURCE_TYPE_POLICY_ENTITY,\n});\n\n/**\n * @public\n * This permission is used to authorize updating permission policies\n */\nexport const policyEntityUpdatePermission = createPermission({\n name: 'policy.entity.update',\n attributes: {\n action: 'update',\n },\n resourceType: RESOURCE_TYPE_POLICY_ENTITY,\n});\n\n/**\n * @public\n * List of all permissions on permission polices.\n */\nexport const policyEntityPermissions = [\n policyEntityReadPermission,\n policyEntityCreatePermission,\n policyEntityDeletePermission,\n policyEntityUpdatePermission,\n];\n"],"names":[],"mappings":";;AAuBO,MAAM,2BAA8B,GAAA;AAepC,MAAM,6BAA6B,gBAAiB,CAAA;AAAA,EACzD,IAAM,EAAA,oBAAA;AAAA,EACN,UAAY,EAAA;AAAA,IACV,MAAQ,EAAA;AAAA,GACV;AAAA,EACA,YAAc,EAAA;AAChB,CAAC;AAMM,MAAM,+BAA+B,gBAAiB,CAAA;AAAA,EAC3D,IAAM,EAAA,sBAAA;AAAA,EACN,UAAY,EAAA;AAAA,IACV,MAAQ,EAAA;AAAA,GACV;AAAA,EACA,YAAc,EAAA;AAChB,CAAC;AAOM,MAAM,+BAA+B,gBAAiB,CAAA;AAAA,EAC3D,IAAM,EAAA,sBAAA;AAAA,EACN,UAAY,EAAA;AAAA,IACV,MAAQ,EAAA;AAAA,GACV;AAAA,EACA,YAAc,EAAA;AAChB,CAAC;AAMM,MAAM,+BAA+B,gBAAiB,CAAA;AAAA,EAC3D,IAAM,EAAA,sBAAA;AAAA,EACN,UAAY,EAAA;AAAA,IACV,MAAQ,EAAA;AAAA,GACV;AAAA,EACA,YAAc,EAAA;AAChB,CAAC;AAMM,MAAM,uBAA0B,GAAA;AAAA,EACrC,0BAAA;AAAA,EACA,4BAAA;AAAA,EACA,4BAAA;AAAA,EACA;AACF;;;;"}
|
package/dist/types.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs.js","sources":["../src/types.ts"],"sourcesContent":["/*\n * Copyright 2024 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 { NotAllowedError } from '@backstage/errors';\nimport {\n ConditionalPolicyDecision,\n PermissionAttributes,\n} from '@backstage/plugin-permission-common';\n\n
|
|
1
|
+
{"version":3,"file":"types.cjs.js","sources":["../src/types.ts"],"sourcesContent":["/*\n * Copyright 2024 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 { NotAllowedError } from '@backstage/errors';\nimport {\n ConditionalPolicyDecision,\n PermissionAttributes,\n} from '@backstage/plugin-permission-common';\n\n/**\n * @public\n * 'rest' created via REST API\n * 'csv-file' created via policies-csv-file with defined path in the application configuration\n * 'configuration' created from application configuration\n * 'legacy'; preexisting policies\n */\nexport type Source = string;\n\n/**\n * @public\n */\nexport type PermissionPolicyMetadata = {\n source: Source;\n};\n\n/**\n * @public\n */\nexport type RoleMetadata = {\n description?: string;\n source?: Source;\n modifiedBy?: string;\n author?: string;\n lastModified?: string;\n createdAt?: string;\n};\n\n/**\n * @public\n */\nexport type Policy = {\n permission?: string;\n policy?: string;\n};\n\n/**\n * @public\n */\nexport type RoleBasedPolicy = Policy & {\n entityReference?: string;\n effect?: string;\n metadata?: PermissionPolicyMetadata;\n};\n\n/**\n * @public\n */\nexport type Role = {\n memberReferences: string[];\n name: string;\n metadata?: RoleMetadata;\n};\n\n/**\n * @public\n */\nexport type UpdatePolicy = {\n oldPolicy: Policy;\n newPolicy: Policy;\n};\n\n/**\n * @public\n */\nexport type NamedPolicy = {\n name: string;\n\n policy: string;\n};\n\n/**\n * @public\n */\nexport type ResourcedPolicy = NamedPolicy & {\n resourceType: string;\n};\n\n/**\n * @public\n */\nexport type PolicyDetails = NamedPolicy | ResourcedPolicy;\n\n/**\n * @public\n */\nexport function isResourcedPolicy(\n policy: PolicyDetails,\n): policy is ResourcedPolicy {\n return 'resourceType' in policy;\n}\n\n/**\n * @public\n */\nexport type PluginPermissionMetaData = {\n pluginId: string;\n policies: PolicyDetails[];\n};\n\n/**\n * @public\n */\nexport type NonEmptyArray<T> = [T, ...T[]];\n\n/**\n * @public\n * Permission framework attributes action has values: 'create' | 'read' | 'update' | 'delete' | undefined.\n * But we are introducing an action named \"use\" when action does not exist('undefined') to avoid\n * a more complicated model with multiple policy and request shapes.\n */\nexport const PermissionActionValues = [\n 'create',\n 'read',\n 'update',\n 'delete',\n 'use',\n] as const;\n\n/**\n * @public\n */\nexport type PermissionAction = (typeof PermissionActionValues)[number];\n\n/**\n * @public\n */\nexport const toPermissionAction = (\n attr: PermissionAttributes,\n): PermissionAction => attr.action ?? 'use';\n\n/**\n * @public\n */\nexport function isValidPermissionAction(\n action: string,\n): action is PermissionAction {\n return (PermissionActionValues as readonly string[]).includes(action);\n}\n\n/**\n * @public\n */\nexport type PermissionInfo = {\n name: string;\n action: PermissionAction;\n};\n\n/**\n * @public\n * Frontend should use RoleConditionalPolicyDecision<PermissionAction>\n */\nexport type RoleConditionalPolicyDecision<\n T extends PermissionAction | PermissionInfo,\n> = ConditionalPolicyDecision & {\n id: number;\n roleEntityRef: string;\n\n permissionMapping: T[];\n};\n\n/**\n * @public\n */\nexport const ConditionalAliases = {\n CURRENT_USER: 'currentUser',\n OWNER_REFS: 'ownerRefs',\n} as const;\n\n/**\n * @public\n */\nexport const CONDITION_ALIAS_SIGN = '$';\n\n/**\n * @public\n * UnauthorizedError should be uniformely used for authorization errors.\n */\nexport class UnauthorizedError extends NotAllowedError {\n constructor() {\n super('Unauthorized');\n }\n}\n"],"names":["NotAllowedError"],"mappings":";;;;AA2GO,SAAS,kBACd,MAC2B,EAAA;AAC3B,EAAA,OAAO,cAAkB,IAAA,MAAA;AAC3B;AAqBO,MAAM,sBAAyB,GAAA;AAAA,EACpC,QAAA;AAAA,EACA,MAAA;AAAA,EACA,QAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF;AAUO,MAAM,kBAAqB,GAAA,CAChC,IACqB,KAAA,IAAA,CAAK,MAAU,IAAA;AAK/B,SAAS,wBACd,MAC4B,EAAA;AAC5B,EAAQ,OAAA,sBAAA,CAA6C,SAAS,MAAM,CAAA;AACtE;AA0BO,MAAM,kBAAqB,GAAA;AAAA,EAChC,YAAc,EAAA,aAAA;AAAA,EACd,UAAY,EAAA;AACd;AAKO,MAAM,oBAAuB,GAAA;AAM7B,MAAM,0BAA0BA,sBAAgB,CAAA;AAAA,EACrD,WAAc,GAAA;AACZ,IAAA,KAAA,CAAM,cAAc,CAAA;AAAA;AAExB;;;;;;;;;;"}
|
package/dist/types.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.esm.js","sources":["../src/types.ts"],"sourcesContent":["/*\n * Copyright 2024 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 { NotAllowedError } from '@backstage/errors';\nimport {\n ConditionalPolicyDecision,\n PermissionAttributes,\n} from '@backstage/plugin-permission-common';\n\n
|
|
1
|
+
{"version":3,"file":"types.esm.js","sources":["../src/types.ts"],"sourcesContent":["/*\n * Copyright 2024 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 { NotAllowedError } from '@backstage/errors';\nimport {\n ConditionalPolicyDecision,\n PermissionAttributes,\n} from '@backstage/plugin-permission-common';\n\n/**\n * @public\n * 'rest' created via REST API\n * 'csv-file' created via policies-csv-file with defined path in the application configuration\n * 'configuration' created from application configuration\n * 'legacy'; preexisting policies\n */\nexport type Source = string;\n\n/**\n * @public\n */\nexport type PermissionPolicyMetadata = {\n source: Source;\n};\n\n/**\n * @public\n */\nexport type RoleMetadata = {\n description?: string;\n source?: Source;\n modifiedBy?: string;\n author?: string;\n lastModified?: string;\n createdAt?: string;\n};\n\n/**\n * @public\n */\nexport type Policy = {\n permission?: string;\n policy?: string;\n};\n\n/**\n * @public\n */\nexport type RoleBasedPolicy = Policy & {\n entityReference?: string;\n effect?: string;\n metadata?: PermissionPolicyMetadata;\n};\n\n/**\n * @public\n */\nexport type Role = {\n memberReferences: string[];\n name: string;\n metadata?: RoleMetadata;\n};\n\n/**\n * @public\n */\nexport type UpdatePolicy = {\n oldPolicy: Policy;\n newPolicy: Policy;\n};\n\n/**\n * @public\n */\nexport type NamedPolicy = {\n name: string;\n\n policy: string;\n};\n\n/**\n * @public\n */\nexport type ResourcedPolicy = NamedPolicy & {\n resourceType: string;\n};\n\n/**\n * @public\n */\nexport type PolicyDetails = NamedPolicy | ResourcedPolicy;\n\n/**\n * @public\n */\nexport function isResourcedPolicy(\n policy: PolicyDetails,\n): policy is ResourcedPolicy {\n return 'resourceType' in policy;\n}\n\n/**\n * @public\n */\nexport type PluginPermissionMetaData = {\n pluginId: string;\n policies: PolicyDetails[];\n};\n\n/**\n * @public\n */\nexport type NonEmptyArray<T> = [T, ...T[]];\n\n/**\n * @public\n * Permission framework attributes action has values: 'create' | 'read' | 'update' | 'delete' | undefined.\n * But we are introducing an action named \"use\" when action does not exist('undefined') to avoid\n * a more complicated model with multiple policy and request shapes.\n */\nexport const PermissionActionValues = [\n 'create',\n 'read',\n 'update',\n 'delete',\n 'use',\n] as const;\n\n/**\n * @public\n */\nexport type PermissionAction = (typeof PermissionActionValues)[number];\n\n/**\n * @public\n */\nexport const toPermissionAction = (\n attr: PermissionAttributes,\n): PermissionAction => attr.action ?? 'use';\n\n/**\n * @public\n */\nexport function isValidPermissionAction(\n action: string,\n): action is PermissionAction {\n return (PermissionActionValues as readonly string[]).includes(action);\n}\n\n/**\n * @public\n */\nexport type PermissionInfo = {\n name: string;\n action: PermissionAction;\n};\n\n/**\n * @public\n * Frontend should use RoleConditionalPolicyDecision<PermissionAction>\n */\nexport type RoleConditionalPolicyDecision<\n T extends PermissionAction | PermissionInfo,\n> = ConditionalPolicyDecision & {\n id: number;\n roleEntityRef: string;\n\n permissionMapping: T[];\n};\n\n/**\n * @public\n */\nexport const ConditionalAliases = {\n CURRENT_USER: 'currentUser',\n OWNER_REFS: 'ownerRefs',\n} as const;\n\n/**\n * @public\n */\nexport const CONDITION_ALIAS_SIGN = '$';\n\n/**\n * @public\n * UnauthorizedError should be uniformely used for authorization errors.\n */\nexport class UnauthorizedError extends NotAllowedError {\n constructor() {\n super('Unauthorized');\n }\n}\n"],"names":[],"mappings":";;AA2GO,SAAS,kBACd,MAC2B,EAAA;AAC3B,EAAA,OAAO,cAAkB,IAAA,MAAA;AAC3B;AAqBO,MAAM,sBAAyB,GAAA;AAAA,EACpC,QAAA;AAAA,EACA,MAAA;AAAA,EACA,QAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF;AAUO,MAAM,kBAAqB,GAAA,CAChC,IACqB,KAAA,IAAA,CAAK,MAAU,IAAA;AAK/B,SAAS,wBACd,MAC4B,EAAA;AAC5B,EAAQ,OAAA,sBAAA,CAA6C,SAAS,MAAM,CAAA;AACtE;AA0BO,MAAM,kBAAqB,GAAA;AAAA,EAChC,YAAc,EAAA,aAAA;AAAA,EACd,UAAY,EAAA;AACd;AAKO,MAAM,oBAAuB,GAAA;AAM7B,MAAM,0BAA0B,eAAgB,CAAA;AAAA,EACrD,WAAc,GAAA;AACZ,IAAA,KAAA,CAAM,cAAc,CAAA;AAAA;AAExB;;;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage-community/plugin-rbac-common",
|
|
3
3
|
"description": "Common functionalities for the rbac-common plugin",
|
|
4
|
-
"version": "1.12.
|
|
4
|
+
"version": "1.12.3",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@backstage/errors": "^1.2.4",
|
|
45
45
|
"@backstage/plugin-permission-common": "^0.8.1",
|
|
46
46
|
"@spotify/prettier-config": "^15.0.0",
|
|
47
|
-
"prettier": "3.3.3"
|
|
47
|
+
"prettier": "^3.3.3"
|
|
48
48
|
},
|
|
49
49
|
"files": [
|
|
50
50
|
"dist"
|
|
@@ -66,5 +66,15 @@
|
|
|
66
66
|
"@PatAKnight"
|
|
67
67
|
],
|
|
68
68
|
"author": "Red Hat",
|
|
69
|
+
"prettier": "@spotify/prettier-config",
|
|
70
|
+
"lint-staged": {
|
|
71
|
+
"*.{js,jsx,ts,tsx,mjs,cjs}": [
|
|
72
|
+
"eslint --fix",
|
|
73
|
+
"prettier --write"
|
|
74
|
+
],
|
|
75
|
+
"*.{json,md}": [
|
|
76
|
+
"prettier --write"
|
|
77
|
+
]
|
|
78
|
+
},
|
|
69
79
|
"module": "dist/index.esm.js"
|
|
70
80
|
}
|