我需要使用 Kerberos 身份验证通过 Active Directory 为 Ruby on Rail 应用程序设置身份验证。
一些技术信息:
- 我正在使用 Apache
- 已安装mod_auth_kerb
- 在httpd配置文件我补充道LoadModule auth_kerb_module 模块/mod_auth_kerb.so
在/etc/krb5.conf我添加了以下配置
[logging] default = FILE:/var/log/krb5libs.log kdc = FILE:/var/log/krb5kdc.log admin_server = FILE:/var/log/kadmind.log [libdefaults] default_realm = EU.ORG.COM dns_lookup_realm = false dns_lookup_kdc = false ticket_lifetime = 24h forwardable = yes [realms] EU.ORG.COM = { kdc = eudc05.eu.org.com:88 admin_server = eudc05.eu.org.com:749 default_domain = eu.org.com } [domain_realm] .eu.org.com = EU.ORG.COM eu.org.com = EU.ORG.COM [appdefaults] pam = { debug = true ticket_lifetime = 36000 renew_lifetime = 36000 forwardable = true krb4_convert = false }
当我测试时kinit 有效用户并输入密码则认证成功。
klist 返回:
Ticket cache: FILE:/tmp/krb5cc_600 Default principal: [email protected] Valid starting Expires Service principal 02/08/13 13:46:40 02/08/13 23:46:47 krbtgt/[email protected] renew until 02/09/13 13:46:40 Kerberos 4 ticket cache: /tmp/tkt600 klist: You have no tickets cached
在应用程序 Apache 配置中我添加了
IfModule mod_auth_kerb.c> Location /winlogin> AuthType Kerberos AuthName "Kerberos Loginsss" KrbMethodNegotiate off KrbAuthoritative on KrbVerifyKDC off KrbAuthRealms EU.ORG.COM Krb5Keytab /home/crmdata/httpd/apache.keytab KrbSaveCredentials off Require valid-user </Location> </IfModule>
我重新启动了 apache
现在进行一些测试:
当我尝试从 Win7 访问应用程序时,弹出消息框,其中包含以下文本:
Warning: This server is requesting that your username and password be sent in an insecure manner (basic authentification without a secure connection)
当我输入有效的凭证时,我的应用程序就会成功打开,并且一切正常运行。
问题:
向用户弹出这样的窗口可以吗?如果我使用 NTLM 身份验证,则不会弹出这样的窗口。我检查了 IE Internet 选项,发现已选中“启用集成 Windows 身份验证”。
为什么 IE 尝试将用户名和密码发送给应用程序 apache?如果我理解正确,那么 Windows 自身必须使用 Kerberos 协议通过 Active Directory 进行身份验证。
当我尝试从 Win7 访问应用程序时,我输入不正确弹出消息框的凭据
- 应用程序说身份验证失败(没问题)
在 apache 错误日志中我看到:
[error] [client 192.168.56.1] krb5_get_init_creds_password() failed: Client not found in Kerberos database
但是现在我无法输入有效的凭据,只有重新启动 IE 时才能再次弹出框。
我的 Kerberos 设置可能存在哪些错误或缺失?
我读到一些博客文章说可能需要在 Active Directory 端做一些事情。具体怎么做?
答案1
您需要KrbMethodNegotiate on
。
如果没有它,http 客户端实际上会向 apache 执行 auth-basic,而 apache 会根据 kdc 测试密码。
此外,为了安全起见,您确实应该设置KrbVerifyKDC on
。