Skip to content

设置 OIDC#

¥Set up OIDC

Feature availability

  • Available on Enterprise plans.
  • You need to be an instance owner or admin to enable and configure OIDC.

设置并启用 OIDC#

¥Setting up and enabling OIDC

  1. 在 n8n 中,转到“设置”>“单点登录 (SSO)”。

¥In n8n, go to Settings > SSO.

  1. 在“选择身份验证协议”下,从下拉列表中选择 OIDC。

¥Under Select Authentication Protocol, choose OIDC from the dropdown.

  1. 复制显示的重定向 URL(例如,https://yourworkspace.app.n8n.cloud/rest/sso/oidc/callback)。

¥Copy the redirect URL shown (for example, https://yourworkspace.app.n8n.cloud/rest/sso/oidc/callback).

Extra configuration for load balancers or proxies

1
If you are running n8n behind a load balancer, make sure you set the [`N8N_EDITOR_BASE_URL` environment variable](/hosting/configuration/environment-variables/deployment.md).
  1. 与你的身份提供商 (IdP) 设置 OIDC。你需要:

¥Set up OIDC with your identity provider (IdP). You'll need to:

  • 在你的身份提供商 (IdP) 中创建一个新的 OIDC 客户端/应用。

    ¥Create a new OIDC client/application in your IdP.

  • 配置上一步中的重定向 URL。

    ¥Configure the redirect URL from the previous step.

  • 记下你的身份提供商 (IdP) 提供的客户端 ID 和客户端密钥。

    ¥Note down the Client ID and Client Secret provided by your IdP. 2. 在身份提供商 (IdP) 中,找到发现端点(也称为众所周知的配置端点)。它通常具有以下格式:

¥In your IdP, locate the Discovery Endpoint (also called the well-known configuration endpoint). It typically has the following format:

1
https://your-idp-domain/.well-known/openid-configuration
3. 在 n8n 中,完成 OIDC 配置:

¥In n8n, complete the OIDC configuration:

  • 发现端点:请输入来自你的身份提供商 (IdP) 的发现端点 URL。

    ¥Discovery Endpoint: Enter the discovery endpoint URL from your IdP.

  • 客户端 ID:输入你在向身份提供商 (IdP) 注册应用时收到的客户端 ID。

    ¥Client ID: Enter the client ID you received when registering your application with your IdP.

  • 客户端密钥:输入你在向身份提供商 (IdP) 注册应用时收到的客户端密钥。

    ¥Client Secret: Enter the client secret you received when registering your application with your IdP. 4. 选择“保存设置”。

¥Select Save settings. 5. 设置 OIDC 为“已激活”。

¥Set OIDC to Activated.

实例和项目访问权限配置#

¥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.

你需要在 OIDC 授权服务器中添加一个名为 n8n 的附加作用域。

¥You need to add a an additional scope called n8n to your OIDC authorization server.

在此 n8n 范围内,你需要添加以下两个声明:

¥On this n8n scope, you need to add these two claims:

名称 数据类型 范围 令牌类型
n8n_instance_role string n8n ID
n8n_projects 字符串数组 n8n ID

这两个必须始终包含在来自授权服务器的 "ID 令牌" 中。

¥These two need to always be included in the "ID Token" from your authorization server.

确保在有权访问 n8n 的身份提供商用户组中配置了这两个属性。

¥Ensure that these two attributes are configured in the user groups of your identity provider that have access to n8n.

在 n8n 的“设置”>“SSO”页面上的表单中,你会找到一个名为 "用户角色配置" 的下拉列表。

¥Inside the form on the Settings > SSO page in n8n, you will find a dropdown labeled "User role provisioning" in the form.

默认情况下,此值设置为 "使用 n8n 管理"。

¥By default this is set to "Manged in n8n".

你可以选择将其设置为:

¥You can choose to set it to:

  • 实例角色

¥Instance role

  • 仅从 SAML 响应的 n8n_instance_role 属性读取每个已配置用户的实例角色。项目访问权限将仍然仅在 n8n 内部管理。

    ¥Only the instance role of each provisioned user will be read from the n8n_instance_role attribute from the SAML response. Project access will still be managed inside n8n only.

  • 如果你的身份提供商 (IdP) 上未配置 n8n_instance_role 的值,则将使用 global:member 角色作为备用。

    ¥If there is no value for n8n_instance_role configured on your IdP, the global:member role is used as fallback.

  • 实例和项目角色

¥Instance and project roles

  • 每个已配置用户的实例角色和项目访问权限都将从 SAML 响应中的 n8n_instance_rolen8n_projects 属性读取。

    ¥Both the instance role and project access of each provisioned user will be read from the n8n_instance_role and n8n_projects attributes from the SAML response.

Existing access will be overwritten

启用 "用户角色配置" 后,下次任何用户使用 SAML 登录时,该用户在 n8n 中被授予的任何访问权限(未反映在 n8n_instance_role 和 n8n_projects 中)都将被移除。

¥Once you enable "User role provisioning", the next time any user logs in using SAML, any access they've been granted inside n8n, which isn't reflected in the n8n_instance_role and n8n_projects will be removed from that user.

启用此功能后,你需要先下载两个 CSV 文件才能保存更改。这些文件包含你当前的所有访问设置,以备需要时参考。

¥When activating this feature, you are required to download two CSV files before you can save this change. These files contain all your current access settings should you need to reference them.

正在配置 n8n_instance_role 属性

¥Configuring n8n_instance_role attribute

n8n_instance_role 属性是一个简单的字符串,用于配置身份提供商 (IdP) 上的组或用户。

¥The n8n_instance_role attribute is a simple string configured for a group or user on your IdP.

支持的实例角色:

¥Supported instance roles are:

  • global:member

  • global: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.

此数组中的每个元素都需要遵循以下格式:<项目 ID>:<角色>

¥Each element in this array needs to follow this format: :

例如:

¥For example:

  • bHsykgeFirmIhezz:viewer

  • 4K3zrg3DvlMFFTB7:editor

  • dCjnYuEpYOUBVaNe:admin

对于使用身份提供商 (IdP) 启用项目访问权限配置时已有的访问设置,你可以在下载的 CSV 文件中找到项目 ID。

¥For existing access settings at the time of enabling project access provisioning using 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.

特定提供商的 OIDC 设置#

¥Provider-specific OIDC setup

Okta#

在 Okta 中设置 OIDC 的步骤与下文所述的 Auth0 类似。

¥The steps to setup OIDC in Okta are similar as with Auth0 described below.

对于 Okta,你可以下载 PDF 格式的图文分步指南:

¥For Okta, you can download a visual step-by-step guide as PDF:

n8n-oidc-with-okta.pdf

Auth0#

  1. 在 Auth0 中创建应用。

¥Create an application in Auth0:

  • 登录你的 Auth0 控制面板。

    ¥Log in to your Auth0 Dashboard.

  • 前往“应用”>“应用”。

    ¥Go to Applications > Applications.

  • 点击“创建应用”。

    ¥Click Create Application.

  • 输入名称(例如 "n8n SSO"),然后选择“常规 Web 应用”。

    ¥Enter a name (for example, "n8n SSO") and select Regular Web Applications.

  • 点击“创建”。

    ¥Click Create. 2. 配置应用:

¥Configure the application:

  • 前往新应用的设置标签页。

    ¥Go to the Settings tab of your new application.

  • 允许回调 URL:从“设置”>“SSO”>“OIDC”添加你的 n8n 重定向 URL。

    ¥Allowed Callback URLs: Add your n8n redirect URL from Settings > SSO > OIDC.

  • 允许的 Web 来源:添加你的 n8n 基本 URL(例如,https://yourworkspace.app.n8n.cloud)。

    ¥Allowed Web Origins: Add your n8n base URL (for example, https://yourworkspace.app.n8n.cloud).

  • 点击“保存更改”。

    ¥Click Save Changes. 3. 获取你的凭据

¥Get your credentials:

  • 客户端 ID:位于“设置”选项卡中。

    ¥Client ID: Found in the Settings tab.

  • 客户端密钥:位于“设置”选项卡中。

    ¥Client Secret: Found in the Settings tab.

  • 发现端点:https://{your-auth0-domain}.auth0.com/.well-known/openid-configuration

    ¥Discovery Endpoint: https://{your-auth0-domain}.auth0.com/.well-known/openid-configuration. 4. 在 n8n 中,完成 OIDC 配置:

¥In n8n, complete the OIDC configuration:

  • 发现端点:请输入来自 Auth0 的发现端点 URL。

    ¥Discovery Endpoint: Enter the discovery endpoint URL from Auth0.

  • 客户端 ID:输入你在 Auth0 设置中找到的客户端 ID。

    ¥Client ID: Enter the client ID you found in your Auth0 settings.

  • 客户端密钥:输入你在 Auth0 设置中找到的客户端密钥。

    ¥Client Secret: Enter the client secret you found in your Auth0 settings. 5. 选择“保存设置”。

¥Select Save settings. 6. 设置 OIDC 为“已激活”。

¥Set OIDC to Activated.

Discovery 端点参考#

¥Discovery endpoints reference

  • Google Discovery 端点示例:

¥Google discovery endpoint example:

1
https://accounts.google.com/.well-known/openid-configuration
  • Microsoft Azure AD 发现终结点示例:

¥Microsoft Azure AD discovery endpoint example:

1
https://login.microsoftonline.com/{tenant-id}/v2.0/.well-known/openid-configuration
  • Auth0 发现端点示例:

¥Auth0 discovery endpoint example:

1
https://{your-domain}.auth0.com/.well-known/openid-configuration
  • Okta 发现端点示例:

¥Okta discovery endpoint example:

1
https://{your-domain}.okta.com/.well-known/openid-configuration
  • Amazon Cognito 发现端点示例:

¥Amazon Cognito discovery endpoint example:

1
https://cognito-idp.{region}.amazonaws.com/{user-pool-id}/.well-known/openid-configuration