permissions: rename permissionIntegrations to permissionsRegistry

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2025-01-09 12:41:58 +01:00
parent dfe6e29c0c
commit cf6bd48cab
27 changed files with 92 additions and 92 deletions
+5 -5
View File
@@ -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],