Apache 使用AuthType摘要跨子域对用户进行一次身份验证的示例?

Apache 使用AuthType摘要跨子域对用户进行一次身份验证的示例?,apache,authentication,subdomain,single-sign-on,digest,Apache,Authentication,Subdomain,Single Sign On,Digest,我有一个域名,它将被一小群私人用户访问。所以我想通过身份验证来控制访问 域中安装了一组应用程序,每个应用程序都有自己的子域。例如:domain.com、app1.domain.com、app2.domain.com、app3.domain.com 我希望有一个单一的登录解决方案,这样他们就不必为每个应用程序进行身份验证。此外,应用程序是用不同的语言(PHP、Python和Perl)编写的,因此通过Apache模块对用户进行身份验证非常理想 我不太了解身份验证,但它似乎是一个很好的解决方案。我已经

我有一个域名,它将被一小群私人用户访问。所以我想通过身份验证来控制访问

域中安装了一组应用程序,每个应用程序都有自己的子域。例如:domain.com、app1.domain.com、app2.domain.com、app3.domain.com

我希望有一个单一的登录解决方案,这样他们就不必为每个应用程序进行身份验证。此外,应用程序是用不同的语言(PHP、Python和Perl)编写的,因此通过Apache模块对用户进行身份验证非常理想

我不太了解身份验证,但它似乎是一个很好的解决方案。我已经使用
htdigest
创建了我的用户。我已经配置了我的域和子域(见下文)

如果我进入域或任何子域,它将提示输入用户名和密码。如果我输入正确的用户名和密码,它将对我进行身份验证,页面将加载。但是,如果我转到另一个子域,它会要求我再次输入用户名和密码。如果我输入相同的用户名和密码,它将工作

密码文件正常,身份验证正常,但问题似乎在于
AuthDigestDomain
的配置

我搜索了整个网络,以找到一个在多个域上使用摘要身份验证的示例,但我找不到一个解决我的问题的具体示例

我希望这里有人能帮忙。我是否在每个
目录中放置相同的身份验证信息?我应该使用
目录
还是
位置
还是
文件
?我一起错过了什么吗

提前谢谢

下面是我在domain.com上的Apache配置示例:

<Directory /var/www>
  AuthType Digest
  AuthName "realm"
  AuthDigestAlgorithm MD5
  AuthDigestDomain / http://domain.com/ http://app1.domain.com/ http://app2.domain.com/ http://app3.domain.com/
  AuthDigestNcCheck Off
  AuthDigestNonceLifetime 0
  AuthDigestQop auth
  AuthDigestProvider file
  AuthUserFile /etc/apache2/.htpasswd-digest
  AuthGroupFile /dev/null
  Require valid-user
</Directory>
<Directory /var/lib/app1>
  AuthType Digest
  AuthName "realm"
  AuthDigestAlgorithm MD5
  AuthDigestDomain / http://domain.com/ http://app1.domain.com/ http://app2.domain.com/ http://app3.domain.com/
  AuthDigestNcCheck Off
  AuthDigestNonceLifetime 0
  AuthDigestQop auth
  AuthDigestProvider file
  AuthUserFile /etc/apache2/.htpasswd-digest
  AuthGroupFile /dev/null
  Require valid-user
</Directory>

AuthType摘要
AuthName“领域”
算法MD5
AuthDigestDomain/http://domain.com/ http://app1.domain.com/ http://app2.domain.com/ http://app3.domain.com/
授权检查
AuthDigestNonceLifetime 0
authqop-auth
AuthDigestProvider文件
AuthUserFile/etc/apache2/.htpasswd摘要
AuthGroupFile/dev/null
需要有效用户
下面是app1.domain.com的一个示例:

<Directory /var/www>
  AuthType Digest
  AuthName "realm"
  AuthDigestAlgorithm MD5
  AuthDigestDomain / http://domain.com/ http://app1.domain.com/ http://app2.domain.com/ http://app3.domain.com/
  AuthDigestNcCheck Off
  AuthDigestNonceLifetime 0
  AuthDigestQop auth
  AuthDigestProvider file
  AuthUserFile /etc/apache2/.htpasswd-digest
  AuthGroupFile /dev/null
  Require valid-user
</Directory>
<Directory /var/lib/app1>
  AuthType Digest
  AuthName "realm"
  AuthDigestAlgorithm MD5
  AuthDigestDomain / http://domain.com/ http://app1.domain.com/ http://app2.domain.com/ http://app3.domain.com/
  AuthDigestNcCheck Off
  AuthDigestNonceLifetime 0
  AuthDigestQop auth
  AuthDigestProvider file
  AuthUserFile /etc/apache2/.htpasswd-digest
  AuthGroupFile /dev/null
  Require valid-user
</Directory>

AuthType摘要
AuthName“领域”
算法MD5
AuthDigestDomain/http://domain.com/ http://app1.domain.com/ http://app2.domain.com/ http://app3.domain.com/
授权检查
AuthDigestNonceLifetime 0
authqop-auth
AuthDigestProvider文件
AuthUserFile/etc/apache2/.htpasswd摘要
AuthGroupFile/dev/null
需要有效用户
更让人困惑的是,这在使用IE6时有效,但在使用Firefox或Chrome时无效。是客户端没有正确发送身份验证,还是服务器没有发送正确的凭据


我还使用PHP阅读和编写了身份验证头,以确保请求/响应质询是正确的。这根本没用

我自己也没有这样的经验。但我只是看了一下,发现:

AuthDigestNonceLifetime指令 控制服务器nonce的持续时间 有效。[…]如果秒数小于0 那么,临时期限永远不会过期


因此,在我看来,0秒(您正在使用的值)要么是非法的,要么真的告诉Apache在0秒后使nonce过期,这正好解释了您正在获取的行为

域上的通配符是否有帮助

*.domain.com
*.domain.com大多数浏览器不遵守摘要“domain”指令,并且不会为其他URI重新发送凭据。据我所知,Opera是唯一一个尊重它的浏览器

对于Opera,服务器必须对域列表中的每个URI使用相同的“领域”字符串进行响应。换句话说,如果domain=“/test/example”,服务器需要在WWW-Authenticate报头中为这两个URI发送“test-Realm-example.com”。我假设Opera这样做是因为它存储了H(A1),而不是用于安全的实际密码。阅读RFC2617了解更多信息


以下是我对这个问题的跨浏览器解决方案:

感谢Manni的回复。我已经用authDigestNonCelifetime300,0,-1测试了它,声明被注释掉了。每个案例的结果都一样。谢谢你的建议。我试过了,但没有用。我不再寻求这个问题的答案。我完全放弃了这个想法。然而,我会保持这个问题的开放性,希望有人能解决它,并帮助其他人。谢谢,谢谢特拉维斯。这是解决我问题的最合适的方法,所以你得到了公认的答案。再次感谢。