配置自托管的 n8n 用户管理(Configure self-hosted n8n for user management)#
n8n 中的用户管理功能允许你邀请他人加入你的 n8n 实例。
🌐 User management in n8n allows you to invite people to work in your n8n instance.
本文档描述了如何配置 n8n 实例以支持用户管理,以及开始邀请用户的步骤。
🌐 This document describes how to configure your n8n instance to support user management, and the steps to start inviting users.
有关使用的更多信息,请参阅主要的用户管理指南,包括:
🌐 Refer to the main User management guide for more information about usage, including:
有关 LDAP 设置的信息,请参阅 LDAP。
🌐 For LDAP setup information, refer to LDAP.
有关 SAML 设置的信息,请参考 SAML。
🌐 For SAML setup information, refer to SAML.
不受支持的用户管理方法
在 1.0 版本中,n8n:
- 移除了对 基本认证 和 JWT 的支持
- 移除了 N8N_USER_MANAGEMENT_DISABLED 环境变量。在最近的 n8n 版本中,没有支持的方式可以禁用登录界面,包括本地或开发使用。如果你需要为本地开发简化登录,可以考虑使用密码管理器、设置一个简单的本地密码,或者编写标准登录流程的脚本。
设置(Setup)#
在 n8n 中设置用户管理分为三个阶段:
🌐 There are three stages to set up user management in n8n:
- 配置你的 n8n 实例以使用你的 SMTP 服务器。
- 启动 n8n 并按照应用中的设置步骤进行操作。
- 邀请用户。
第一步:SMTP(Step one: SMTP)#
n8n 建议你设置一个 SMTP 服务器,用于用户邀请和密码重置。
🌐 n8n recommends setting up an SMTP server, for user invites and password resets.
Optional from 0.210.1
From version 0.210.1 onward, this step is optional. You can choose to manually copy and send invite links instead of setting up SMTP. Note that if you skip this step, users can't reset passwords.
Get the following information from your SMTP provider:
- 服务器名称
- SMTP 用户名
- SMTP 密码
- SMTP 发件人名称
To set up SMTP with n8n, configure the SMTP environment variables for your n8n instance. For information on how to set environment variables, refer to Configuration
| Variable | Type | Description | Required? |
|---|---|---|---|
N8N_EMAIL_MODE |
string | smtp |
Required |
N8N_SMTP_HOST |
string | your_SMTP_server_name | Required |
N8N_SMTP_PORT |
number | your_SMTP_server_port Default is 465. |
Optional |
N8N_SMTP_USER |
string | your_SMTP_username | Optional |
N8N_SMTP_PASS |
string | your_SMTP_password | Optional |
N8N_SMTP_OAUTH_SERVICE_CLIENT |
string | your_OAuth_service_client | Optional |
N8N_SMTP_OAUTH_PRIVATE_KEY |
string | your_OAuth_private_key | Optional |
N8N_SMTP_SENDER |
string | Sender email address. You can optionally include the sender name. Example with name: n8n <contact@n8n.com> |
Required |
N8N_SMTP_SSL |
boolean | Whether to use SSL for SMTP (true) or not (false). Defaults to true. |
Optional |
N8N_UM_EMAIL_TEMPLATES_INVITE |
string | Full path to your HTML email template. This overrides the default template for invite emails. | Optional |
N8N_UM_EMAIL_TEMPLATES_PWRESET |
string | Full path to your HTML email template. This overrides the default template for password reset emails. | Optional |
N8N_UM_EMAIL_TEMPLATES_WORKFLOW_SHARED |
String | Overrides the default HTML template for notifying users that a credential was shared. Provide the full path to the template. | Optional |
N8N_UM_EMAIL_TEMPLATES_CREDENTIALS_SHARED |
String | Overrides the default HTML template for notifying users that a credential was shared. Provide the full path to the template. | Optional |
N8N_UM_EMAIL_TEMPLATES_PROJECT_SHARED |
String | Overrides the default HTML template for notifying users that a project was shared. Provide the full path to the template. | Optional |
如果你的 n8n 实例已经在运行,你需要重启它以启用新的 SMTP 设置。
更多配置选项
还有更多可以作为环境变量使用的配置选项。有关列表,请参阅环境变量。这些选项包括禁用标签、工作流模板以及个性化调查,如果你不希望用户看到它们。
SMTP 新手?
如果你不熟悉 SMTP,这篇由 SendGrid 发布的博客文章提供了一个简短的介绍,而维基百科的简单邮件传输协议文章则提供了更详细的技术背景。
第二步:应用内设置(Step two: In-app setup)#
When you set up user management for the first time, you create an owner account.
- Open n8n. The app displays a signup screen.
- Enter your details. Your password must be at least eight characters, including at least one number and one capital letter.
- Click Next. n8n logs you in with your new owner account.
从环境变量预配置实例所有者(Pre-provision the instance owner from environment variables)#
Available from n8n v2.17.0
你可以通过环境变量预先配置实例所有者,而无需通过应用内设置。将 N8N_INSTANCE_OWNER_MANAGED_BY_ENV 设置为 true 并提供所有者详细信息。有关激活模式如何工作的说明,请参阅 使用环境变量管理实例设置。
🌐 You can pre-provision the instance owner from environment variables instead of going through the in-app setup. Set N8N_INSTANCE_OWNER_MANAGED_BY_ENV to true and provide the owner details. See Manage instance settings using environment variables for how the activation pattern works.
N8N_INSTANCE_OWNER_PASSWORD_HASH 必须是一个 bcrypt 哈希
此变量期望一个预先哈希的 bcrypt 值。设置明文密码会导致登录失败。
| Variable | Type | Default | Description |
|---|---|---|---|
N8N_INSTANCE_OWNER_MANAGED_BY_ENV |
Boolean | false |
Set to true to manage the instance owner from environment variables. When true, n8n overwrites the instance owner details below on every startup, locks the UI control for that user, and rejects API writes. |
N8N_INSTANCE_OWNER_EMAIL |
String | - | Email address for the instance owner. |
N8N_INSTANCE_OWNER_FIRST_NAME |
String | - | First name for the instance owner. |
N8N_INSTANCE_OWNER_LAST_NAME |
String | - | Last name for the instance owner. |
N8N_INSTANCE_OWNER_PASSWORD_HASH |
String | - | Bcrypt hash of the instance owner's password. Setting a plaintext password breaks login. |
第三步:邀请用户(Step three: Invite users)#
You can now invite other people to your n8n instance.
- Sign into your workspace with your owner account. (If you are in the Admin Panel open your Workspace from the Dashboard)
- Click the three dots next to your user icon at the bottom left and click Settings. n8n opens your Personal settings page.
- Click Users to go to the Users page.
- Click Invite.
- Enter the new user's email address.
- Click Invite user. n8n sends an email with a link for the new user to join.