Skip to content

Commit 8f8133f

Browse files
authored
docs(rbac): add documentation for api and known permissions (#1000)
1 parent 63590cc commit 8f8133f

File tree

3 files changed

+492
-10
lines changed

3 files changed

+492
-10
lines changed

plugins/rbac-backend/README.md

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@ To effectively utilize the RBAC plugin, you must have the Backstage permission f
1616

1717
You need to [set up the permission framework in Backstage](https://backstage.io/docs/permissions/getting-started/).Since this plugin provides a dynamic policy that replaces the traditional one, there's no need to create a policy manually. Please note that one of the requirements for permission framework is enabling the [service-to-service authentication](https://backstage.io/docs/auth/service-to-service-auth/#setup). Ensure that you complete these authentication setup steps as well.
1818

19-
Note: Red Hat Developer Hub users enjoy the benefit of Permission Framework and backend-to-backend authentication being enabled by default
20-
2119
### Configuring the Backend
2220

2321
To connect the RBAC framework to your backend use the `PolicyBuilder` class in your backend permissions plugin (typically `packages/backend/src/plugins/permissions.ts`) as follows:
2422

2523
```ts
24+
/* highlight-add-start */
2625
import { Router } from 'express';
2726

2827
import {
@@ -48,18 +47,32 @@ export default async function createPlugin(
4847
pluginIdProvider,
4948
);
5049
}
50+
/* highlight-add-end */
5151
```
5252

5353
Secondly, in your backend router (typically `packages/backend/src/index.ts`) add a route for `/permission` specifying the list of plugin id's that support permissions:
5454

5555
```ts
56-
apiRouter.use(
57-
'/permission',
58-
await permission(permissionEnv, {
59-
// return list static plugin which supports Backstage permissions.
60-
getPluginIds: () => ['catalog', 'scaffolder', 'permission'],
61-
}),
62-
);
56+
// ...
57+
/* highlight-add-next-line */
58+
import permission from './plugins/permissions';
59+
60+
async function main() {
61+
// ...
62+
/* highlight-add-next-line */
63+
const permissionEnv = useHotMemoize(module, () => createEnv('permission'));
64+
65+
// ...
66+
/* highlight-add-start */
67+
apiRouter.use(
68+
'/permission',
69+
await permission(permissionEnv, {
70+
// return list static plugin which supports Backstage permissions.
71+
getPluginIds: () => ['catalog', 'scaffolder', 'permission'],
72+
}),
73+
);
74+
/* highlight-add-end */
75+
}
6376
```
6477

6578
### Identity resolver
@@ -96,6 +109,8 @@ permission:
96109
- name: group:default/admins
97110
```
98111
112+
For more information on the available API endpoints, refer to the [API documentation](./docs/apis.md).
113+
99114
### Configuring policies via file
100115
101116
The RBAC plugin also allows you to import policies from an external file. These policies are defined in the [Casbin rules format](https://casbin.org/docs/category/the-basics), known for its simplicity and clarity. For a quick start, please refer to the format details in the provided link.
@@ -104,7 +119,7 @@ Here's an example of an external permission policies configuration file named `r
104119

105120
```CSV
106121
p, role:default/team_a, catalog-entity, read, deny
107-
p, role:default/team_b, catalog.entity.create, use, deny
122+
p, role:default/team_b, catalog.entity.create, create, deny
108123
109124
g, user:default/bob, role:default/team_a
110125
@@ -128,6 +143,8 @@ permission:
128143
policies-csv-file: /some/path/rbac-policy.csv
129144
```
130145

146+
For more information on the available permissions within Showcase and RHDH, refer to the [permissions documentation](./docs/permissions.md).
147+
131148
### Configuring Database Storage for policies
132149

133150
The RBAC plugin offers the option to store policies in a database. It supports two database storage options:

0 commit comments

Comments
 (0)