apache中的多个身份验证流

apache中的多个身份验证流,apache,Apache,我正在尝试将Apache配置为使用kerberos或客户端证书对HTTP请求进行身份验证 以下配置能够使用上述任何一种方式对请求进行身份验证。但是,它会对这两个对象执行LDAP查找。如果通过kerberos进行身份验证,我想只需要LDAP查找。对于客户端证书身份验证,我想基于证书中的另一个属性执行一些过滤,然后在Authorize Samaccountname头中使用CN值。我可以通过使用SSL\u CLIENT\u S\u DN\u CN获取标题中的CN,因此应该能够告诉它使用存在的任何一个

我正在尝试将Apache配置为使用kerberos或客户端证书对HTTP请求进行身份验证

以下配置能够使用上述任何一种方式对请求进行身份验证。但是,它会对这两个对象执行LDAP查找。如果通过kerberos进行身份验证,我想只需要LDAP查找。对于客户端证书身份验证,我想基于证书中的另一个属性执行一些过滤,然后在
Authorize Samaccountname
头中使用CN值。我可以通过使用
SSL\u CLIENT\u S\u DN\u CN
获取标题中的CN,因此应该能够告诉它使用存在的任何一个

<VirtualHost *:443>
  ServerName subdomain.example.com
  
  DocumentRoot "/var/www/html"

  <Directory "/var/www/html">
    AllowOverride None
    Require all granted
  </Directory>

  <Location "/">
    <LimitExcept OPTIONS>
        Require ldap-filter objectclass=user
    </LimitExcept>
    AuthType Kerberos
    AuthName "Kerberos Login"
    SSLVerifyClient optional
    SSLVerifyDepth 10
    SSLUserName SSL_CLIENT_S_DN_CN
    SSLRequireSSL
    AuthLDAPURL "ldaps://example.com/dc=EXAMPLE,dc=COM?sAMAccountName"
    AuthLDAPBindDN svc-ldap
    AuthLDAPBindPassword yupyupyup
    ProxyPass http://localhost:8080/ timeout=600
    ProxyPassReverse http://localhost:8080/
  </Location>

  ## Request header rules
  RequestHeader set Authorize-Samaccountname %{AUTHORIZE_SAMACCOUNTNAME}e

  ## Kerberos directives
  KrbMethodNegotiate on
  KrbMethodK5Passwd on
  KrbAuthoritative on
  Krb5Keytab /usr/local/etc/svc-t-kerberos.keytab
  KrbLocalUserMapping on
  KrbVerifyKDC on
  KrbServiceName HTTP/svc-t-kerberos
  KrbSaveCredentials off

  ## SSL directives
  SSLEngine on
  SSLCertificateFile      "/etc/pki/CA/certs/host.example.com.cer"
  SSLCertificateKeyFile   "/etc/pki/CA/certs/host.example.com.key"
  SSLCertificateChainFile "/etc/pki/CA/certs/intermediate.cer"
  SSLCACertificatePath    "/etc/pki/tls/certs"
  SSLCACertificateFile    "/etc/pki/tls/certs/ca-bundle.crt"

</VirtualHost>

ServerName subdomain.example.com
DocumentRoot“/var/www/html”
不允许超限
要求所有授权
需要ldap筛选器objectclass=user
身份验证类型Kerberos
AuthName“Kerberos登录”
SSLVerifyClient可选
SSLVerifyDepth 10
SSLUserName SSL\u客户端\u S\u DN\u CN
SSLRequireSSL
AuthLDAPURL“ldaps://example.com/dc=EXAMPLE,dc=COM?sAMAccountName“
AuthLDAPBindDN svc ldap
authldappindpassword yupyupyup
ProxyPasshttp://localhost:8080/ 超时=600
ProxyPassReversehttp://localhost:8080/
##请求头规则
RequestHeader集合Authorize Samaccountname%{Authorize_Samaccountname}e
##Kerberos指令
KrbMethodNegotiate on
KrbMethodK5Passwd打开
Krbautoritative on
Krb5Keytab/usr/local/etc/svc-t-kerberos.keytab
上的KrbLocalUserMapping
KrbVerifyKDC on
KrbServiceName HTTP/svc-t-kerberos
KrbSaveCredentials关闭
##SSL指令
斯伦金安
SSLCertificateFile“/etc/pki/CA/certs/host.example.com.cer”
SSLCertificateKeyFile“/etc/pki/CA/certs/host.example.com.key”
SSLCertificateChainFile“/etc/pki/CA/certs/intermediate.cer”
SSLCACertificatePath“/etc/pki/tls/certs”
SSLCACertificateFile“/etc/pki/tls/certs/ca bundle.crt”

如何绕过LDAP查找,而是在使用客户端证书时检查证书字段值?

如果指定多个
Require
语句,则可能需要其中任何一个语句(取决于检查是否失败或是中性)。在我的情况下,我可以使用以下方法:

Require ldap-filter objectclass=user
Require ssl-verify-client
这仍然执行LDAP查找,但如果SSL要求通过,它仍然允许用户通过

您可以查看如何使用
RequireAny
RequireAll
来满足更复杂的需求,尽管它们不能与
LimitExcept
结合使用。我假设您可以使用
Require method OPTIONS
,但由于上述内容满足我的需要,因此没有进一步研究