管理面板 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.
\🔌 此重大更改是否会影响插件? | \是 |
---|
\🤖 此重大更改是否由 codemod 自动处理? | \否 |
---|
重大更改描述
¥Breaking change description
在 Strapi v4 中
¥In 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 中
¥In Strapi 5
content-manager_rbacManager
被删除,取而代之的是使用常规权限系统,这意味着 useRBAC
钩子的使用方式不同,如以下通用示例所示:
¥content-manager_rbacManager
is removed and the regular permissions system is used instead, which implies the useRBAC
hook is used differently, as in the following generic example:
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
新的 RBAC API 可用,用户可以利用中间件系统与调用进行交互(参见 贡献者文档)。
¥A new RBAC API is available and users can utilise a middleware system to interact with calls (see contributors documentation).
有关更多信息,请参阅贡献者文档的 获取权限 和 验证 部分。
¥Additional information can be found in the Contributors Documentation, in the Fetching permissions and Authentication sections.
手动迁移
¥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.