permissions: rename permissionIntegrations to permissionsRegistry
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
+10
-10
@@ -1,15 +1,15 @@
|
||||
---
|
||||
id: permissions
|
||||
title: Permission Integrations Service
|
||||
sidebar_label: Permission Integrations
|
||||
description: Documentation for the Permission Integrations service
|
||||
title: Permissions Registry Service
|
||||
sidebar_label: Permissions Registry
|
||||
description: Documentation for the Permissions Registry service
|
||||
---
|
||||
|
||||
This service allows your plugins to register new permissions, rules, and resource types and integrate with [the permissions framework](../../permissions/overview.md).
|
||||
|
||||
## Using the service
|
||||
|
||||
For a deep dive into how to use the `permissionIntegrations` service, see the [permission guide for plugin authors](../../permissions/plugin-authors/01-setup.md).
|
||||
For a deep dive into how to use the `permissionsRegistry` service, see the [permission guide for plugin authors](../../permissions/plugin-authors/01-setup.md).
|
||||
|
||||
If all you want to do is add new custom permission rules to an existing plugin, you can instead refer to the [custom permission rules guide](../../permissions/custom-rules.md).
|
||||
|
||||
@@ -38,7 +38,7 @@ export async function createRouter() {
|
||||
}
|
||||
```
|
||||
|
||||
Next, add a dependency on the `PermissionIntegrationsService` to your plugin,
|
||||
Next, add a dependency on the `PermissionsRegistryService` to your plugin,
|
||||
and pass it the same options:
|
||||
|
||||
```ts
|
||||
@@ -49,16 +49,16 @@ export const examplePlugin = createBackendPlugin({
|
||||
deps: {
|
||||
logger: coreServices.logger,
|
||||
/* highlight-add-next-line */
|
||||
permissionIntegrations: coreServices.permissionIntegrations,
|
||||
permissionsRegistry: coreServices.permissionsRegistry,
|
||||
},
|
||||
/* highlight-remove-next-line */
|
||||
async init({ logger }) {
|
||||
/* highlight-add-next-line */
|
||||
async init({ logger, permissionIntegrations }) {
|
||||
async init({ logger, permissionsRegistry }) {
|
||||
logger.log('This is a silly example plugin with no functionality');
|
||||
|
||||
/* highlight-add-start */
|
||||
permissionIntegrations.addResourceType({
|
||||
permissionsRegistry.addResourceType({
|
||||
resourceType: RESOURCE_TYPE_MY_RESOURCE,
|
||||
permissions: [myResourcePermissions],
|
||||
rules: [myResourceRule],
|
||||
@@ -72,9 +72,9 @@ export const examplePlugin = createBackendPlugin({
|
||||
|
||||
If you only passed the `permissions` option to
|
||||
`createPermissionIntegrationRouter`, you will want to use
|
||||
`permissionIntegrations.addPermissions` instead.
|
||||
`permissionsRegistry.addPermissions` instead.
|
||||
|
||||
If you passed multiple resources types to `createPermissionIntegrationRouter`
|
||||
via the `resources` option, you will want to call
|
||||
`permissionIntegrations.addResourceType` multiple times for each of those
|
||||
`permissionsRegistry.addResourceType` multiple times for each of those
|
||||
resource types.
|
||||
@@ -141,11 +141,11 @@ Now that we have a custom rule defined and added to our policy, we need provide
|
||||
|
||||
:::warning Warning
|
||||
|
||||
The `PermissionIntegrationsService` is a fairly new addition and not yet supported by all plugins as they might still be using the old `createPermissionIntegrationRouter` that cannot be extended. If you encounter errors when installing custom rules for a plugin, the plugin may need to be switched to using the `PermissionIntegrationsService` first.
|
||||
The `PermissionsRegistryService` is a fairly new addition and not yet supported by all plugins as they might still be using the old `createPermissionIntegrationRouter` that cannot be extended. If you encounter errors when installing custom rules for a plugin, the plugin may need to be switched to using the `PermissionsRegistryService` first.
|
||||
|
||||
:::
|
||||
|
||||
To install custom rules in a plugin, we need to use the [`PermissionIntegrationsService`](../backend-system/core-services/permissionIntegrations.md). Here's the steps you'll need to take to add the `isInSystemRule` we created above to the catalog:
|
||||
To install custom rules in a plugin, we need to use the [`PermissionsRegistryService`](../backend-system/core-services/permissionsRegistry.md). Here's the steps you'll need to take to add the `isInSystemRule` we created above to the catalog:
|
||||
|
||||
1. We will be using the `@backstage/plugin-catalog-node` package as it contains the extension point we need. Run this to add it:
|
||||
|
||||
@@ -166,9 +166,9 @@ To install custom rules in a plugin, we need to use the [`PermissionIntegrations
|
||||
moduleId: 'permission-rules',
|
||||
register(reg) {
|
||||
reg.registerInit({
|
||||
deps: { permissionIntegrations: coreServices.permissionIntegrations },
|
||||
async init({ permissionIntegrations }) {
|
||||
permissionIntegrations.addPermissionRules([isInSystemRule]);
|
||||
deps: { permissionsRegistry: coreServices.permissionsRegistry },
|
||||
async init({ permissionsRegistry }) {
|
||||
permissionsRegistry.addPermissionRules([isInSystemRule]);
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
@@ -145,14 +145,14 @@ export const exampleTodoListPlugin = createBackendPlugin({
|
||||
/* highlight-add-next-line */
|
||||
permissions: coreServices.permissions,
|
||||
/* highlight-add-next-line */
|
||||
permissionIntegrations: coreServices.permissionIntegrations,
|
||||
permissionsRegistry: coreServices.permissionsRegistry,
|
||||
},
|
||||
/* highlight-remove-next-line */
|
||||
async init({ logger, httpAuth, httpRouter }) {
|
||||
/* highlight-add-next-line */
|
||||
async init({ httpAuth, logger, httpRouter, permissions, permissionIntegrations }) {
|
||||
async init({ httpAuth, logger, httpRouter, permissions, permissionsRegistry }) {
|
||||
/* highlight-add-next-line */
|
||||
permissionIntegrations.addPermissions([todoListCreatePermission]);
|
||||
permissionsRegistry.addPermissions([todoListCreatePermission]);
|
||||
|
||||
httpRouter.use(
|
||||
await createRouter({
|
||||
|
||||
@@ -62,9 +62,9 @@ import {
|
||||
// ...
|
||||
|
||||
/* highlight-remove-next-line */
|
||||
permissionIntegrations.addPermissions([todoListCreatePermission]);
|
||||
permissionsRegistry.addPermissions([todoListCreatePermission]);
|
||||
/* highlight-add-start */
|
||||
permissionIntegrations.addPermissions([
|
||||
permissionsRegistry.addPermissions([
|
||||
todoListCreatePermission,
|
||||
todoListUpdatePermission,
|
||||
]);
|
||||
@@ -171,7 +171,7 @@ Specifically, the `apply` function is used to understand whether the passed reso
|
||||
Let's skip the `toQuery` function for now, we'll come back to that in the next section.
|
||||
|
||||
Now, let's add the new resource type to the permissions system via the
|
||||
`PermissionIntegrationsService`. You'll need to supply:
|
||||
`PermissionsRegistryService`. You'll need to supply:
|
||||
|
||||
- `getResources`: a function that accepts an array of `resourceRefs` in the same format you expect to be passed to `authorize`, and returns an array of the corresponding resources.
|
||||
- `resourceType`: the same value used in the permission rule above.
|
||||
@@ -199,13 +199,13 @@ import { rules } from './rules';
|
||||
// ...
|
||||
|
||||
/* highlight-remove-start */
|
||||
permissionIntegrations.addPermissions([
|
||||
permissionsRegistry.addPermissions([
|
||||
todoListCreatePermission,
|
||||
todoListUpdatePermission,
|
||||
]);
|
||||
/* highlight-remove-end */
|
||||
/* highlight-add-start */
|
||||
permissionIntegrations.addResourceType({
|
||||
permissionsRegistry.addResourceType({
|
||||
resourceType: TODO_LIST_RESOURCE_TYPE,
|
||||
permissions: [todoListCreatePermission, todoListUpdatePermission],
|
||||
rules: Object.values(rules),
|
||||
|
||||
@@ -97,7 +97,7 @@ import {
|
||||
|
||||
// ...
|
||||
|
||||
permissionIntegrations.addResourceType({
|
||||
permissionsRegistry.addResourceType({
|
||||
resourceType: TODO_LIST_RESOURCE_TYPE,
|
||||
/* highlight-remove-next-line */
|
||||
permissions: [todoListCreatePermission, todoListUpdatePermission],
|
||||
|
||||
Reference in New Issue
Block a user