1.7. 为 Apache HTTP web 服务器配置 Kerberos 验证

要在 Apache HTTP web 服务器中执行 Kerberos 身份验证,RHEL 9 使用 mod_auth_gssapi Apache 模块。Generic Security Services API(GSSAPI)是请求使用安全库(如 Kerberos)的应用程序的接口。gssproxy 服务允许对 httpd 服务器实施特权分离,从安全的角度来看,这优化了此过程。

注意

mod_auth_gssapi 模块取代了已删除的 mod_auth_kerb 模块。

先决条件

  • 已安装了 httpd, mod_auth_gssapigssproxy 软件包。
  • Apache Web 服务器已设置,并且 httpd 服务在运行。

1.7.1. 在 IdM 环境中设置 GSS-Proxy

这个流程描述了如何设置 GSS-Proxy ,以便在 Apache HTTP Web 服务器中执行 Kerberos 身份验证。

流程

  1. 通过创建服务主体来启用对 HTTP/<SERVER_NAME>@realm 主体的keytab文件的访问:

    # ipa service-add HTTP/<SERVER_NAME>
  2. 检索存储在/etc/gssproxy/http.keytab文件中的主体的keytab

    # ipa-getkeytab -s $(awk '/^server =/ {print $3}' /etc/ipa/default.conf) -k /etc/gssproxy/http.keytab -p HTTP/$(hostname -f)

    此步骤将权限设置为 400,因此只有 root 用户有权访问 keytab 文件。apache 用户无法访问。

  3. 使用以下内容创建 /etc/gssproxy/80-httpd.conf 文件:

    [service/HTTP]
      mechs = krb5
      cred_store = keytab:/etc/gssproxy/http.keytab
      cred_store = ccache:/var/lib/gssproxy/clients/krb5cc_%U
      euid = apache
  4. 重启并启用 gssproxy 服务:

    # systemctl restart gssproxy.service
    # systemctl enable gssproxy.service

其它资源

  • gssproxy (8) 手册页
  • gssproxy-mech(8)手册页
  • gssproxy.conf (5) 手册页

1.7.2. 为 Apache HTTP Web 服务器共享的目录配置 Kerberos 身份验证

这个过程描述了如何为 /var/www/html/private/ 目录配置 Kerberos 身份验证。

先决条件

  • gssproxy 服务已配置并在运行。

流程

  1. 配置 mod_auth_gssapi模块来保护 /var/www/html/private/目录:

    <Location /var/www/html/private>
      AuthType GSSAPI
      AuthName "GSSAPI Login"
      Require valid-user
    </Location>
  2. 创建系统单元配置置入文件:

    # systemctl edit httpd.service
  3. 在系统置入文件中添加以下参数:

    [Service]
    Environment=GSS_USE_PROXY=1
  4. 重新载入systemd配置:

    # systemctl daemon-reload
  5. 重启httpd服务:

    # systemctl restart httpd.service

验证步骤

  1. 获取Kerberos ticket:

    # kinit
  2. 在浏览器中打开到受保护目录的URL。