security - HTTP 摘要认证

标签 security apache http authentication digest

我想将 HTTP 摘要式身份验证与存储用户名和加密密码的中央数据库一起使用。这些数据应该由不同的服务器使用,例如 Apache httpd 或 Tomcat。客户端将是使用浏览器和其他应用程序以 RESTful 方式进行通信的人。

据我所知,我不能使用带有散列密码的表。只可能存储HA1 = MD5(username:realm:password)需要明文密码的地方 - 正确吗?

另一方面,似乎可以在 Apache httpd 中使用散列密码:

Apache httpd doc说:

The first column value of the first row returned by the query statement should be a string containing the encrypted password.

它是否适用于摘要式身份验证?没有指定哈希算法的参数。 Apache httpd 如何决定使用哪种算法?

RFC 2617说:

4.13 Storing passwords

Digest authentication requires that the authenticating agent (usually the server) store some data derived from the user's name and password in a "password file" associated with a given realm. Normally this might contain pairs consisting of username and H(A1), where H(A1) is the digested value of the username, realm, and password as described above.

听起来密码必须是明文。

Servlet 3.0 规范说:

Although passwords are not sent on the wire, HTTP Digest authentication requires that clear text password equivalents be avaialble to the authenticating container so that it can validate received authenticators by calculating the expected digest.

这里的“等效明文密码”是什么?密码哈希?

Tomcat documentation说:

If using digested passwords with DIGEST authentication, the cleartext used to generate the digest is different. In the examples above {cleartext-password} must be replaced with {username}:{realm}:{cleartext-password}. For example, in a development environment this might take the form testUser:localhost:8080:testPassword.

这里需要一个明文密码。

那么,HTTP Digest 身份验证是否可以使用已加密的密码或使用明文密码?

如果用户请求来自不同子域的页面,他是否必须重新输入他的凭据?

浏览器是在tab关闭时删除缓存的密码还是只在整个关闭时才删除?也许这因浏览器而异 - 我对哪个浏览器删除它以及哪个浏览器保留它感兴趣。

总体问题是,摘要式身份验证是否适合我的场景,中央用户数据库已加密密码。或者我应该更好地使用基于 session 的单点登录服务?

最佳答案

在这种情况下,您已经有一个散列密码数据库,就不可能使用摘要式身份验证,因为它们没有使用相同的函数进行散列。

我认为这里最适合您的解决方案是创建一个登录页面并使用 cookie session 来控制用户的权限。使用此解决方案,您可以获得其他问题的答案:

关于security - HTTP 摘要认证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2109308/

相关文章:

api - 由于 User-Agent header 无效而拒绝请求时更正 HTTP 状态代码

node.js - 通过 Angular App 和 NodeJS 发送 GET/POST 请求到 express 服务器时如何修复 404 Not Found

javascript - Chrome 网络服务器中断我的 API URL 调用

php - 是否可以通过 cpanel 配置和 php 脚本来防止 DDos 攻击?

html - Xampp 和 Ampps 在更改时不会重新加载文件

security - GroovyClassLoader parseClass安全

php - 站点缓存文件,需要这个来停止

apache - 如何在flume中设置日志文件名

javascript - 在浏览器中生成唯一的序列号以进行日志记录

php - 如何在 PHP 中安全地识别远程设备?