SecurityBCrypt登录加密
1,在实现了WebSecurityConfigurerAdapter的类中添加配置
//加密配置
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
// auth.userDetailsService(customUserService()); //user Details Service验证
DaoAuthenticationProvider authenticationProvider = new DaoAuthenticationProvider();
authenticationProvider.setUserDetailsService(customUserService());
authenticationProvider.setPasswordEncoder(passwordEncoder());//登录密码进行加密验证
auth.authenticationProvider(authenticationProvider);
}
这时数据库就必须预先存储加密过得密码,
这是123456加密后的密码
$2a 10