设置 SAML(Set up SAML)#
Feature availability
- Available on Business and Enterprise plans.
- You need to be an instance owner or admin to enable and configure SAML.
启用 SAML(Enable SAML)#
- 在 n8n 中,前往 设置 > 单点登录 (SSO)。
- 记下 n8n 的 重定向 URL 和 实体 ID。
- 可选:如果你的身份提供商允许你通过导入的元数据设置 SAML,请导航到 实体 ID URL 并保存 XML。
- 可选:如果你在负载均衡器后运行 n8n,请确保已配置
N8N_EDITOR_BASE_URL。
- 使用你的身份提供商(IdP)设置 SAML。你需要 重定向 URL 和 实体 ID。你可能还需要 IdP 用户的电子邮件地址和名称。
- 在你的身份提供商(IdP)完成设置后,将元数据 XML 加载到 n8n 中。你可以使用元数据 URL 或原始 XML:
- 元数据 URL:将你的 IdP 的元数据 URL 复制到 n8n 中的 身份提供商设置 字段。
- 原始 XML:从你的身份提供商 (IdP) 下载元数据 XML,将 身份提供商设置 切换为 XML,然后将原始 XML 复制到 身份提供商设置 中。
- 选择 保存设置。
- 选择 测试设置 来检查你的 SAML 设置是否正常工作。
- 将 SAML 2.0 设置为 已激活。
SAML 请求类型
n8n 不支持 POST 绑定。请将您的 IdP 配置为使用 HTTP 请求绑定。
通用身份提供商 (IdP) 设置(Generic IdP setup)#
配置身份提供者(IdP)的步骤取决于你选择的身份提供者。以下是一些常见的设置任务:
🌐 The steps to configure the IdP vary depending on your chosen IdP. These are some common setup tasks:
- 在你的身份提供商 (IdP) 中为 n8n 创建应用。
- 将 n8n 属性映射到 IdP 属性:
| 值(IdP 端) | 名称格式 | 名称 |
|---|---|---|
| 用户邮箱 | URI 引用 | http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress |
| 用户名 | URI 引用 | http://schemas.xmlsoap.org/ws/2005/05/identity/claims/firstname |
| 用户姓氏 | URI 引用 | http://schemas.xmlsoap.org/ws/2005/05/identity/claims/lastname |
| 用户邮箱 | URI 引用 | http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn |
实例和项目访问权限配置(Instance and project access provisioning)#
从版本 1.122.2 起,n8n 支持从你的身份提供商 (IdP) 配置实例角色和项目角色。
🌐 From version 1.122.2 upwards, n8n supports provisioning the instance role and project roles from your IdP.
你需要在身份提供商 (IdP) 的组或单个用户上配置以下属性:
🌐 You need to configure these attributes on the groups or individual users in your IdP:
| 值(IdP 端) | 数据类型 | 名称 |
|---|---|---|
n8n_instance_role |
字符串 | n8n_instance_role |
n8n_projects |
数组 | n8n_projects |
在 设置 > SSO 页面上的表单中,找到标记为 用户角色配置 的下拉菜单。n8n 将此下拉菜单的默认值设置为 在 n8n 中管理。
🌐 On the form on the Settings > SSO page, located the dropdown labeled User role provisioning. n8n sets the default value of this dropdown to Managed in n8n.
你可以选择将其设置为以下值之一:
🌐 You can choose to set it to one of these values:
- 实例角色
- 每个已配置用户的实例角色仅从 SAML 响应中的
n8n_instance_role属性中读取。项目访问仍然仅在 n8n 内部管理。 - 如果你的身份提供商(IdP)上没有配置
n8n_instance_role的值,则会使用global:member角色作为备用。
- 每个已配置用户的实例角色仅从 SAML 响应中的
- 实例和项目角色
- 每个已配置用户的实例角色和项目访问权限都是从 SAML 响应中的
n8n_instance_role和n8n_projects属性读取的。
- 每个已配置用户的实例角色和项目访问权限都是从 SAML 响应中的
现有访问权限将被覆盖
一旦你启用“用户角色配置”,下次任何用户通过 SAML 登录时,其在 n8n 内获得的、未反映在 n8n_instance_role 和 n8n_projects 中的任何访问权限都将从该用户中移除。
在激活此功能时,你需要在保存更改之前下载两个 CSV 文件。这些文件包含你当前的所有访问设置,以便日后参考。
正在配置 n8n_instance_role 属性(Configuring n8n_instance_role attribute)#
n8n_instance_role 属性是在你的身份提供者 (IdP) 上为某个组或用户配置的字符串。
🌐 The n8n_instance_role attribute is a string configured for a group or user on your IdP.
支持的实例角色:
🌐 Supported instance roles are:
global:memberglobal:admin
正在配置 n8n_projects 属性(Configuring n8n_projects attribute)#
n8n_projects 属性是在你的身份提供商(IdP)上为某个组或用户配置的字符串数组。
🌐 The n8n_projects attribute is a string array configured for a group or user on your IdP.
这个数组中的每个元素都需要遵循这个格式:
<project-id>:<role>
🌐 Each element in this array needs to follow this format:
<project-id>:<role>
例如:
🌐 For example:
bHsykgeFirmIhezz:viewer4K3zrg3DvlMFFTB7:editordCjnYuEpYOUBVaNe:admin
对于通过身份提供商 (IdP) 启用项目访问权限配置时已有的访问设置,你可以在下载的 CSV 文件中找到项目 ID。
🌐 For existing access settings at the time of enabling project access provisioning through your IdP, you can find the project IDs in the downloaded CSV file.
从头开始创建项目时,请在浏览器中查看项目时从 URL 获取项目 ID。
🌐 When creating a project from scratch, get the project ID from the URL when viewing the project in your browser:
例如,在 URL <your-domain>/projects/VVRWZaq5DRxaf9O1/workflows 中,项目 ID 是 VVRWZaq5DRxaf9O1。
🌐 In the URL <your-domain>/projects/VVRWZaq5DRxaf9O1/workflows for example, the project ID is VVRWZaq5DRxaf9O1.
常用身份提供商 (IdP) 的设置资源(Setup resources for common IdPs)#
常用身份提供商 (IdP) 的文档链接。
🌐 Documentation links for common IdPs.
| 身份提供商 | 文档 |
|---|---|
| Auth0 | 将 Auth0 配置为 SAML 身份提供商:手动配置 SSO 集成 |
| Authentik | 应用程序 和 SAML 提供商 |
| Azure AD | 使用 Azure Active Directory 的 SAML 身份验证 |
| JumpCloud | 如何使用 JumpCloud 设置 SAML (SSO) 应用程序(以 Zoom 为例) |
| Keycloak | 根据您的托管方式选择 入门指南 |
| Okta | n8n 提供了 员工身份设置指南 以及 逐步 PDF 指南 |
| PingIdentity | PingOne SSO |