I have the following:

   @Override
protected void registerAuthentication(AuthenticationManagerBuilder auth) throws Exception {
    auth.userDetailsService(userDetailsManager()).passwordEncoder(passwordEncoder());
}

@Bean
public MongoUserDetailsService userDetailsManager() {
    return new MongoUserDetailsService();
}

@Bean
public BCryptPasswordEncoder passwordEncoder() {
    return new BCryptPasswordEncoder();
}

in my WebSecurityConfigurerAdapter and it seems to be working OK for checking the password on login.

Am I missing anything else to be able to store the password encrypted as well?

有帮助吗?

解决方案

I just needed to encrypt the password programatically when I was storing it. Essentially:

new BCryptPasswordEncoder().encode(user.getPassword())
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top