Rancher 对接 KeyCloak SAML

Rancher 支持对接 KeyCloak 进行用户身份认证,此处测试基于 SAML 协议。

环境信息:

  1. Rancher: v2.9.5-ent
  2. KeyCloak: 26.4.5

部署 KeyCloak

参考:https://warnerchen.github.io/2025/11/19/Rancher-%E5%AF%B9%E6%8E%A5-KeyCloak-OIDC/#%E9%83%A8%E7%BD%B2-KeyCloak

配置 KeyCloak

创建一个 Client:

保存后,编辑 Client:

点击对应的 Client -> Client scopes -> https://<rancher_url>/v1-saml/keycloak/saml/metadata-dedicated

点击 Add predefined mappers,添加所有 Mapper:

点击 Add Mapper -> By Configuration,创建第一个 Mapper:

点击 Add Mapper -> By Configuration,创建第二个 Mapper:

在 Advanced 页面设置 Logout Service Redirect Binding URL 配置登出重定向页面:

进入 Realm settings 页面,在 Endpoints 选项中点击 SAML 2.0 Identity Provider Metadta 保存 metadata.xml:

配置 Rancher 对接 KeyCloak

在 Rancher 选择 KeyCloak SAML:

对接 KeyCloak 需要有一个证书,使得 Rancher 和 IDP 之间能够创建一个安全的外壳,证书可以通过下面的命令创建:

1
openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout myservice.key -out myservice.cert

随后会跳出一个弹窗,此时通过对应 Realm 的 admin 用户进行登录:

完成认证后,开启成功:

Author

Warner Chen

Posted on

2025-11-21

Updated on

2025-11-21

Licensed under

You need to set install_url to use ShareThis. Please set it in _config.yml.
You forgot to set the business or currency_code for Paypal. Please set it in _config.yml.

Comments

You forgot to set the shortname for Disqus. Please set it in _config.yml.