15.4. 为单点登录配置 LDAP 和 Kerberos
单点登录允许用户登录开发人员门户或管理门户,而无需重新输入密码。身份验证凭据从 Kerberos 服务器获取。要为管理门户和虚拟机门户配置单点登录,您需要配置两个扩展:
ovirt-engine-extension-aaa-misc
和 ovirt-engine-extension-aaa-ldap
; 和两个 Apache 模块: mod_auth_gssapi
和 mod_session
。您可以配置不涉及 Kerberos 的单点登录,但这超出了本文档的范围。
注意
如果启用了开发人员门户单点登录,则无法对虚拟机进行单点登录。启用单点登录后,开发人员门户不需要接受密码,因此无法委派密码以登录虚拟机。
这个示例假设如下:
- 现有密钥分发中心(KDC)服务器使用 MIT 版本的 Kerberos 5。
- 您有对 KDC 服务器的管理权限。
- Kerberos 客户端安装在 Red Hat Virtualization Manager 和用户机器上。
- kadmin 实用程序用于创建 Kerberos 服务主体和
keytab
文件。
这个过程涉及以下组件:
在 KDC 服务器上
- 在 Red Hat Virtualization Manager 上为 Apache 服务创建服务主体和
keytab
文件。
在 Red Hat Virtualization Manager 中
- 安装身份验证和授权扩展软件包和 Apache Kerberos 身份验证模块。
- 配置扩展文件。
过程 15.5. 为 Apache 服务配置 Kerberos
- 在 KDC 服务器上,使用 kadmin 工具为 Red Hat Virtualization Manager 上的 Apache 服务创建服务主体。服务主体是 Apache 服务的 KDC 的引用 ID。
# kadmin kadmin> addprinc -randkey HTTP/fqdn-of-rhevm@REALM.COM
- 为 Apache 服务生成
keytab
文件。keytab
文件存储共享 secret 密钥。kadmin> ktadd -k /tmp/http.keytab HTTP/fqdn-of-rhevm@REALM.COM
kadmin> quit
- 将
keytab
文件从 KDC 服务器复制到 Red Hat Virtualization Manager:# scp /tmp/http.keytab root@rhevm.example.com:/etc/httpd
过程 15.6. 为客户门户网站或管理门户配置单点登录
- 在 Red Hat Virtualization Manager 中,确保 keytab 的所有权和权限适当:
# chown apache /etc/httpd/http.keytab
# chmod 400 /etc/httpd/http.keytab
- 安装身份验证扩展软件包、LDAP 扩展软件包和
mod_auth_gssapi
和mod_session
Apache 模块:# yum install ovirt-engine-extension-aaa-misc ovirt-engine-extension-aaa-ldap mod_auth_gssapi mod_session
- 将 SSO 配置模板文件复制到
/etc/ovirt-engine
目录中。模板文件可用于 Active Directory (ad-sso
)和其他目录类型(simple-sso
)。本例使用简单的 SSO 配置模板。# cp -r /usr/share/ovirt-engine-extension-aaa-ldap/examples/simple-sso/. /etc/ovirt-engine
- 将
ovirt-sso.conf
移到 Apache 配置目录中:# mv /etc/ovirt-engine/aaa/ovirt-sso.conf /etc/httpd/conf.d
- 检查身份验证方法文件。您不需要编辑此文件,因为域会自动从
keytab
文件中获取。# vi /etc/httpd/conf.d/ovirt-sso.conf
例 15.5. 验证方法文件示例
<LocationMatch ^/ovirt-engine/sso/(interactive-login-negotiate|oauth/token-http-auth)|^/ovirt-engine/api> <If "req('Authorization') !~ /^(Bearer|Basic)/i"> RewriteEngine on RewriteCond %{LA-U:REMOTE_USER} ^(.*)$ RewriteRule ^(.*)$ - [L,NS,P,E=REMOTE_USER:%1] RequestHeader set X-Remote-User %{REMOTE_USER}s AuthType GSSAPI AuthName "Kerberos Login" # Modify to match installation GssapiCredStore keytab:/etc/httpd/http.keytab GssapiUseSessions On Session On SessionCookieName ovirt_gssapi_session path=/private;httponly;secure; Require valid-user ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0; url=/ovirt-engine/sso/login-unauthorized\"/><body><a href=\"/ovirt-engine/sso/login-unauthorized\">Here</a></body></html>" </If> </LocationMatch>
- 重命名配置文件,使其与管理门户和客户门户网站登录页面中用户可见的配置集名称匹配:
# mv /etc/ovirt-engine/aaa/profile1.properties /etc/ovirt-engine/aaa/example.properties
# mv /etc/ovirt-engine/extensions.d/profile1-http-authn.properties /etc/ovirt-engine/extensions.d/example-http-authn.properties
# mv /etc/ovirt-engine/extensions.d/profile1-http-mapping.properties /etc/ovirt-engine/extensions.d/example-http-mapping.properties
# mv /etc/ovirt-engine/extensions.d/profile1-authz.properties /etc/ovirt-engine/extensions.d/example-authz.properties
- 通过取消注释 LDAP 服务器类型并更新 domain 和 password 字段来编辑 LDAP 属性配置文件:
# vi /etc/ovirt-engine/aaa/example.properties
例 15.6. 配置文件示例:LDAP 服务器部分
# Select one include = <openldap.properties> #include = <389ds.properties> #include = <rhds.properties> #include = <ipa.properties> #include = <iplanet.properties> #include = <rfc2307-389ds.properties> #include = <rfc2307-rhds.properties> #include = <rfc2307-openldap.properties> #include = <rfc2307-edir.properties> #include = <rfc2307-generic.properties> # Server # vars.server = ldap1.company.com # Search user and its password. # vars.user = uid=search,cn=users,cn=accounts,dc=company,dc=com vars.password = 123456 pool.default.serverset.single.server = ${global:vars.server} pool.default.auth.simple.bindDN = ${global:vars.user} pool.default.auth.simple.password = ${global:vars.password}
要使用 TLS 或 SSL 协议与 LDAP 服务器交互,请获取 LDAP 服务器的 root CA 证书,并使用它来创建公共密钥存储文件。取消注释以下行,并指定用于访问该文件的公共密钥存储文件的完整路径。注意有关创建公共密钥存储文件的更多信息,请参阅 第 D.2 节 “在 Manager 和 LDAP 服务器之间设置 SSL 或 TLS 连接”。例 15.7. profile: keystore 部分示例
# Create keystore, import certificate chain and uncomment # if using ssl/tls. pool.default.ssl.startTLS = true pool.default.ssl.truststore.file = /full/path/to/myrootca.jks pool.default.ssl.truststore.password = password
- 查看身份验证配置文件。该配置集名称对管理门户中的用户可见,开发人员门户登录页面由
ovirt.engine.aaa.authn.profile.name
定义。配置配置文件位置必须与 LDAP 配置文件位置匹配。所有字段都可以保留为默认值。# vi /etc/ovirt-engine/extensions.d/example-http-authn.properties
例 15.8. 身份验证配置文件示例
ovirt.engine.extension.name = example-http-authn ovirt.engine.extension.bindings.method = jbossmodule ovirt.engine.extension.binding.jbossmodule.module = org.ovirt.engine-extensions.aaa.misc ovirt.engine.extension.binding.jbossmodule.class = org.ovirt.engineextensions.aaa.misc.http.AuthnExtension ovirt.engine.extension.provides = org.ovirt.engine.api.extensions.aaa.Authn ovirt.engine.aaa.authn.profile.name = example-http ovirt.engine.aaa.authn.authz.plugin = example-authz ovirt.engine.aaa.authn.mapping.plugin = example-http-mapping config.artifact.name = HEADER config.artifact.arg = X-Remote-User
- 检查授权配置文件。配置配置文件位置必须与 LDAP 配置文件位置匹配。所有字段都可以保留为默认值。
# vi /etc/ovirt-engine/extensions.d/example-authz.properties
例 15.9. 授权配置文件示例
ovirt.engine.extension.name = example-authz ovirt.engine.extension.bindings.method = jbossmodule ovirt.engine.extension.binding.jbossmodule.module = org.ovirt.engine-extensions.aaa.ldap ovirt.engine.extension.binding.jbossmodule.class = org.ovirt.engineextensions.aaa.ldap.AuthzExtension ovirt.engine.extension.provides = org.ovirt.engine.api.extensions.aaa.Authz config.profile.file.1 = ../aaa/example.properties
- 查看身份验证映射文件。配置配置文件位置必须与 LDAP 配置文件位置匹配。配置配置集扩展名称必须与身份验证配置文件中的
ovirt.engine.aaa.authn.mapping.plugin
值匹配。所有字段都可以保留为默认值。# vi /etc/ovirt-engine/extensions.d/example-http-mapping.properties
例 15.10. 身份验证映射配置文件示例
ovirt.engine.extension.name = example-http-mapping ovirt.engine.extension.bindings.method = jbossmodule ovirt.engine.extension.binding.jbossmodule.module = org.ovirt.engine-extensions.aaa.misc ovirt.engine.extension.binding.jbossmodule.class = org.ovirt.engineextensions.aaa.misc.mapping.MappingExtension ovirt.engine.extension.provides = org.ovirt.engine.api.extensions.aaa.Mapping config.mapAuthRecord.type = regex config.mapAuthRecord.regex.mustMatch = true config.mapAuthRecord.regex.pattern = ^(?<user>.*?)((\\\\(?<at>@)(?<suffix>.*?)@.*)|(?<realm>@.*))$ config.mapAuthRecord.regex.replacement = ${user}${at}${suffix}
- 确保配置文件的所有权和权限适当:
# chown ovirt:ovirt /etc/ovirt-engine/aaa/example.properties
# chown ovirt:ovirt /etc/ovirt-engine/extensions.d/example-http-authn.properties
# chown ovirt:ovirt /etc/ovirt-engine/extensions.d/example-http-mapping.properties
# chown ovirt:ovirt /etc/ovirt-engine/extensions.d/example-authz.properties
# chmod 600 /etc/ovirt-engine/aaa/example.properties
# chmod 640 /etc/ovirt-engine/extensions.d/example-http-authn.properties
# chmod 640 /etc/ovirt-engine/extensions.d/example-http-mapping.properties
# chmod 640 /etc/ovirt-engine/extensions.d/example-authz.properties
- 重启 Apache 服务和
ovirt-engine
服务:# systemctl restart httpd.service
# systemctl restart ovirt-engine.service