了解单点登录 (SSO) 流程
在为你的组织配置单点登录(SSO)时,你可以在两种不同的登录流程之间进行选择:身份提供者(IdP)发起 和 服务提供者(SP)发起。了解它们的区别可以帮助你为用户提供最佳体验。
🌐 When configuring SSO for your organization, you can choose between two different sign-in flows: identity provider (IdP)-initiated and service provider (SP)-initiated. Understanding the difference helps you provide the best experience for your users.
快速决策指南
大多数企业使用身份提供商(IdP)发起的流程,因为它更简单、用户体验更好。只有在你希望用户从 supabase.com 开始登录流程时,才启用服务提供商(SP)发起的流程。
🌐 Most enterprises use IdP-initiated flow for its simplicity and better user experience. Enable SP-initiated only if you need users to start their sign-in journey at supabase.com.
查看我们的选择合适的登录流程指南了解使用案例示例。
🌐 See our Choosing the Right Sign-in Flow guide for use case examples.
登录流程概览 #
🌐 Overview of sign-in flows
IdP 发起(身份提供者发起) #
🌐 IdP-initiated (Identity Provider Initiated)
使用 IdP 发起的流程时,用户从你的身份提供商(Okta、Azure AD、Google Workspace 等)开始登录,然后直接被认证进入 Supabase。
🌐 With IdP-initiated flow, users start their sign-in journey from your identity provider (Okta, Azure AD, Google Workspace, etc.) and are directly authenticated into Supabase.
用户体验:
- 用户打开他们的身份提供商仪表板(例如,Okta 首页,Azure MyApps)
- 用户点击 Supabase 应用图标或书签
- 如果用户已经通过身份提供者认证,则会立即登录 Supabase
主要特点:
- ✅ 更简单的用户体验——从身份提供者只需一键
- ✅ 不需要域名配置
- ✅ 一旦启用 SSO,就会自动工作
- ✅ 更适合内部网络门户和员工应用目录
- ✅ Supabase 的默认行为
SP 发起的(服务提供商发起) #
🌐 SP-initiated (Service Provider Initiated)
使用 SP 发起的流程时,用户从 supabase.com 开始,输入他们的邮箱地址,然后被重定向到你的身份提供者进行认证。
🌐 With SP-initiated flow, users start at supabase.com, enter their email address, and are redirected to your identity provider for authentication.
用户体验:
- 用户访问 supabase.com 并点击“使用 SSO 登录”
- 用户输入他们的邮箱地址
- 用户被重定向到他们的身份提供者
- 验证后,用户会被重定向回 Supabase
主要特点:
- ✅ 对常用 supabase.com 的用户来说很熟悉的流程
- ✅ 支持基于域的自动 IdP 路由
- ⚠️ 需要配置邮箱域名
- ⚠️ 登录过程需要更多步骤
在流程之间做选择 #
🌐 Choosing between flows
什么时候使用 IdP 发起(推荐) #
🌐 When to use IdP-initiated (recommended)
最佳适用对象:
- 已经建立身份提供商工作流程的组织
- 主要通过他们的身份提供者仪表板访问应用的用户
- 每个域名多个 SAML 应用(开发、测试、生产环境)
- 简化用户入职
常见场景:
- 我们团队通过 Okta 图标访问所有工具
- 我们想要最简单的登录体验
- 我们需要在同一个域下有单独的开发和生产 SAML 应用
- 用户根本不需要记住 supabase.com
什么时候使用服务提供商发起的 #
🌐 When to use SP-initiated
最佳适用对象:
- 用户直接收藏 supabase.com 的组织
- 从基于密码的身份验证迁移
- 不熟悉身份提供商控制面板的用户
常见场景:
- 有些用户会把 supabase.com 加入书签,并且期望从那里开始
- 我们正在从密码认证转向单点登录
- 用户需要在所有工具中使用一致的登录页面
- 我们想要基于域的自动 IdP 选择
什么时候同时启用两个流程 #
🌐 When to enable both flows
你可以同时启用两种流程来支持不同的用户偏好。
🌐 You can enable both flows simultaneously to support different user preferences.
最佳适用对象:
- 拥有多样化用户需求的大型组织
- 混合认证的渐进式单点登录迁移
- 支持技术和非技术用户
配置登录流程 #
🌐 Configuring sign-in flows
启用 IdP 发起的流程(默认) #
🌐 Enabling IdP-initiated flow (default)
当你配置 SSO 时,IdP 发起的流程会自动启用。不需要额外步骤。
🌐 IdP-initiated flow is automatically enabled when you configure SSO. No additional steps required.
- 导航到仪表板的SSO 设置部分
- 启用“单点登录”
- 配置你的身份提供者元数据和属性映射
- 保存你的配置
用户现在可以通过你们身份提供商的应用目录访问 Supabase。
🌐 Users can now access Supabase through your IdP's app catalog.
域配置可选
使用 IdP 发起的流程时,你不需要配置电子邮件域名。你的身份提供商会处理所有的认证路由。
🌐 With IdP-initiated flow, you don't need to configure email domains. Your identity provider handles all authentication routing.
启用服务提供商发起的流程 #
🌐 Enabling SP-initiated flow
要启用 SP 发起的流程,你需要配置邮箱域名:
🌐 To enable SP-initiated flow, you need to configure email domains:
- 导航到仪表板的SSO 设置部分
- 启用“单点登录”
- 将 启用 SP 发起的登录 切换为“开启”
- 添加一个或多个邮箱域名(例如,
yourcompany.com) - 配置你的身份提供者元数据和属性映射
- 保存你的配置
邮箱域名要求 #
🌐 Email domain requirements
- 启用 SP 发起时至少需要一个域
- 域名必须通过你的身份提供商验证
- 支持多个域(例如,
company.com、subsidiary.com) - 具有匹配电子邮件域的用户将被引导到你的身份提供者
域名有限制
只有邮箱地址与你配置的域匹配的用户才能使用 SP 发起的登录。其他域的用户无法通过 supabase.com 的 SSO 登录(但如果你在 IdP 中配置了,他们仍然可以使用 IdP 发起的流程)。
🌐 Only users with email addresses matching your configured domains can use SP-initiated sign-in. Users with other domains cannot sign in via SSO at supabase.com (but can still use IdP-initiated flow if you configure it in your IdP).
在流程之间切换 #
🌐 Switching between flows
你可以随时更改登录流程配置:
🌐 You can change sign-in flow configuration at any time:
从SP发起切换到仅IdP #
🌐 To switch from SP-initiated to IdP-only
- 导航到仪表板的SSO 设置部分
- 将 启用 SP 发起的登录 切换为“关闭”
- 保存更改
现有用户可以继续通过 IdP 发起的流程登录。
🌐 Existing users can continue signing in via IdP-initiated flow.
从仅 IdP 切换到 SP 发起 #
🌐 To switch from IdP-only to SP-initiated
- 导航到仪表板的SSO 设置部分
- 将 启用 SP 发起的登录 切换为“开启”
- 添加必需的邮箱域名
- 保存更改
技术细节 #
🌐 Technical details
IdP 发起的流程是如何运作的 #
🌐 How IdP-initiated flow works
- 用户点击身份提供商中的应用图标
- 身份提供者生成 SAML 断言并 POST 到 Supabase ACS URL
- Supabase 会验证断言并创建会话
- 用户被重定向到 Supabase 仪表板
不需要域名查询 - IdP 断言包含所有必要的用户信息。
SP 发起的流程是怎么运作的 #
🌐 How SP-initiated flow works
- 用户在 supabase.com/sign-in-sso 输入邮箱
- Supabase 会将邮箱域名匹配到已配置的 SSO 提供商
- Supabase 生成 SAML 请求并重定向到 IdP
- 身份提供者验证用户并生成SAML声明
- 身份提供者将断言通过 POST 发送到 Supabase ACS URL
- Supabase 会验证断言并创建会话
域名匹配很关键 - 如果域名不匹配,用户无法完成 SP 发起的流程。
每个域的多个 SAML 应用 #
🌐 Multiple SAML apps per domain
IdP发起的流程的一个主要优势是支持在同一域名下使用多个SAML应用。
🌐 One of the key advantages of IdP-initiated flow is supporting multiple SAML applications under the same domain.
只有SP发起的问题 #
🌐 The problem with SP-initiated only
许多企业需要为不同环境设置独立的 SAML 应用:
🌐 Many enterprises need separate SAML apps for different environments:
- 开发 SAML 应用
- 部署 SAML 应用
- 生产 SAML 应用
仅限 SP 发起的流程: 每个 SAML 应用都需要一个唯一的域名。你需要:
dev.company.comstaging.company.comprod.company.com
这通常不太实际,因为所有员工都使用 company.com 邮箱地址。
🌐 This is often impractical since all employees use company.com email addresses.
使用 IdP 发起流程的解决方案 #
🌐 The solution with IdP-initiated flow
使用 IdP 发起流程: 所有 SAML 应用都可以使用相同的域名(company.com),因为:
- 用户通过不同的 IdP 图标/书签访问每个应用
- 不需要基于域的路由
- 每个 SAML 应用都有自己独特的 ACS URL 和元数据
你在身份提供商中的配置 #
🌐 Configuration in your IdP
- 创建“Supabase Dev” SAML 应用 → 指向开发组织的 ACS URL
- 创建“Supabase Staging”SAML 应用 → 指向暂存组织的 ACS URL
- 创建“Supabase Production” SAML 应用 → 指向生产组织的 ACS URL
用户点击他们需要的环境对应的选项卡。
🌐 Users click the appropriate tile for the environment they need.
这是针对有多个环境的企业推荐的方法。将每个环境配置为仅由 IdP 发起(不需要域名)。
🌐 This is the recommended approach for enterprises with multiple environments. Configure each environment as IdP-initiated only (no domains needed).
常见问题 #
🌐 Common questions
你能同时使用这两种流程吗? #
🌐 Can you use both flows simultaneously?
是的!启用 SP 发起的登录并配置域名。IdP 发起的流程会继续自动工作。
🌐 Yes! Enable SP-initiated sign-in and configure domains. IdP-initiated flow continues to work automatically.
如果你不配置域名会发生什么? #
🌐 What happens when you don't configure domains?
没有域名的话,只能使用 IdP 发起的流程。用户不能在 supabase.com 开始登录。
🌐 Without domains, only IdP-initiated flow is available. Users cannot start their sign-in at supabase.com.
身份提供者需要配置吗? #
🌐 Does the IdP require configuration?
对于 IdP 发起的流程: 在你的 IdP 中配置 Supabase 的 ACS URL 和实体 ID。查看我们的特定提供商指南:
🌐 For IdP-initiated flow: Configure the Supabase ACS URL and entity ID in your IdP. See our provider-specific guides:
对于SP发起的流程: 配置相同,但也要确保你的 IdP 接受来自 Supabase 的 SAML 请求。
🌐 For SP-initiated flow: Same configuration, but also ensure your IdP accepts SAML requests from Supabase.
如果用户尝试 SP 发起但没有匹配的域,会发生什么? #
🌐 What happens if a user tries SP-initiated with no matching domain?
他们收到一条错误信息,提示找不到他们邮箱域名对应的单点登录(SSO)提供商。如果他们有非SSO账户,仍然可以使用密码或社交账号登录。
🌐 They receive an error message indicating no SSO provider found for their email domain. They can still sign in using password or social auth (if they have a non-SSO account).
你启用 SP 发起的流程后能禁用它吗? #
🌐 Can you disable SP-initiated flow after enabling it?
是的,可以随时关闭。现有用户可以继续使用 IdP 发起的流程。
🌐 Yes, toggle it off at any time. Existing users can continue using IdP-initiated flow.
哪个流程更安全? #
🌐 Which flow is more secure?
只要配置得当,这两种流程的安全性是一样的。安全性取决于:
🌐 Both flows are equally secure when properly configured. Security depends on:
- 强身份提供者认证策略
- 证书管理与轮换
- 属性映射配置
- 定期安全检查
查看我们的SSO 测试与最佳实践指南,获取安全建议。
🌐 See our SSO Testing and Best Practices guide for security recommendations.
下一步 #
🌐 Next steps
- 选择你的登录流程: 查看 选择正确的登录流程
- **配置你的服务提供商:**请参考我们的特定服务提供商指南
- 彻底测试: 查看 SSO 测试与最佳实践
- 启用自动加入: 配置自动加入设置以实现无缝入门