@backstage/plugin-permission-backend 0.5.51 → 0.5.52-next.1
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
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @backstage/plugin-permission-backend
|
|
2
2
|
|
|
3
|
+
## 0.5.52-next.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 5c9cc05: Use native fetch instead of node-fetch
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/plugin-auth-node@0.5.5-next.1
|
|
10
|
+
- @backstage/backend-plugin-api@1.1.0-next.1
|
|
11
|
+
- @backstage/plugin-permission-node@0.8.6-next.1
|
|
12
|
+
- @backstage/config@1.3.0
|
|
13
|
+
- @backstage/errors@1.2.5
|
|
14
|
+
- @backstage/plugin-permission-common@0.8.2
|
|
15
|
+
|
|
16
|
+
## 0.5.52-next.0
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- 1e624ca: Restrict `@types/express` version range from `*` to `^4.17.6`.
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
- @backstage/backend-plugin-api@1.0.3-next.0
|
|
23
|
+
- @backstage/plugin-auth-node@0.5.5-next.0
|
|
24
|
+
- @backstage/config@1.3.0
|
|
25
|
+
- @backstage/errors@1.2.5
|
|
26
|
+
- @backstage/plugin-permission-common@0.8.2
|
|
27
|
+
- @backstage/plugin-permission-node@0.8.6-next.0
|
|
28
|
+
|
|
3
29
|
## 0.5.51
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var fetch = require('node-fetch');
|
|
4
3
|
var zod = require('zod');
|
|
5
4
|
var pluginPermissionCommon = require('@backstage/plugin-permission-common');
|
|
6
5
|
var errors = require('@backstage/errors');
|
|
7
6
|
|
|
8
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
9
|
-
|
|
10
|
-
var fetch__default = /*#__PURE__*/_interopDefaultCompat(fetch);
|
|
11
|
-
|
|
12
7
|
const responseSchema = zod.z.object({
|
|
13
8
|
items: zod.z.array(
|
|
14
9
|
zod.z.object({
|
|
@@ -31,7 +26,7 @@ class PermissionIntegrationClient {
|
|
|
31
26
|
onBehalfOf: credentials,
|
|
32
27
|
targetPluginId: pluginId
|
|
33
28
|
}).then((t) => t.token);
|
|
34
|
-
const response = await
|
|
29
|
+
const response = await fetch(endpoint, {
|
|
35
30
|
method: "POST",
|
|
36
31
|
body: JSON.stringify({
|
|
37
32
|
items: decisions.map(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PermissionIntegrationClient.cjs.js","sources":["../../src/service/PermissionIntegrationClient.ts"],"sourcesContent":["/*\n * Copyright 2021 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 */\n\nimport
|
|
1
|
+
{"version":3,"file":"PermissionIntegrationClient.cjs.js","sources":["../../src/service/PermissionIntegrationClient.ts"],"sourcesContent":["/*\n * Copyright 2021 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 */\n\nimport { z } from 'zod';\nimport {\n AuthorizeResult,\n ConditionalPolicyDecision,\n} from '@backstage/plugin-permission-common';\nimport {\n ApplyConditionsRequestEntry,\n ApplyConditionsResponseEntry,\n} from '@backstage/plugin-permission-node';\nimport {\n AuthService,\n BackstageCredentials,\n DiscoveryService,\n} from '@backstage/backend-plugin-api';\nimport { ResponseError } from '@backstage/errors';\n\nconst responseSchema = z.object({\n items: z.array(\n z.object({\n id: z.string(),\n result: z\n .literal(AuthorizeResult.ALLOW)\n .or(z.literal(AuthorizeResult.DENY)),\n }),\n ),\n});\n\nexport type ResourcePolicyDecision = ConditionalPolicyDecision & {\n resourceRef: string;\n};\n\nexport class PermissionIntegrationClient {\n private readonly discovery: DiscoveryService;\n private readonly auth: AuthService;\n\n constructor(options: { discovery: DiscoveryService; auth: AuthService }) {\n this.discovery = options.discovery;\n this.auth = options.auth;\n }\n\n async applyConditions(\n pluginId: string,\n credentials: BackstageCredentials,\n decisions: readonly ApplyConditionsRequestEntry[],\n ): Promise<ApplyConditionsResponseEntry[]> {\n const baseUrl = await this.discovery.getBaseUrl(pluginId);\n const endpoint = `${baseUrl}/.well-known/backstage/permissions/apply-conditions`;\n\n const token = this.auth.isPrincipal(credentials, 'none')\n ? undefined\n : await this.auth\n .getPluginRequestToken({\n onBehalfOf: credentials,\n targetPluginId: pluginId,\n })\n .then(t => t.token);\n\n const response = await fetch(endpoint, {\n method: 'POST',\n body: JSON.stringify({\n items: decisions.map(\n ({ id, resourceRef, resourceType, conditions }) => ({\n id,\n resourceRef,\n resourceType,\n conditions,\n }),\n ),\n }),\n headers: {\n ...(token ? { authorization: `Bearer ${token}` } : {}),\n 'content-type': 'application/json',\n },\n });\n\n if (!response.ok) {\n throw await ResponseError.fromResponse(response);\n }\n\n const result = responseSchema.parse(await response.json());\n\n return result.items;\n }\n}\n"],"names":["z","AuthorizeResult","ResponseError"],"mappings":";;;;;;AAgCA,MAAM,cAAA,GAAiBA,MAAE,MAAO,CAAA;AAAA,EAC9B,OAAO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,WAAA;AAAA,YACA,YAAA;AAAA,YACA;AAAA,WACF;AAAA;AACF,OACD,CAAA;AAAA,MACD,OAAS,EAAA;AAAA,QACP,GAAI,QAAQ,EAAE,aAAA,EAAe,UAAU,KAAK,CAAA,CAAA,KAAO,EAAC;AAAA,QACpD,cAAgB,EAAA;AAAA;AAClB,KACD,CAAA;AAED,IAAI,IAAA,CAAC,SAAS,EAAI,EAAA;AAChB,MAAM,MAAA,MAAMC,oBAAc,CAAA,YAAA,CAAa,QAAQ,CAAA;AAAA;AAGjD,IAAA,MAAM,SAAS,cAAe,CAAA,KAAA,CAAM,MAAM,QAAA,CAAS,MAAM,CAAA;AAEzD,IAAA,OAAO,MAAO,CAAA,KAAA;AAAA;AAElB;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-permission-backend",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.52-next.1",
|
|
4
4
|
"backstage": {
|
|
5
5
|
"role": "backend-plugin",
|
|
6
6
|
"pluginId": "permission",
|
|
@@ -62,24 +62,23 @@
|
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@backstage/backend-common": "^0.25.0",
|
|
65
|
-
"@backstage/backend-plugin-api": "
|
|
66
|
-
"@backstage/config": "
|
|
67
|
-
"@backstage/errors": "
|
|
68
|
-
"@backstage/plugin-auth-node": "
|
|
69
|
-
"@backstage/plugin-permission-common": "
|
|
70
|
-
"@backstage/plugin-permission-node": "
|
|
71
|
-
"@types/express": "
|
|
65
|
+
"@backstage/backend-plugin-api": "1.1.0-next.1",
|
|
66
|
+
"@backstage/config": "1.3.0",
|
|
67
|
+
"@backstage/errors": "1.2.5",
|
|
68
|
+
"@backstage/plugin-auth-node": "0.5.5-next.1",
|
|
69
|
+
"@backstage/plugin-permission-common": "0.8.2",
|
|
70
|
+
"@backstage/plugin-permission-node": "0.8.6-next.1",
|
|
71
|
+
"@types/express": "^4.17.6",
|
|
72
72
|
"dataloader": "^2.0.0",
|
|
73
73
|
"express": "^4.17.1",
|
|
74
74
|
"express-promise-router": "^4.1.0",
|
|
75
75
|
"lodash": "^4.17.21",
|
|
76
|
-
"node-fetch": "^2.7.0",
|
|
77
76
|
"yn": "^4.0.0",
|
|
78
77
|
"zod": "^3.22.4"
|
|
79
78
|
},
|
|
80
79
|
"devDependencies": {
|
|
81
|
-
"@backstage/backend-test-utils": "
|
|
82
|
-
"@backstage/cli": "
|
|
80
|
+
"@backstage/backend-test-utils": "1.2.0-next.1",
|
|
81
|
+
"@backstage/cli": "0.29.3-next.1",
|
|
83
82
|
"@types/lodash": "^4.14.151",
|
|
84
83
|
"@types/supertest": "^2.0.8",
|
|
85
84
|
"msw": "^1.0.0",
|