Azure AD SAML 设置(Azure AD SAML setup)#
本文件提供了配置 Azure AD 以通过 SAML 属性向 n8n 发送角色信息的说明。这使得可以根据 Azure AD 群组成员资格自动分配角色。
🌐 This document provides instructions for configuring Azure AD to send role information to n8n via SAML attributes. This enables automatic role assignment based on Azure AD group membership.
先决条件(Prerequisites)#
你需要一个具有访问企业应用权限的 Azure AD 账户,以及来自 n8n 的 SAML 设置的重定向 URL 和实体 ID。
🌐 You need an Azure AD account with access to Enterprise Applications, and the redirect URL and entity ID from n8n's SAML settings.
请先阅读 设置 SAML 指南。
🌐 Read the Set up SAML guide first.
n8n 所需的(What n8n requires)#
n8n 期望在 SAML 声明中包含自定义 SAML 属性:
🌐 n8n expects a custom SAML attribute to be included in the SAML assertion:
| 属性名称 | 数据类型 | 用途 |
|---|---|---|
| n8n_instance_role | 字符串 | 控制用户在 n8n 中的全局角色 |
n8n_instance_role 的有效值:
🌐 Valid values for n8n_instance_role:
| 值 | 描述 |
|---|---|
global:owner |
完整实例所有者访问权限 |
global:admin |
管理员访问权限 |
global:member |
普通成员访问权限(如果未指定,则默认) |
global:chatUser |
n8n 中的受限非技术角色,设计用于通过 Chat Hub 界面安全地与 AI 代理交互 |
设置(Setup)#
步骤 1:配置标准 SAML 属性
- 在你的 Azure AD 门户中,导航到你的 n8n 企业应用。
- 转到 单点登录 > 属性和声明。
-
确保配置了这些标准属性:
声明名称 来源属性 http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddressuser.mail http://schemas.xmlsoap.org/ws/2005/05/identity/claims/firstnameuser.givenname http://schemas.xmlsoap.org/ws/2005/05/identity/claims/lastnameuser.surname http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upnuser.userprincipalname
步骤 2:添加 n8n_instance_role 权限声明
此声明使用条件逻辑根据 Azure AD 组成员身份发出不同的角色值。
🌐 This claim uses conditional logic to emit different role values based on Azure AD group membership.
- 在 属性和声明 中,点击 添加新的声明。
- 配置基本设置:
- 名称:
n8n_instance_role - 命名空间:留空
- 来源:
Attribute
- 名称:
- 展开 索赔条件 并点击 添加条件。
-
为每个 Azure AD 组添加条件(按优先顺序):
用户类型 范围组 来源 值 成员 n8n-chatusers 属性 global:chatUser成员 n8n-users 属性 global:member成员 n8n-admins 属性 global:admin成员 n8n-owners 属性 global:owner
条件顺序
条件按顺序进行评估。把最有特权的群体(所有者)放在最后。
- 点击 保存。
测试配置(Testing the configuration)#
- 在 n8n 中,前往 设置 > 单点登录 (SSO)。
- 将 角色分配 设置为 通过 SSO 的实例角色。
- 将 角色映射方法 设置为 在你的身份提供商上映射规则。
- 点击 测试设置。
- 验证 SAML 响应显示正确的
n8n_instance_role值。
故障排除(Troubleshooting)#
声明未出现在 SAML 响应中
- 验证用户是否是至少一个已配置组的成员。
- 检查这些组是否已分配到企业应用。
- 确保条件已配置
Attribute作为来源。 - 使用类似 'SAML Chrome Panel' 的浏览器扩展插件来查看应用的 SAML 响应。
用户获得错误角色
- 检查条件顺序(最优先的组应放在最后)。