13.2. 目录用户

13.2.1. Red Hat Enterprise Virtualization 的目录服务支持

在安装 Red Hat Enterprise Virtualization Manager 的过程中,一个内部的管理员用户(admin)会被创建。这个用户可以被用来对环境进行初始的设置以及进行故障排除。为了在 Red Hat Enterprise Virtualization 环境中创建其它用户,需要首先把一个目录服务器附加到 Manager 上。对于 Red Hat Enterprise Virtualization 3.5 以前的环境,使用域管理工具(engine-manage-domains)把一个目录服务器附加到 Manager上,相关信息,请参阅 Red Hat Enterprise Virtualization 管理指南The Domain Management Tool 一节;对于 Red Hat Enterprise Virtualization 3.5 或更新的环境,使用新的通用 LDAP 供应商功能,相关信息,请参阅 Red Hat Enterprise Virtualization 管理指南Configuring a Generic LDAP Provider 一节。
一旦一个目录服务器被附加到 Red Hat Enterprise Virtualization Manager 上后,您就可以通过管理门户把目录服务器上的用户添加到您的虚拟环境中,并为它们分配角色。用户可以通过它们的 User Principal Name (UPN) 被识别,它的格式是 user@domain。另外,您也可以为 Red Hat Enterprise Virtualization Manager 附加多个目录服务器。
Red Hat Enterprise Virtualization 3.6 支持的目录服务:
  • Active Directory
  • Identity Management (IdM)
  • Red Hat Directory Server 9 (RHDS 9)
  • OpenLDAP
您需要保证您的目录服务器有正确的 DNS 记录。它的 DNS 记录必须包括:
  • 目录服务器的反向查找地址的有效指针记录(PTR)。
  • 使用 TCP 端口 389LDAP 的有效服务记录(SRV)。
  • 使用 TCP 端口 88Kerberos 的有效服务记录(SRV)。
  • 使用 UDP 端口 88Kerberos 的有效服务记录(SRV)。
如果这些记录不存在于 DNS 中,您将无法使用 engine-manage-domains 来把这个域添加到 Red Hat Enterprise Virtualization Manager 配置中。
如需了解更多关于安装和配置目录服务器的信息,请参阅目录服务厂商的相关文档:

重要

您需要在目录管理服务器上单独创建一个有权限访问所有用户和组的用户来作为 Red Hat Enterprise Virtualization 的管理员,而不要使用目录服务器本身的管理员作为 Red Hat Enterprise Virtualization 的管理员。

重要

您不能在同一个系统上同时安装 Red Hat Enterprise Virtualization Manager(rhevm)和 IdM(ipa-server)。IdM 和 Red Hat Enterprise Virtualization Manager 所需要的 mod_ssl 软件包不兼容。

重要

如果您使用 Active Directory 作为目录服务,而且需要在创建模板和虚拟机时使用 sysprep,您必须为 Red Hat Enterprise Virtualization 的管理员设置“委派对组织单位的控制(delegation of control)”来进行以下操作:
  • 把一个计算机添加到域中
  • 修改一个组的成员
如需了解更多关于在 Active Directory 中创建用户账户的信息,请参阅 http://technet.microsoft.com/en-us/library/cc732336.aspx.
如需了解更多关于在 Active Directory 中进行委派对组织单位的控制(delegation of control),请参阅 http://technet.microsoft.com/en-us/library/cc732524.aspx

注意

