Rancher 系列文章之 - Azure AD 登录认证
本文永久链接: https://www.xtplayer.cn/rancher/authentication/rancher2-azure-ad-authentication/
版本支持: Rancher v2.0.3+
如果您在 Azure中启用了 Active Directory(AD)服务,则可以配置 Rancher以允许您的用户使用 Azure AD帐户登录。
在 Azure中注册 Rancher
在 Rancher中启用 Azure AD之前,必须向 Azure注册 Rancher。
Azure分 Global区和中国区:
·中国区 Portal地址:https://portal.azure.cn
·Global区Portal地址:https://portal.azure.com
本文配置以中国区为例,Global区方法类似
1.步骤中的配置需要管理访问权限,所以需要以管理用户身份登录Microsoft Azure portal。
2.搜索应用注册并打开

3.点击新应用程序注册,并完成表单填写,最后点击右下角的创建。


注意:登录 URL需要填写为 Rancher设置中配置的server_url,但是中国区需要在rancher_server_url地址后面添加verify-auth-azure 后缀,例如:https://demo.rancher.com/verify-auth-azure,Azure为 Global区不用添加。
创建 Azure API密钥
从 Azure门户中创建 API密钥,Rancher将使用此密钥对 Azure AD进行身份验证。
1.搜索应用注册服务,然后打开上一个过程中创建的rancher-test。可能会提示您不是此目录中任何应用程序的所有者,直接点击查看所有应用程序。


2.点击rancher-test后弹出新的窗口

3.单击设置,从设置边栏中选择密钥。

4.输入密钥描述,比如rancher-test,选择密钥的有效期,最后点击保存。

注意: 因为密钥只显示一次,所以需要复制密钥并保存到一个安全的地方。
设置 Rancher的必需权限
接下来,在 Azure中为 Rancher设置 API权限。
1.紧接上一步,从设置边栏选择所需权限。

2.单击Windows Azure Active Directory。
3.从启用访问权限边栏选项卡中,勾选以下委派权限:
o以登录用户身份访问该目录
o读取目录数据
o读取所有群组
o读取所有用户的完整个人资料
o读取所有用户的基本配置文件
o登录并读取用户个人资料

注意:必须以 Azure管理员身份登录才能成功保存权限设置。
复制 Azure应用程序数据
Azure配置的最后一步,复制用于配置 Rancher进行 Azure AD身份验证的相关配置参数到空文本文件中。
1.获取目录 ID
o搜索 Azure Active Directory服务

o从 Azure Active Directory菜单中,打开属性

o复制目录 ID并将其粘贴到文本文件中

2.获取应用 ID。
o搜索应用注册
o找到创建的rancher-test应用
o复制应用程序 ID并将其粘贴到您的文本文件中

o获取MICROSOFT AZURE AD GRAPH API终结点、OAUTH 2.0令牌终结点和OAUTH 2.0授权终结点。
o搜索应用注册,并点击终结点


3.将以下端点复制到剪贴板并将其粘贴到文本文件中
oMICROSOFT AZURE AD GRAPH API终结点
oOAUTH 2.0令牌终结点
oOAUTH 2.0授权终结点
在 Rancher中配置 Azure AD
在 Rancher UI中,输入在 Azure中获取到的 AD配置信息以完成配置。
1.登录 RancherUI,从全局视图中,选择安全>认证。
2.选择 Azure AD。
3.输入对应的配置信息:
下表是 Azure 门户配置与 Rancher 认证配置的字段对应表:

重要提示
Global区 Endpoint地址: https://login.windows.net/
Global区 Graph Endpoint地址:https://graph.windows.net/
具体信息请查阅:Check-endpoints-in-Azure
4.最后点击启用 Azure AD。