2.5.5. 配置 SAML 身份验证
SAML 允许身份提供程序(IdP)和服务提供商(SP)交换身份验证和授权数据。Ansible Automation Platform 是一个 SAML SP,您可以配置与一个或多个 SAML IdP 通信来验证用户。
根据 SAML IdP 提供的组和属性,可以根据与这个验证器关联的验证器映射,将用户放置到 Ansible Automation Platform 中的团队和机构中。此映射可确保用户通过 SAML 登录时,Ansible Automation Platform 可以正确识别用户并分配正确的属性,如给定名称、姓氏、电子邮件和组成员资格。
先决条件
在 Ansible Automation Platform 中配置 SAML 身份验证前,请确定您执行以下操作:
- 配置 SAML 身份提供程序(IdP)。
使用与 Ansible Automation Platform 集成所需的设置预配置 SAML IdP。例如,在 Microsoft Entra ID 中,您可以配置以下内容:
- Identifier (Entity ID): 这可以是您想要的任何值,但需要与 Ansible Automation Platform 中配置的值匹配。
- 回复 URL (Assertion Consumer Service (ACS) URL : 当 Ansible Automation Platform 中配置了 SAML 方法时,会自动生成此 URL。从 Ansible Automation Platform 复制该值,并粘贴到 IdP 设置中。
- 为 SAML IdP 应用程序收集用户属性。不同的 IdP 可能会使用不同的属性名称和格式。有关确切的属性名称和预期值,请参阅特定 IdP 的文档。
使用以下命令生成私钥和公共证书:
$ openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -sha256 -days 3650 -nodes
流程
-
在导航面板中,选择
。 - 点 。
- 输入此 SAML 配置的 Name。
- 从 Authentication type 列表中选择 SAML。Authentication details 部分自动更新,以显示与所选验证类型相关的字段。
- 在 SAML Service Provider Entity ID 字段中输入应用程序定义的唯一标识符,用作 SAML 服务提供商实体 ID 字段中的 SAML 服务提供商配置的使用者。这通常是服务供应商的基本 URL,但实际值取决于您的 IdP 所预期的实体 ID。
-
在 SAML Service Provider Public Certificate 字段中包含证书内容。此信息包含在您作为先决条件创建的 cert.pem 中,必须包含--
BEGIN CERTIFICATE-- 和--END CERTIFICATE--。 -
在 SAML Service Provider Private Key 字段中包含私钥内容。此信息包含在您作为先决条件创建的 key.pem 中,必须包含--
BEGIN PRIVATE KEY-- 和--END PRIVATE KEY--。 - 在 IdP Login URL 字段中输入要重定向至 的登录登录的 URL。这是 SAML IdP 应用程序的登录 URL。
在 IdP Public Cert 字段中输入来自 IdP 的 secret 的公共证书。这是可从 IdP 下载的 SAML 证书。
注意IdP Public Cert 字段中的 IdP 应包含整个证书,包括
--BEGIN-- 和--END CERTIFICATE--。如果 IdP 没有包含前缀和后缀,则必须手动输入前缀和后缀。- 在实体 ID 中输入断言返回的 实体 ID。这是 IdP SAML 应用程序的标识符。您可以在 IdP 提供的 SAML 元数据中找到这个值。
- 在 Groups,User Email,Username,User Last Name and User First Name 中输入用户详细信息。
在 User Permanent ID 字段中输入用户的永久 ID。此字段是必需的。
注意其他属性可能通过 SAML IdP 提供。这些值必须包含在 Additional Authenticators 字段或 SAML IDP to extra_data 属性映射 字段中。详情请参考这些步骤。
- SAML Assertion Consumer Service (ACS) URL 字段将服务注册为服务提供者(SP),其中包含您配置的每个身份提供程序(IdP)。将此字段留空。保存这个验证方法后,会自动生成它。此字段必须与 IdP 中的 Reply URL 设置匹配。
可选:输入此验证器可以采用的任何其他 身份验证器字段。这些字段不会被验证,并直接传递给验证器。例如,要确保为映射包含 Email, Username, Last Name, First Name 以外的所有 SAML IdP 属性,请输入:
GET_ALL_EXTRA_DATA: true另外,您可以在 SAML IDP 到 extra_data 属性映射字段中包含 SAML IdP 属性 列表。
注意此字段中定义的值覆盖 UI 中提供的专用字段。此处未定义的任何值都不提供给验证器。
在 SAML Service Provider Organization Info 字段中,提供 URL、显示名称和应用程序的名称。
{ "en-US": { "url": "http://www.example.com", "displayname": "Example", "name": "example" } }在 SAML Service Provider Technical contact 字段中,为您的服务提供商提供技术联系人的名称和电子邮件地址。
{ "givenName": "Some User", "emailAddress": "suser@example.com" }在 SAML Service Provider Support Contact 字段中,为您的服务提供商提供支持联系人的名称和电子邮件地址。
{ "givenName": "Some User", "emailAddress": "suser@example.com" }可选:在 SAML 服务提供商额外配置数据 字段中提供额外的配置数据。例如,您可以选择为添加的安全性启用签名请求:
{ "sign_request": True, }此字段等同于 API 中的
SOCIAL_AUTH_SAML_SP_EXTRA。如需更多信息,请参阅 OneLogin 的 SAML Python Toolkit 来了解有关有效的服务提供商额外(SP_EXTRA)参数的信息。注意对 OneLogin SAML Python Toolkit 的引用仅用于格式化示例。OneLogin 文档中的一些配置条目可能不适用于 Ansible Automation Platform。
可选:在 SAML Security Config 字段中提供安全设置。此字段等同于 API 中的
SOCIAL_AUTH_SAML_SECURITY_CONFIG字段。// Indicates whether the <samlp:AuthnRequest> messages sent by this SP // will be signed. [Metadata of the SP will offer this info] "authnRequestsSigned": false, // Indicates a requirement for the <samlp:Response>, <samlp:LogoutRequest> // and <samlp:LogoutResponse> elements received by this SP to be signed. "wantMessagesSigned": false, // Indicates a requirement for the <saml:Assertion> elements received by // this SP to be signed. [Metadata of the SP will offer this info] "wantAssertionsSigned": false, // Authentication context. // Set to false and no AuthContext will be sent in the AuthNRequest, // Set true or don't present this parameter and you will get an AuthContext 'exact' 'urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport' // Set an array with the possible auth context values: array ('urn:oasis:names:tc:SAML:2.0:ac:classes:Password', 'urn:oasis:names:tc:SAML:2.0:ac:classes:X509'), "requestedAuthnContext": true,如需更多信息和附加选项,请参阅 OneLogin 的 SAML Python Toolkit。
可选:在 SAML IDP 到 extra_data 属性映射 字段中,输入值以将 IDP 属性映射到 extra_data 属性。这些值会包括除标准属性(如 Email 或 Username )以外的其他用户信息。例如:
- Department - UserType - Organization有关您可以包含的值的更多信息,请参阅高级 SAML 设置。
重要确保包含所有相关值,以便一切都为您的配置正确映射。或者,您可以在 Additional Authenticator 字段中包含
GET_ALL_EXTRA_DATA: true,以允许映射所有可用的 SAML IdP 属性。- 要在成功登录时自动创建机构、用户和团队,请选择 Create objects。
- 要在创建时启用此验证方法,请选择 Enabled。
- 要在之前从此来源进行身份验证时添加的任何组删除用户,请选择 Remove users。
单击 。
重要您可以在基于 operator 的部署中为 SAML 配置 HTTPS 重定向,以简化用户的登录。有关配置此设置的步骤,请参阅 在 OpenShift Container Platform 上为平台网关启用单点登录(SSO)。
2.5.5.1. 配置透明 SAML 登录 复制链接链接已复制到粘贴板!
要使透明登录正常工作,您必须首先使 IdP 启动的登录正常工作。
流程
-
将 IdP 上的
RelayState设置为 "IdP"。