java - jdbcDigestAuthentication 仅在提供哈希时才有效

标签 java digest-authentication jdbcrealm

我开始了一个设置基本身份验证的项目。我现在想切换到摘要式身份验证。问题是,只有当我提供实际密码的哈希值而不是实际密码时,身份验证才会有效。

我执行了以下操作以从 BASIC 切换到 DIGEST:

  1. 将我的 web.xml 中的 auth-method 更改为 DIGEST

  2. 将 JDBC 领域的 JAAS 上下文更改为“jdbcDigestRealm”

  3. 在我的数据库中,我曾经使用“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 Realmdigest-algorithm 属性设置为 MD5。之后 JDBC 领域将对密码进行哈希处理。

关于java - jdbcDigestAuthentication 仅在提供哈希时才有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7702258/

相关文章:

java - JDBCRealm 不起作用但没有错误消息

security - Tomcat 7.11 JDBCRealm 和 UserDatabaseRealm 不能一起工作

tomcat - 如何使用 Tomcat 7 配置 JNDI 领域以进行 PKI 用户证书身份验证?

java - 如何将带有 HTML 标签的字符串放入数组或列表中?

java - 如何替换 "["和 "]"的所有实例

java - SmartGWT 在运行时切换 CSS 类

c# - HttpListener 摘要身份验证架构

java - 使用 Hibernate 的后备数据库

Spring Webflux WebClient : Does it supports digest based authentication?

spring-boot - 使用 spring security : 401 recieved as expected but with two WWW-Authenticate headers 进行摘要认证