Red Hat Enterprise Virtualization Manager 使用 Kerberos 来和目录服务器进行用户认证。Red Hat Directory Server(RHDS) 不原生支持(native support)Kerberos。如需使用 RHDS 作为目录服务器,您需要保证您的目录服务器在一个有效的 Kerberos 域中是一个服务。请参阅相关的目录服务器文档来进行以下操作:
  • RHDS 配置 memberOf 插件来允许使用组成员功能。您需要把 memberOf 插件的 memberofgroupattr 属性设置为 uniqueMember。在 OpenLDAP 中,memberOf 功能并不被称为“插件(plugin)”,它被称为 "overlay", 您在安装后不需要配置它。
    您可以参阅 Red Hat Directory Server 9.0 Plug-in Guide 来获得更多关于配置 memberOf 插件的信息。
  • 在 Kerberos realm 中把目录服务器定义为服务(格式为 ldap/hostname@REALMNAME)。您需要使用目录服务器的全局域名(FQDN)替换 hostname,使用全局 Kerberos realm 名替换 REALMNAME。Kerberos realm 名必须是大写。
  • 在 Kerberos realm 中为目录服务器产生一个 keytab 文件。keytab 文件包括了 Kerberos principal 以及和它们相关的加密密钥。这些密钥被目录服务器用来和 Kerberos realm 进行验证。
    请参阅 Kerberos principle 的相关文档来获得更多关于生成 keytab 文件的信息。
  • 在目录服务器上安装 keytab 文件,然后配置 RHDS 来识别 keytab 文件,并接受使用 GSSAPI 进行的 Kerberos 验证。
    请参阅 Red Hat Directory Server 9.0 Administration Guide 来获得更多关于配置 RHDS 来使用外部 keytab 文件的信息。
  • 要测试您的目录服务器配置,您可以使用 kinit 命令来验证在 Kerberos realm 中定义的用户。一旦验证成功后,您可以运行 ldapsearch 命令在目录服务器上进行查询。使用 -Y GSSAPI 参数来指定使用 Kerberos 进行验证。

13.2.2. 配置通用的 LDAP 供应商

可以配置一个通用的 LDAP 供应商来提供用户验证和授权服务。这个新功能使用 LDAP 协议访问 LDAP 服务器,并可以对它进行自定义。要配置一个通用的 LDAP 供应商,需要修改身份验证扩展的配置文件、两个扩展值向的 LDAP 配置文件。

注意

如需了解更多为管理门户和用户门户的单点登录设置 LDAP 和 Kerberos 的信息,请参阅 第 13.2.3.1 节 “为 LDAP 和 Kerberos 配置单点登录”

过程 13.1. 配置通用的 LDAP 供应商

  1. 在 Red Hat Enterprise Virtualization Manager 中安装 LDAP 扩展软件包:
    # yum install ovirt-engine-extension-aaa-ldap
  2. 把 LDAP 配置模板文件复制到 /etc/ovirt-engine 目录中。其中包括了 Active Directory(ad)和其它目录服务类型(simple)的模板文件。这个示例使用简单配置模板。
    # cp -r /usr/share/ovirt-engine-extension-aaa-ldap/examples/simple/. /etc/ovirt-engine
  3. 编辑 LDAP 属性配置文件,取消注释一个 LDAP 服务器类型并更新域和密码项的内容。
    #  vi /etc/ovirt-engine/aaa/profile1.properties

    例 13.1. 配置档案实例:LDAP 服务器部分

    #
    # Select one
    #
    include = <openldap.properties>
    #include = <389ds.properties>
    #include = <rhds.properties>
    #include = <ipa.properties>
    #include = <iplanet.properties>
    #include = <rfc2307.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 证书,使用它来创建一个公共的 keystore 文件。取消注释以下行,指定到公共 keystore 文件的完全路径以及访问这个文件的密码。

    注意

    如需了解更多与创建公共 keystore 文件相关的信息,请参阅 第 C.2 节 “在 Manager 和一个 LDAP 服务器间设置 SSL 或 TLS 连接”

    例 13.2. 配置档案实例:keystore 部分

    # Create keystore, import certificate chain and uncomment
    # if using tls.
    pool.default.ssl.startTLS = true
    pool.default.ssl.truststore.file = /full/path/to/myrootca.jks
    pool.default.ssl.truststore.password = changeit
  4. 检查验证配置文件。profile 名在管理门户和用户门户的登录界面中可见。配置 profile 的位置必须和 LDAP 配置文件的位置相匹配。所有项都可以使用默认值。
    # vi /etc/ovirt-engine/extensions.d/profile1-authn.properties

    例 13.3. 验证配置文件的示例

    ovirt.engine.extension.name = profile1-authn
    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.AuthnExtension
    ovirt.engine.extension.provides = org.ovirt.engine.api.extensions.aaa.Authn
    ovirt.engine.aaa.authn.profile.name = profile1
    ovirt.engine.aaa.authn.authz.plugin = profile1-authz
    config.profile.file.1 = ../aaa/profile1.properties
  5. 检查授权配置文件。这个配置集的配置必须和 LDAP 配置文件的位置相匹配。所有项都可以使用默认值。
    # vi /etc/ovirt-engine/extensions.d/profile1-authz.properties

    例 13.4. 授权配置文件的示例

    ovirt.engine.extension.name = profile1-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/profile1.properties
  6. 为配置文件设置正确的所有者权限和访问权限:
    # chown ovirt:ovirt /etc/ovirt-engine/aaa/profile1.properties
    # chmod 600 /etc/ovirt-engine/aaa/profile1.properties
  7. 重新启动引擎服务。
    # service ovirt-engine restart
  8. 在管理门户和用户门户的登录页中包括了刚创建的 ldap1 profile。如需了解更多与为 LDAP 服务器中的用户分配相关权限(如登录到用户门户的权限)的信息,请参阅 Red Hat Enterprise Virtualization Administration GuideRed Hat Enterprise Virtualization Manager User Tasks 一节。

