使用 Google Workspace 设置单点登录
此功能仅在团队和企业计划中可用。如果你是现有的团队或企业计划客户,请继续下面的设置。
🌐 This feature is only available on the Team and Enterprise Plans. If you are an existing Team or Enterprise Plan customer, continue with the setup below.
想找关于如何在你的 Supabase 项目中添加单点登录支持的文档吗?快去看看 项目的 SAML 2.0 单点登录 吧。
🌐 Looking for docs on how to add Single Sign-On support in your Supabase project? Head on over to Single Sign-On with SAML 2.0 for Projects.
Supabase 支持使用 Google Workspace(以前叫 G Suite)的单点登录(SSO)。
🌐 Supabase supports single sign-on (SSO) using Google Workspace (formerly known as G Suite).
第 1 步:打开 Google Workspace 网页和移动应用控制台 #
🌐 Step 1: Open the Google Workspace web and mobile apps console [#google-workspace-console]

步骤 2:选择添加自定义 SAML 应用 #
🌐 Step 2: Choose to add custom SAML app [#add-custom-saml-app]
在工具栏的 添加应用 按钮中选择 添加自定义 SAML 应用。
🌐 From the Add app button in the toolbar choose Add custom SAML app.

步骤 3:填写应用详情 #
🌐 Step 3: Fill out app details [#add-app-details]
你在这里输入的信息是为了让你能够看到你的 Google Workspace。你可以随意选择任何值。Supabase 作为名称在大多数情况下都很适用。你也可以选择输入一个描述。
🌐 The information you enter here is for visibility into your Google Workspace. You can choose any values you like. Supabase as a name works well for most use cases. Optionally enter a description.

第4步:下载 IdP 元数据 #
🌐 Step 4: Download IdP metadata [#download-idp-metadata]
这是一个非常重要的步骤。点击 下载元数据 并保存下载的文件。你稍后在 步骤 10 中需要上传这个文件。
🌐 This is a very important step. Click on DOWNLOAD METADATA and save the file that was downloaded. You will need to upload this file later in Step 10.

重要提示:确保屏幕上显示的证书至少在 1 年后才会过期。
证书到期: 在证书到期前30天设置日历提醒。当证书更新后,你需要下载新的元数据文件并在Supabase SSO设置中更新。证书过期是导致SSO登录失败的常见原因。
步骤 5:添加服务提供商详情 #
🌐 Step 5: Add service provider details [#add-service-provider-details]
在下一个屏幕填写这些服务提供商的详细信息。
🌐 Fill out these service provider details on the next screen.
| 详情 | 值 |
|---|---|
| ACS URL | https://alt.supabase.io/auth/v1/sso/saml/acs |
| 实体 ID | https://alt.supabase.io/auth/v1/sso/saml/metadata |
| 起始 URL | https://supabase.nodejs.cn/dashboard |
| 名称 ID 格式 | PERSISTENT |
| 名称 ID | 基本信息 > 主要邮箱 |

第6步:配置属性映射 #
🌐 Step 6: Configure attribute mapping [#configure-attribute-mapping]
属性映射可以让 Supabase 在每次登录时获取你的 Google Workspace 用户信息。
🌐 Attribute mappings allow Supabase to get information about your Google Workspace users on each sign-in.
需要将 主电子邮件 映射到 email。 下面显示的其他映射是可选的,并且可以根据你的 Google Workspace 设置进行配置。如果不确定,可以按照显示的配置进行复制。
你在此屏幕上做的任何更改稍后将在步骤10:配置属性映射中使用。
🌐 Any changes you make from this screen will be used later in Step 10: Configure Attribute Mapping.

步骤 7:配置用户访问 #
🌐 Step 7: Configure user access [#configure-user-access]
你可以配置哪些 Google Workspace 用户账号可以访问 Supabase。如果你想限制访问权限只给你的软件工程团队,这一点很重要。
🌐 You can configure which Google Workspace user accounts will get access to Supabase. This is important if you wish to limit access to your software engineering teams.
你可以点击“用户访问”卡片(或向下箭头)来配置此访问权限。按照屏幕上的说明操作即可。
🌐 You can configure this access by clicking on the User access card (or down-arrow). Follow the instructions on screen.

从这一步开始的更改有时需要一段时间才能在谷歌的系统中生效。请至少等 15 分钟再测试你的更改。
🌐 Changes from this step sometimes take a while to propagate across Google's systems. Wait at least 15 minutes before testing your changes.
步骤 8:在控制面板中启用单点登录 #
🌐 Step 8: Enable SSO in the Dashboard [#dashboard-enable-sso]
- 访问组织设置页面下的SSO标签。

- 切换 启用单点登录 以开始配置。启用后,配置表单将会出现。

步骤9:配置域名 #
🌐 Step 9: Configure domains [#dashboard-configure-domain]
输入一个或多个与你用户邮箱地址相关的域名(例如,supabase.com)。这些域名决定哪些用户可以通过SSO登录。
🌐 Enter one or more domains associated with your users email addresses (e.g., supabase.com).
These domains determine which users are eligible to sign in via SSO.

如果你的组织使用多个电子邮件域名——例如,员工用 supabase.com,承包商用 supabase.io——你可以在这里添加多个域名。所有列出的域名都可以用于 SSO 登录。
🌐 If your organization uses more than one email domain - for example, supabase.com for staff and supabase.io for contractors - you can add multiple domains here. All listed domains will be authorized for SSO sign-in.

我们不允许使用像 gmail.com、yahoo.com 这样的公共域名。
🌐 We do not permit use of public domains like gmail.com, yahoo.com.
每个 SSO 提供商都可以配置不同的邮箱域名。对于多环境设置(开发/预演/生产),我们建议使用 IdP 发起的流程,在同一域名下使用多个 SAML 应用,而不是基于域名的路由。更多详情,请参阅 多个 SSO 提供商指南。
🌐 Each SSO provider can be configured with different email domains. For multi-environment setups (Dev/Staging/Prod), we recommend using IdP-initiated flow with multiple SAML apps under the same domain rather than domain-based routing. For more details, see the Multiple SSO Providers guide.
第10步:配置元数据 #
🌐 Step 10: Configure metadata [#dashboard-configure-metadata]
把你在 步骤 6 下载的元数据文件上传到元数据上传文件栏里。
🌐 Upload the metadata file you downloaded in Step 6 into the Metadata Upload File field.

第11步:配置属性映射 #
🌐 Step 11: Configure attribute mapping [#dashboard-configure-attributes]
把你在步骤 6填写的 SAML 属性输入到属性映射部分。
🌐 Enter the SAML attributes you filled out in Step 6 into the Attribute Mapping section.

如果你没有自定义设置,可以通过点击 G Suite 预设来节省一些时间。
🌐 If you did not customize your settings you may save some time by clicking the G Suite preset.
第12步:注册时加入组织(可选)#
🌐 Step 12: Join organization on signup (optional) [#dashboard-configure-autojoin]
**推荐的工作流程:**一开始先关闭自动加入,以测试你的 SSO 配置。一旦 SSO 登录正常工作,如果需要,可以开启自动加入。
默认情况下,这个设置是关闭的,通过 SSO 登录的用户不会自动被添加到你的组织中。
🌐 By default this setting is disabled, users signing in via SSO will not be added to your organization automatically.

如果你希望通过SSO登录的用户 在登录时自动加入你的组织,请开启此选项。自动加入适用于 每次登录,不仅仅是第一次注册——这让你在启用此功能前测试SSO也很安全。
🌐 Toggle this on if you want SSO-authenticated users to be automatically added to your organization when they sign in via SSO. Auto-join applies on every sign-in, not only on first signup - this makes it safe to test SSO before enabling this feature.

开启自动加入后,你可以为新用户选择默认角色:
🌐 When auto-join is enabled, you can choose the default role for new users:

我们建议将 开发者 作为默认角色(最小权限原则),并根据需要单独提升用户权限。
🌐 We recommend choosing Developer as the default role (principle of least privilege) and promoting users individually as needed.
访问 access-control 文档,了解每个角色的详细信息。
🌐 Visit access-control documentation for details about each role.
步骤 13:保存更改 #
🌐 Step 13: Save changes [#dashboard-configure-save]
当你点击 保存更改 时,你的新 SSO 配置会立即生效。从那一刻起,任何使用与你配置的域名匹配的邮箱地址的用户访问你们组织的登录网址时,都会通过 SSO 流程进行。
🌐 When you click Save changes, your new SSO configuration is applied immediately. From that moment, any user with an email address matching one of your configured domains who visits your organization's sign-in URL will be routed through the SSO flow.
下一步:测试你的 SSO 配置
在向你的组织推出单点登录(SSO)之前,我们强烈建议进行彻底测试。请查阅我们的 SSO 测试和最佳实践 指南,了解更多信息:
🌐 Before rolling out SSO to your organization, we strongly recommend thorough testing. Visit our SSO Testing and Best Practices guide for:
- 逐步测试说明
- 如何确认自动加入功能正常工作
- 常见问题与解决方法
- 安全最佳实践
- 预发布清单