Merge pull request #19720 from UsainBloot/backend-di/permission-policy-backend-module
[permission-backend] Move AllowAllPermissionPolicy to it's own backend module package
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-permission-backend': patch
|
||||
---
|
||||
|
||||
Moved `permissionModuleAllowAllPolicy` to `@backstage/plugin-permission-backend-module-allow-all-policy`
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-permission-backend-module-allow-all-policy': minor
|
||||
---
|
||||
|
||||
Created package with policy `permissionModuleAllowAllPolicy`
|
||||
@@ -41,6 +41,7 @@
|
||||
"@backstage/plugin-lighthouse-backend": "workspace:^",
|
||||
"@backstage/plugin-linguist-backend": "workspace:^",
|
||||
"@backstage/plugin-permission-backend": "workspace:^",
|
||||
"@backstage/plugin-permission-backend-module-allow-all-policy": "workspace:^",
|
||||
"@backstage/plugin-permission-common": "workspace:^",
|
||||
"@backstage/plugin-permission-node": "workspace:^",
|
||||
"@backstage/plugin-proxy-backend": "workspace:^",
|
||||
|
||||
@@ -18,10 +18,8 @@ import { createBackend } from '@backstage/backend-defaults';
|
||||
import { appPlugin } from '@backstage/plugin-app-backend/alpha';
|
||||
import { catalogPlugin } from '@backstage/plugin-catalog-backend/alpha';
|
||||
import { kubernetesPlugin } from '@backstage/plugin-kubernetes-backend/alpha';
|
||||
import {
|
||||
permissionModuleAllowAllPolicy,
|
||||
permissionPlugin,
|
||||
} from '@backstage/plugin-permission-backend/alpha';
|
||||
import { permissionPlugin } from '@backstage/plugin-permission-backend/alpha';
|
||||
import { permissionModuleAllowAllPolicy } from '@backstage/plugin-permission-backend-module-allow-all-policy';
|
||||
import { scaffolderPlugin } from '@backstage/plugin-scaffolder-backend/alpha';
|
||||
import { catalogModuleTemplateKind } from '@backstage/plugin-scaffolder-backend/alpha';
|
||||
import { searchModuleCatalogCollator } from '@backstage/plugin-search-backend-module-catalog/alpha';
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
module.exports = require('@backstage/cli/config/eslint-factory')(__dirname);
|
||||
@@ -0,0 +1,5 @@
|
||||
# @backstage/plugin-permission-backend-module-allow-all-policy
|
||||
|
||||
The allow all policy backend module for the permission plugin.
|
||||
|
||||
_This plugin was created through the Backstage CLI_
|
||||
@@ -0,0 +1,10 @@
|
||||
## API Report File for "@backstage/plugin-permission-backend-module-allow-all-policy"
|
||||
|
||||
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
||||
|
||||
```ts
|
||||
import { BackendFeature } from '@backstage/backend-plugin-api';
|
||||
|
||||
// @public
|
||||
export const permissionModuleAllowAllPolicy: () => BackendFeature;
|
||||
```
|
||||
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"name": "@backstage/plugin-permission-backend-module-allow-all-policy",
|
||||
"description": "Allow all policy backend module for the permission plugin.",
|
||||
"version": "0.0.0",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
"license": "Apache-2.0",
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"main": "dist/index.cjs.js",
|
||||
"types": "dist/index.d.ts"
|
||||
},
|
||||
"backstage": {
|
||||
"role": "backend-plugin-module"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "backstage-cli package start",
|
||||
"build": "backstage-cli package build",
|
||||
"lint": "backstage-cli package lint",
|
||||
"test": "backstage-cli package test",
|
||||
"clean": "backstage-cli package clean",
|
||||
"prepack": "backstage-cli package prepack",
|
||||
"postpack": "backstage-cli package postpack"
|
||||
},
|
||||
"dependencies": {
|
||||
"@backstage/backend-common": "workspace:^",
|
||||
"@backstage/backend-plugin-api": "workspace:^",
|
||||
"@backstage/plugin-auth-node": "workspace:^",
|
||||
"@backstage/plugin-permission-common": "workspace:^",
|
||||
"@backstage/plugin-permission-node": "workspace:^"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@backstage/backend-test-utils": "workspace:^",
|
||||
"@backstage/cli": "workspace:^"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright 2023 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The allow all policy backend module for the permission plugin.
|
||||
*
|
||||
* @packageDocumentation
|
||||
*/
|
||||
|
||||
export { permissionModuleAllowAllPolicy } from './module';
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2023 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { createBackendModule } from '@backstage/backend-plugin-api';
|
||||
import { policyExtensionPoint } from '@backstage/plugin-permission-node/alpha';
|
||||
import { AllowAllPermissionPolicy } from './policy';
|
||||
|
||||
/**
|
||||
* A permission policy module that allows all requests.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const permissionModuleAllowAllPolicy = createBackendModule({
|
||||
moduleId: 'allowAllPolicy',
|
||||
pluginId: 'permission',
|
||||
register(reg) {
|
||||
reg.registerInit({
|
||||
deps: { policy: policyExtensionPoint },
|
||||
async init({ policy }) {
|
||||
policy.setPolicy(new AllowAllPermissionPolicy());
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2023 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { BackstageIdentityResponse } from '@backstage/plugin-auth-node';
|
||||
import {
|
||||
AuthorizeResult,
|
||||
PolicyDecision,
|
||||
} from '@backstage/plugin-permission-common';
|
||||
import {
|
||||
PermissionPolicy,
|
||||
PolicyQuery,
|
||||
} from '@backstage/plugin-permission-node';
|
||||
|
||||
export class AllowAllPermissionPolicy implements PermissionPolicy {
|
||||
async handle(
|
||||
_request: PolicyQuery,
|
||||
_user?: BackstageIdentityResponse,
|
||||
): Promise<PolicyDecision> {
|
||||
return {
|
||||
result: AuthorizeResult.ALLOW,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -5,9 +5,6 @@
|
||||
```ts
|
||||
import { BackendFeature } from '@backstage/backend-plugin-api';
|
||||
|
||||
// @alpha
|
||||
export const permissionModuleAllowAllPolicy: () => BackendFeature;
|
||||
|
||||
// @alpha
|
||||
export const permissionPlugin: () => BackendFeature;
|
||||
|
||||
|
||||
@@ -14,4 +14,4 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export { permissionPlugin, permissionModuleAllowAllPolicy } from './plugin';
|
||||
export { permissionPlugin } from './plugin';
|
||||
|
||||
@@ -17,18 +17,9 @@
|
||||
import { loggerToWinstonLogger } from '@backstage/backend-common';
|
||||
import {
|
||||
coreServices,
|
||||
createBackendModule,
|
||||
createBackendPlugin,
|
||||
} from '@backstage/backend-plugin-api';
|
||||
import { BackstageIdentityResponse } from '@backstage/plugin-auth-node';
|
||||
import {
|
||||
AuthorizeResult,
|
||||
PolicyDecision,
|
||||
} from '@backstage/plugin-permission-common';
|
||||
import {
|
||||
PermissionPolicy,
|
||||
PolicyQuery,
|
||||
} from '@backstage/plugin-permission-node';
|
||||
import { PermissionPolicy } from '@backstage/plugin-permission-node';
|
||||
import {
|
||||
policyExtensionPoint,
|
||||
PolicyExtensionPoint,
|
||||
@@ -46,35 +37,6 @@ class PolicyExtensionPointImpl implements PolicyExtensionPoint {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A permission policy module that allows all requests.
|
||||
*
|
||||
* @alpha
|
||||
*/
|
||||
export const permissionModuleAllowAllPolicy = createBackendModule({
|
||||
moduleId: 'allowAllPolicy',
|
||||
pluginId: 'permission',
|
||||
register(reg) {
|
||||
class AllowAllPermissionPolicy implements PermissionPolicy {
|
||||
async handle(
|
||||
_request: PolicyQuery,
|
||||
_user?: BackstageIdentityResponse,
|
||||
): Promise<PolicyDecision> {
|
||||
return {
|
||||
result: AuthorizeResult.ALLOW,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
reg.registerInit({
|
||||
deps: { policy: policyExtensionPoint },
|
||||
async init({ policy }) {
|
||||
policy.setPolicy(new AllowAllPermissionPolicy());
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* Permission plugin
|
||||
*
|
||||
@@ -99,7 +61,7 @@ export const permissionPlugin = createBackendPlugin({
|
||||
const winstonLogger = loggerToWinstonLogger(logger);
|
||||
if (!policies.policy) {
|
||||
throw new Error(
|
||||
'No policy module installed! Please install a policy module. If you want to allow all requests, use permissionModuleAllowAllPolicy',
|
||||
'No policy module installed! Please install a policy module. If you want to allow all requests, use @backstage/plugin-permission-backend-module-allow-all-policy permissionModuleAllowAllPolicy',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -8166,6 +8166,20 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@backstage/plugin-permission-backend-module-allow-all-policy@workspace:^, @backstage/plugin-permission-backend-module-allow-all-policy@workspace:plugins/permission-backend-module-policy-allow-all":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@backstage/plugin-permission-backend-module-allow-all-policy@workspace:plugins/permission-backend-module-policy-allow-all"
|
||||
dependencies:
|
||||
"@backstage/backend-common": "workspace:^"
|
||||
"@backstage/backend-plugin-api": "workspace:^"
|
||||
"@backstage/backend-test-utils": "workspace:^"
|
||||
"@backstage/cli": "workspace:^"
|
||||
"@backstage/plugin-auth-node": "workspace:^"
|
||||
"@backstage/plugin-permission-common": "workspace:^"
|
||||
"@backstage/plugin-permission-node": "workspace:^"
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@backstage/plugin-permission-backend@workspace:^, @backstage/plugin-permission-backend@workspace:plugins/permission-backend":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@backstage/plugin-permission-backend@workspace:plugins/permission-backend"
|
||||
@@ -25770,6 +25784,7 @@ __metadata:
|
||||
"@backstage/plugin-lighthouse-backend": "workspace:^"
|
||||
"@backstage/plugin-linguist-backend": "workspace:^"
|
||||
"@backstage/plugin-permission-backend": "workspace:^"
|
||||
"@backstage/plugin-permission-backend-module-allow-all-policy": "workspace:^"
|
||||
"@backstage/plugin-permission-common": "workspace:^"
|
||||
"@backstage/plugin-permission-node": "workspace:^"
|
||||
"@backstage/plugin-proxy-backend": "workspace:^"
|
||||
|
||||
Reference in New Issue
Block a user