我开始了一个设置基本身份验证的项目。我现在想切换到摘要式身份验证。问题是,只有当我提供实际密码的哈希值而不是实际密码时,身份验证才会有效。
我执行了以下操作以从 BASIC 切换到 DIGEST:
将我的 web.xml 中的 auth-method 更改为 DIGEST
将 JDBC 领域的 JAAS 上下文更改为“jdbcDigestRealm”
在我的数据库中,我曾经使用“password”作为密码,我更改为 MD5(webuser:postgres:webuser) 的结果(其中 webuser 是登录名,webuser 是密码,postgres是领域),换句话说,我将表中的密码设置为 c3c2681ed07a5a2a5cb772061a8385e8。
我遇到的问题是,当我尝试访问资源时,浏览器会显示登录弹出窗口,但使用“webuser”作为密码不起作用。但是,使用“c3c2681ed07a5a2a5cb772061a8385e8”作为密码是可行的。看来我仍处于 BASIC 身份验证模式。
有什么线索吗?
谢谢!
最佳答案
DIGEST 身份验证方法与 HTTP Digest 身份验证相同。它只是对浏览器和服务器之间的通信进行加密。服务器仍然有明文密码。
来自http://java.boot.by/wcd-guide/ch05s03.html :
The difference between basic and digest authentication is that on the network connection between the browser and the server, the password is encrypted, even on a non-SSL connection. In the server, the password can be stored in clear text or encrypted text, which is true for all login methods and is independent of the choice that the application deployer makes.
您应该将 JDBC Realm
的 digest-algorithm
属性设置为 MD5
。之后 JDBC 领域将对密码进行哈希处理。
关于java - jdbcDigestAuthentication 仅在提供哈希时才有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7702258/