注意

如需了解更多信息,请参阅 LDAP 验证和授权扩展的 README 文件(/usr/share/doc/ovirt-engine-extension-aaa-ldap-version)。

13.2.3. 管理门户和用户门户的单点登录

Red Hat Enterprise Virtualization 3.5 以及更高的版本支持到管理门户和用户门户的单点登录功能。在启用这个功能时,用户可以使用从单点登录机制(如 Kerberos)所获得的凭证登录到用户门户或管理门户。管理员需要设定使用哪一种单点登录机制。
如需了解使用 Kerberos 实现管理门户和用户门户的单点登录功能的信息,请参阅 第 13.2.3.1 节 “为 LDAP 和 Kerberos 配置单点登录”

注意

如果到用户门户的单独登录功能被启用,则到虚拟机的单点登录功能将无法实现。这是因为,用户门户在启用了单独登录功能后,将不需要接受用户密码,因此用户的密码将无法在登录到虚拟机时被验证。

13.2.3.1. 为 LDAP 和 Kerberos 配置单点登录

这个示例假设了以下情况:
  • 存在的 KDC(Key Distribution Center,密钥分配中心)服务器使用 MIT 版的 Kerberos 5。
  • 您具有 KDC 服务器的管理权限。
  • Red Hat Enterprise Virtualization Manager 和用户的机器上安装了 Kerberos 客户端。
  • kadmin 工具程序可以被用来创建 Kerberos 服务主体(principal)和 keytab 文件。
这个过程会涉及到以下组件:

在 KDC 服务器上

  • 为 Red Hat Enterprise Virtualization Manager 上的 Apache 服务创建一个服务主体(principal)和一个 keytab 文件。

在 Red Hat Enterprise Virtualization Manager 上

  • 安装 Manager 的验证和授权扩展软件包,以及 Apache Kerberos 验证模块。
  • 配置扩展文件。

过程 13.2. 为 Apache 服务配置 Kerberos

  1. 在 KDC 服务器上,使用 kadmin 为 Red Hat Enterprise Virtualization Manager 上的 Apache 服务创建一个服务主体。这个服务主体是 KDC 指代 Apache 服务的 ID。
    # kadmin
    kadmin> addprinc -randkey HTTP/fqdn-of-rhevm@REALM.COM
  2. 为 Apache 服务产生一个 keytab 文件。keytab 文件保存了共享的密钥。
    kadmin> ktadd -k /tmp/http.keytab HTTP/fqdn-of-rhevm@REALM.COM
    kadmin> quit
  3. keytab 文件从 KDC 服务器复制到 Red Hat Enterprise Virtualization Manager:
    # scp /tmp/http.keytab root@rhevm.example.com:/etc/httpd

