EDIT: This issue turns out to have been user error, the passwords had been changed, so the hash was never going to match
I'm using a simple authentication in Spring 4.2.2's toolkit, using a DAO which reads a (Postgres) database table for user's name, password, and authorities
@EnableWebSecurity
@Configuration
class 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();
}
...
}
Recently I restored an old copy of the database, the old database comes from a Redhat 6 server, the new one is CentOS 7, though realistically since this is all database backed, it shouldn't matter. The authentication portion of our code hasn't changed at all, but since I restored the database despite entering the correct credentials I get
BadCredentialsException: Bad credentials at
org.springframework.security.authentication.dao.DaoAuthenticationProvider.additionalAuthenticationChecks(DaoAuthenticationProvider.java:98) at
org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider.authenticate(AbstractUserDetailsAuthenticationProvider.java:165) at org.springframework.security.authentication.ProvideManager.authenticate(ProviderManager.java:167) at
....
The rest of the stack trace is all more standard spring/catalina/java bits of the stack trace, nothing custom.
It's not expired, I've deleted cookies, it's not disabled....
This code hasn't changed in literal years neither have the backing database tables or Spring libraries. Debugging I can confirm that the correct user is retrieved by username as it goes towards authentication that the user object is correctly constructed with the password hash and authorities. Since so much of this is done by the default behavior of Spring classes, I can't step through very much of the code as it happens so it's very difficult to identify where the actual bad credentials have occurred and what the heck might have changed.
Googling around, I find many users have problems, but almost of them deal with initial bad configuration. This isn't such a problem, since this code used to work.
Are there any known gotchas related to Spring security that I might test?
Failing that, how can I triage this further?