用户与权限
🌐 Users & Permissions
Page summary:
用户与权限管理终端用户账户、基于JWT的身份验证以及基于角色的API访问权限。本文档解释了如何创建角色、配置权限以及发布API令牌以实现安全访问控制。
“用户与权限”功能允许管理 Strapi 项目的终端用户 它提供基于 JSON Web Token(JWT)的完整身份验证流程来保护你的 API,并且提供访问控制列表(ACL)策略,使你能够管理用户组之间的权限。
管理面板配置
🌐 Admin panel configuration
用户和权限功能可从管理面板设置和代码库进行配置。
🌐 The Users & Permissions feature is configured from both the admin panel settings, and via the code base.
角色
🌐 Roles
用户和权限功能允许为终端用户创建和管理角色,以配置他们可以访问的内容。
🌐 The Users & Permissions feature allows to create and manage roles for end users, to configure what they can have access to.
创建新角色
🌐 Creating a new role
路径: 用户与权限插件 > 角色
在 Roles 界面的右上方,显示了一个 添加新角色 按钮。它允许为你的 Strapi 应用的终端用户创建新角色。
🌐 On the top right side of the Roles interface, an Add new role button is displayed. It allows to create a new role for end users of your Strapi application.
点击 添加新角色 按钮,将会跳转到角色编辑界面,在那里你可以为新角色命名并定义其详细信息和权限(参见 编辑角色)。
🌐 Click on the Add new role button to be redirected to the roles edition interface, where you will be able to name your new role and define its details and permissions (see Editing a role).

所有新终端用户默认分配的终端用户角色可以在用户与权限插件的高级设置子部分中定义(参见高级设置)。
🌐 The end-user role attributed by default to all new end users can be defined in the Advanced settings sub-section of Users & Permissions plugin (see Advanced settings).
编辑角色
🌐 Editing a role
路径: 用户与权限插件 > 角色
Roles 界面显示为你的 Strapi 应用的终端用户创建的所有角色。
🌐 The Roles interface displays all created roles for the end users of your Strapi application.
默认情况下,为任何 Strapi 应用定义 2 个终端用户角色:
🌐 By default, 2 end-user roles are defined for any Strapi application:
- 已认证:只有在登录前端应用的情况下,终端用户才能访问内容。
- 公共:供终端用户在未登录前端应用的情况下访问内容 。
然而,可以创建更多角色(参见创建新角色),并且所有角色都可以通过角色编辑界面进行编辑。
🌐 More roles can however be created (see Creating a new role), and all can be edited through the role edition interface.
-
点击角色的编辑按钮 进行编辑——除非你是直接从创建新角色进入角色编辑界面。
-
填写角色详情,按照下表中的说明操作: | 角色详情 | 指示 || --- | --- || 名称 | 在文本框中写下角色的新名称。 || 描述 | 在文本框中写下角色的描述。它应该帮助管理员了解该角色可以访问的内容。 |
-
通过以下方式配置终端用户角色的权限:
- 单击要配置的权限类别的名称(例如应用、内容管理器、电子邮件等)。
- 勾选要授予角色的操作和权限的框。
-
点击 保存 按钮。
当勾选某个操作或权限框时,界面右侧会显示该 API 的相关绑定路由。
🌐 When ticking an action or permission box, related bound routes of the API are displayed in the right side of the interface.

删除角色
🌐 Deleting a role
路径: 用户与权限插件 > 角色
尽管无法删除 2 个默认终端用户角色,但其他角色可以删除,只要没有终端用户仍将此角色归属于其账户即可。
🌐 Although the 2 default end-user roles cannot be deleted, the other ones can, as long as no end user still has this role attributed to their account.
- 点击角色记录右侧的删除按钮 。
- 在删除窗口,点击 确认按钮以确认删除。
提供者
🌐 Providers
路径: 用户与权限插件 > 提供者
用户和权限功能允许启用和配置提供商,以便终端用户通过第三方提供商登录,通过 Strapi 应用 API 访问前端应用的内容。
🌐 The Users & Permissions feature allows enabling and configuring providers, for end users to login via a third-party provider to access the content of a front-end application through the Strapi application API.
默认情况下,会提供一个提供者列表,其中包括“电子邮件”,它在启用用户和权限的所有 Strapi 应用中默认启用。
🌐 By default, a list of providers is available including one, "Email", enabled by default for all Strapi applications with Users & Permissions enabled.
- 点击供应商的编辑 按钮以启用并配置。
- 在提供者版本窗口中,点击启用选项的TRUE按钮。
- 填写提供商的配置。每个提供商都有自己特定的配置集(请参阅用户与权限提供商文档)。
- 点击 保存 按钮。

Strapi 默认未提供的其他服务提供商可以通过手动修改 Strapi 应用的代码来添加。点击以下任意卡片以获取有关配置或创建第三方服务提供商的更多信息:
🌐 Other providers that are not proposed by default by Strapi can be added manually through the code of your Strapi application. Click on any of the following cards to get additional information on configuring or creating third-party providers:
电子邮件模板
🌐 Email templates
路径: 用户与权限插件 > 邮件模板
“用户与权限”功能使用两个电子邮件模板,“电子邮件地址确认”和“重置密码”,这些模板会发送给终端用户:
🌐 The Users & Permissions feature uses 2 email templates, "Email address confirmation" and "Reset password", that are sent to end users:
- 如果必须确认他们的账户才能激活,
- 如果他们需要重置 Strapi 账户的密码。
两个电子邮件模板都可以修改。
🌐 Both email templates can be modified.