添加 SAML 身份提供商
本指南解释了如何让用户通过任何 SAML 2.0 身份提供商 (IdP)(如 Google Workspace、Azure AD 或 Okta)登录到 Casdoor。
学习目标
- 在 IdP 中将 Casdoor 注册为服务提供商。
- 将 IdP 的元数据导入到自定义 SAML 提供商中。
- 将该提供商添加到应用。
所需条件
- IdP 的管理员访问权限
- Casdoor 管理控制台的管理员访问权限
在 IdP 中注册 Casdoor
在 IdP 中,使用以下值将 Casdoor 注册为服务提供商:
| Setting | Value |
|---|---|
| ACS URL | https://<your-casdoor-domain>/api/acs, for example https://door.example.com/api/acs. For a local instance at http://localhost:8000, the URL is http://localhost:8000/api/acs |
| SP entity ID | The same URL as the ACS URL |
| Binding | HTTP POST. The endpoint accepts only POST |
获取 IdP 的元数据
将 IdP 的 SAML 元数据导出为 XML。它包含实体 ID、单点登录端点和证书。某些 IdP(例如 Keycloak)仅在您输入服务提供商详细信息后才提供元数据。
在 Casdoor 中添加提供商
-
在 Casdoor 管理控制台中,转到 Identity > Providers 并添加一个提供商。
-
将 Category 设置为
SAML,将 Type 设置为Custom。 -
将 Favicon 设置为 IdP 徽标的 URL。
-
将 IdP 的元数据粘贴到 Metadata 中并点击 Parse。Casdoor 会自动填充 Endpoint、IdP、Issuer URL、SP ACS URL 和 SP Entity ID。

-
保存提供商.
将提供商添加到应用
打开应用的编辑页面,在 Providers 选项卡中添加该提供商,然后保存。
