Skip to content

Commit

Permalink
feat(rbac): turn rbac plugin into a dynamic plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
ciiay committed Jan 26, 2024
1 parent 1c4c54d commit e152da2
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 5 deletions.
10 changes: 8 additions & 2 deletions plugins/rbac-backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,15 @@ The permission framework, and consequently, this RBAC plugin, rely on the concep

## Installation

To integrate the RBAC plugin into your Backstage instance, follow these steps.
The RBAC backend plugin can be integrated into your Backstage instance either as a static or a dynamic plugin. In any case, do not miss the info about configuration as described below.

### Installing the plugin
### Installing as a dynamic plugin

To install it as a dynamic plugin, please follow instructions here: https://github.com/janus-idp/backstage-showcase/blob/main/showcase-docs/dynamic-plugins.md#installing-a-dynamic-plugin-package-in-the-showcase

To install it as a static plugin, several steps are required as described below.

### Installing as a static plugin

Add the RBAC plugin packages as dependencies by running the following command.

Expand Down
10 changes: 8 additions & 2 deletions plugins/rbac-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
"test": "backstage-cli package test --passWithNoTests --coverage",
"clean": "backstage-cli package clean",
"prepack": "backstage-cli package prepack",
"postpack": "backstage-cli package postpack"
"postpack": "backstage-cli package postpack",
"export-dynamic": "janus-cli package export-dynamic-plugin"
},
"dependencies": {
"@backstage/backend-common": "^0.19.8",
"@backstage/backend-dynamic-feature-service": "0.1.0",
"@backstage/backend-plugin-api": "^0.5.4",
"@backstage/catalog-client": "^1.4.5",
"@backstage/catalog-model": "^1.4.3",
Expand Down Expand Up @@ -51,6 +53,7 @@
"@types/express": "4.17.20",
"@types/node": "18.18.5",
"@types/supertest": "2.0.16",
"@janus-idp/cli": "^1.4.7",
"knex-mock-client": "2.0.0",
"msw": "1.3.2",
"supertest": "6.3.3"
Expand All @@ -59,7 +62,10 @@
"dist",
"config.d.ts",
"model",
"migrations"
"migrations",
"dist-dynamic/*.*",
"dist-dynamic/dist/**",
"dist-dynamic/alpha/*"
],
"repository": "github:janus-idp/backstage-plugins",
"keywords": [
Expand Down
17 changes: 17 additions & 0 deletions plugins/rbac-backend/src/dynamic/alpha.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { createBackendModule } from '@backstage/backend-plugin-api';
import { BackendDynamicPluginInstaller } from '@backstage/backend-plugin-manager';

export const dynamicPluginInstaller: BackendDynamicPluginInstaller = {
kind: 'new',

install: createBackendModule({
moduleId: 'catalog-backend-module-rbac',
pluginId: 'catalog',
register(env) {
env.registerInit({
deps: {},
async init() {},
});
},
}),
};
12 changes: 12 additions & 0 deletions plugins/rbac-backend/src/dynamic/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { BackendDynamicPluginInstaller } from '@backstage/backend-dynamic-feature-service';

import { createRouter } from '../service/router';

export const dynamicPluginInstaller: BackendDynamicPluginInstaller = {
kind: 'legacy',

router: {
pluginID: 'rbac',
createPlugin: createRouter,
},
};
2 changes: 2 additions & 0 deletions plugins/rbac-backend/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
export * from './service/router';
export * from './service/policy-builder';

export * from './dynamic';
7 changes: 7 additions & 0 deletions plugins/rbac/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ The RBAC UI plugin offers a streamlined user interface for effectively managing

### Installation

#### Installing as a dynamic plugin?

The sections below are relevant for static plugins. If the plugin is expected to be installed as a dynamic one:

- follow https://github.com/janus-idp/backstage-showcase/blob/main/showcase-docs/dynamic-plugins.md#installing-a-dynamic-plugin-package-in-the-showcase
- add content of `app-config.janus-idp.yaml` into `app-config.local.yaml`.

#### Prerequisites

Follow the RBAC backend plugin [README](https://github.com/janus-idp/backstage-plugins/tree/main/plugins/rbac-backend) to integrate rbac in your Backstage instance
Expand Down
14 changes: 14 additions & 0 deletions plugins/rbac/app-config.janus-idp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
dynamicPlugins:
frontend:
janus-idp.backstage-plugin-rbac:
appIcons:
- name: AdminPanelSettingsOutlinedIcon
module: RbacPlugin
importName: AdminPanelSettingsOutlinedIcon
dynamicRoutes:
- path: /rbac
importName: RbacPage
module: RbacPlugin
menuItem:
icon: AdminPanelSettingsOutlinedIcon
text: Administration
9 changes: 8 additions & 1 deletion plugins/rbac/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,16 @@
"@types/node": "18.18.5",
"msw": "1.3.2"
},
"scalprum": {
"name": "janus-idp.backstage-plugin-rbac",
"exposedModules": {
"RbacPlugin": "./src/index.ts"
}
},
"files": [
"dist",
"dist-scalprum"
"dist-scalprum",
"app-config.janus-idp.yaml"
],
"repository": "github:janus-idp/backstage-plugins",
"keywords": [
Expand Down
2 changes: 2 additions & 0 deletions plugins/rbac/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export { rbacPlugin, RbacPage, Administration } from './plugin';

export { default as AdminPanelSettingsOutlinedIcon } from '@mui/icons-material/AdminPanelSettingsOutlined';

0 comments on commit e152da2

Please sign in to comment.