Keycloak SAML
Keycloak is an open-source IdP that supports SAML and OpenID Connect and can broker LDAP or other SAML IdPs. This guide configures a Keycloak SAML client and Casdoor so Keycloak users can sign in to Casdoor.
Configure Keycloak
Example assumptions:
- Casdoor: UI at
http://localhost:7001, API athttp://localhost:8000. Adjust for your deployment. - Keycloak: UI at
http://localhost:8080/auth. - SP ACS URL and Entity ID:
http://localhost:8000/api/acs.
备注
The /api/acs endpoint only accepts POST requests. Ensure Keycloak is configured to use HTTP POST binding for SAML responses.
Use the default realm or create a new one.


在 Keycloak 中添加客户端条目
在菜单中点击 客户端 然后点击 创建 去到 添加客户端 页面。 按照以下方式填写字段:
- 客户端 ID:
http://localhost:8000/api/acs- 这将是以后在 Casdoor 配置中使用的 SP 实体ID。 - Client Protocol:
saml. - 客户端SAML端点:
http://localhost:8000/api/acs- 这个URL是你希望Keycloak服务器发送SAML请求和响应的地方。 通常,应用程序有一个用于处理SAML请求的URL。 客户端的设置选项卡中可以设置多个URL。

单击 Save(保存)。 此动作创建客户端并将您带到 设置 选项卡。
以下是设置的一部分:
- Name — e.g.
Casdoor; any friendly name for the Keycloak UI. - 已启用 - 选择
on。 - 包含 Authn 语句 - 选择
on。 - 签署文件 - 选择
on。 - 签名断言 - 选择
off。 - 加密断言 - 选择
off。 - 需要客户签名 - 请选择
off。 - 强制名称ID格式 - 选择
on。 - 名称 ID 格式 - 选择
username。 - 有效重定向 URI - 添加
http://localhost:8000/api/acs. - Master SAML 处理 URL -
http://localhost:8000/api/acs. - 精良的谷物SAML端点配置
- 声明消费者服务公开绑定URL -
http://localhost:8000/api/acs。 - 声明消费者服务重定向绑定URL -
http://localhost:8000/api/acs。
- 声明消费者服务公开绑定URL -
保存该配置。