背景
在最新的 Spring Security 5发布版本中, 出于安全性的考虑调整了PasswordEncoder的实现与使用策略.原先的StandardPasswordEncoder被@Deprecated,推荐BCryptPasswordEncoder。
BCryptPasswordEncoder使用示例
一种方式:在AuthenticationManagerBuilder配置实例化具体PasswordEncoder
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(redisUserDetailsService)
.passwordEncoder(new BCryptPasswordEncoder());
}
另一种方式:PasswordEncoderFactories的createDelegatingPasswordEncoder()方法来创建:
@Override