Skip to main content

管理员面板的 RBAC 系统已更新

🌐 The admin panel RBAC system has been updated

在 Strapi 5 中,content-manager_rbacManager,这是 Strapi 管理面板的 redux 存储的一部分,被移除了,取而代之的是使用常规权限系统。此外,useRBAC 钩子也已更新。

🌐 In Strapi 5, the content-manager_rbacManager, which is a section of Strapi's redux store for the admin panel, is removed and the regular permissions system is used instead. Additionally, the useRBAC hook is updated.

此页面是重大更改数据库的一部分,提供关于重大更改的信息以及从 Strapi v4 迁移到 Strapi 5 的附加说明。

🌐 This page is part of the breaking changes database and provides information about the breaking change and additional instructions to migrate from Strapi v4 to Strapi 5.

 Is this breaking change affecting plugins?Yes
 Is this breaking change automatically handled by a codemod?No

重大变更描述

🌐 Breaking change description

在 Strapi v4 中

权限是通过 redux 存储的 content-manager_rbacManager 部分处理的,就像以下通用示例一样:

🌐 Permissions are handled with the content-manager_rbacManager section of the redux store, like in the following generic example:

const cmPermissions useSelector(state => state['content-manager_rbacManager'])
const { allowedActions } = useRBAC({
main: [{ action: 'admin::something.main', subject: null }]
})

const canMain = allowedActions.canMain

在 Strapi 5 中

content-manager_rbacManager 已被移除,改为使用常规权限系统,这意味着 useRBAC 钩子的使用方式有所不同,如以下通用示例所示:

const { allowedActions } = useRBAC([
{ action: 'admin::something.main', subject: null }
])

const canMain = allowedActions.canMain

迁移

🌐 Migration

本节重新组合了有关引入的重大更改的有用说明和程序。

🌐 This section regroups useful notes and procedures about the introduced breaking change.

注意

🌐 Notes

手动迁移

🌐 Manual migration

如果确实需要,仍在使用该函数的插件开发者应将其用法替换为真正的模板库。

🌐 Plugin developers that are hooking into the redux store to tweak RBAC permissions in Strapi v4 need to update their code according to the described changes.