编辑:这个问题原来是用户错误,密码已更改,因此哈希永远不会匹配我在 Spring 4.2.2 的工具包中使用简单的身份验证,使用 DAO 读取 (Postgres) 数据库表以获取用户名、密码和权限@EnableWebSecurity@Configurationclass X extends WebSecurityConfigurerAdapter{ ... @Autowired private SessionRegistry sessionRegistry; @Autowired private SessionAuthenticationStrategy sessionAuthenticationStrategy; @Override protected void configure(HttpSecurity http){ http.sessionManagement().sessionAuthenticationStrategy(sessionAuthenticationStrategy).maximumSessions(1).sessionRegistry(sessionRegistry).expiredUrl("/login.jsp"); //presumably unrelated additional code related to matchers, roles, https } @Bean public SessionRegistry sessionRegistry(){ return new SessionRegistryImpl(); } @Bean public SessionAuthenticationStrategy sessionAuthenticationStrategy(){ return new ConcurrentSessionControlAuthenticationStrategy(sessionRegistry); } @Bean public PasswordEncoder passwordEncoder(){ return new StandardPasswordEncoder(); } ...}最近我恢复了数据库的旧副本,旧数据库来自Redhat 6 服务器,新数据库是CentOS 7,但实际上因为这都是数据库支持的,所以应该没有关系。我们代码的身份验证部分根本没有改变,但是尽管输入了正确的凭据,但由于我恢复了数据库,所以我得到了BadCredentialsException: Bad credentials at org.springframework.security.authentication.dao.DaoAuthenticationProvider.additionalAuthenticationChecks(DaoAuthenticationProvider.java:98) atorg.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider.authenticate(AbstractUserDetailsAuthenticationProvider.java:165) at org.springframework.security.authentication.ProvideManager.authenticate(ProviderManager.java:167) at.... 堆栈跟踪的其余部分是堆栈跟踪的更多标准 spring/catalina/java 位,没有任何自定义。它没有过期,我已经删除了 cookie,它没有被禁用....这段代码在字面意义上没有改变,支持数据库表或 Spring 库也没有改变。调试 我可以确认通过用户名检索到正确的用户,因为它用于验证用户对象是使用密码哈希和权限正确构造的。由于其中大部分是由 Spring 类的默认行为完成的,因此我无法在代码发生时单步执行很多代码,因此很难确定实际的错误凭证发生的位置以及到底发生了什么变化。谷歌搜索,我发现很多用户都遇到了问题,但几乎都是处理初始错误配置的问题。这不是问题,因为这段代码曾经有效。有没有我可以测试的与 Spring 安全相关的已知问题?如果做不到这一点,我该如何进一步分类?
添加回答
举报
0/150
提交
取消