过程 13.3. 配置到用户门户和管理门户的单点登录

  1. 在 Red Hat Enterprise Virtualization Manager 上,设置正确的 keytab 所有者权限和访问权限:
    # chown apache /etc/httpd/http.keytab
    # chmod 400 /etc/httpd/http.keytab
  2. 安装验证扩展软件包、LDAP 扩展软件包和 mod_auth_kerb 验证模块:
    # yum install ovirt-engine-extension-aaa-misc ovirt-engine-extension-aaa-ldap mod_auth_kerb
  3. 把 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
  4. 为 Apache 创建一个 /etc/httpd/conf.d 目录的软链接来使用 SSO 配置文件:
    # ln -s /etc/ovirt-engine/aaa/ovirt-sso.conf /etc/httpd/conf.d
  5. 编辑验证方法文件来使 Apache 使用 Kerberos 进行验证:
    # vi /etc/ovirt-engine/aaa/ovirt-sso.conf

    例 13.5. 验证方法文件的示例

    <LocationMatch ^(/ovirt-engine/(webadmin|userportal|api)|/api)>
        RewriteEngine on
        RewriteCond %{LA-U:REMOTE_USER} ^(.*)$
        RewriteRule ^(.*)$ - [L,P,E=REMOTE_USER:%1]
        RequestHeader set X-Remote-User %{REMOTE_USER}s
    
        AuthType Kerberos
        AuthName "Kerberos Login"
        Krb5Keytab /etc/httpd/http.keytab
        KrbAuthRealms REALM.COM
        Require valid-user
    </LocationMatch>
  6. 编辑 LDAP 属性配置文件,取消注释一个 LDAP 服务器类型并更新域和密码项的内容:
    #  vi /etc/ovirt-engine/aaa/profile1.properties

    例 13.6. 配置档案实例:LDAP 服务器部分

    #
    # Select one
    #
    include = <openldap.properties>
    #include = <389ds.properties>
    #include = <rhds.properties>
    #include = <ipa.properties>
    #include = <iplanet.properties>
    #include = <rfc2307.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 证书,使用它来创建一个公共的 keystore 文件。取消注释以下行,指定到公共 keystore 文件的完全路径以及访问这个文件的密码。

    注意

    如需了解更多与创建公共 keystore 文件相关的信息,请参阅 第 C.2 节 “在 Manager 和一个 LDAP 服务器间设置 SSL 或 TLS 连接”

    例 13.7. 配置档案实例: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 = changeit
  7. 检查验证配置文件。profile 名在管理门户和用户门户的登录界面中可见。配置 profile 的位置必须和 LDAP 配置文件的位置相匹配。所有项都可以使用默认值。
    # vi /etc/ovirt-engine/extensions.d/profile1-http-authn.properties

    例 13.8. 验证配置文件的示例

    ovirt.engine.extension.name = profile1-authn
    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.AuthnExtension
    ovirt.engine.extension.provides = org.ovirt.engine.api.extensions.aaa.Authn
    ovirt.engine.aaa.authn.profile.name = profile1-http
    ovirt.engine.aaa.authn.authz.plugin = profile1-authz
    ovirt.engine.aaa.authn.mapping.plugin = http-mapping
    config.artifact.name = HEADER
    config.artifact.arg = X-Remote-User
  8. 检查授权配置文件。这个配置集的配置必须和 LDAP 配置文件的位置相匹配。所有项都可以使用默认值。
    #  vi /etc/ovirt-engine/extensions.d/profile1-authz.properties

    例 13.9. 授权配置文件的示例

    ovirt.engine.extension.name = profile1-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/profile1.properties
  9. 为配置文件设置正确的所有者权限和访问权限:
    # chown ovirt:ovirt /etc/ovirt-engine/aaa/profile1.properties
    # chmod 600 /etc/ovirt-engine/aaa/profile1.properties
  10. 重启 Apache 服务和引擎服务:
    # service httpd restart
    # service ovirt-engine restart