expose the permission plugin using the new backend system

Signed-off-by: eipc16 <pprzemek.312@gmail.com>
This commit is contained in:
eipc16
2023-04-03 20:36:35 +02:00
parent 16f532678f
commit 84946a580c
9 changed files with 174 additions and 0 deletions
@@ -0,0 +1,20 @@
## API Report File for "@backstage/plugin-permission-backend"
> 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';
import { PermissionPolicy } from '@backstage/plugin-permission-node';
// @alpha
export const permissionPlugin: (
options: PermissionPluginOptions,
) => BackendFeature;
// @alpha
export type PermissionPluginOptions = {
policy: PermissionPolicy;
};
// (No @packageDocumentation comment for this package)
```
+16
View File
@@ -9,6 +9,21 @@
"main": "dist/index.cjs.js",
"types": "dist/index.d.ts"
},
"exports": {
".": "./src/index.ts",
"./alpha": "./src/alpha.ts",
"./package.json": "./package.json"
},
"typesVersions": {
"*": {
"alpha": [
"src/alpha.ts"
],
"package.json": [
"package.json"
]
}
},
"backstage": {
"role": "backend-plugin"
},
@@ -23,6 +38,7 @@
},
"dependencies": {
"@backstage/backend-common": "workspace:^",
"@backstage/backend-plugin-api": "workspace:^",
"@backstage/config": "workspace:^",
"@backstage/errors": "workspace:^",
"@backstage/plugin-auth-node": "workspace:^",
+17
View File
@@ -0,0 +1,17 @@
/*
* Copyright 2020 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.
*/
export { permissionPlugin, type PermissionPluginOptions } from './plugin';
+66
View File
@@ -0,0 +1,66 @@
/*
* Copyright 2021 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 { loggerToWinstonLogger } from '@backstage/backend-common';
import {
coreServices,
createBackendPlugin,
} from '@backstage/backend-plugin-api';
import { PermissionPolicy } from '@backstage/plugin-permission-node';
import { createRouter } from './service';
/**
* Permission plugin options
*
* @alpha
*/
export type PermissionPluginOptions = {
policy: PermissionPolicy;
};
/**
* Permission plugin
*
* @alpha
*/
export const permissionPlugin = createBackendPlugin(
(options: PermissionPluginOptions) => ({
pluginId: 'permission',
register(env) {
env.registerInit({
deps: {
http: coreServices.httpRouter,
config: coreServices.config,
logger: coreServices.logger,
discovery: coreServices.discovery,
identity: coreServices.identity,
},
async init({ http, config, logger, discovery, identity }) {
const winstonLogger = loggerToWinstonLogger(logger);
http.use(
await createRouter({
config,
discovery,
identity,
logger: winstonLogger,
policy: options.policy,
}),
);
},
});
},
}),
);