SpringBoot 集成 Security 时,报 Encoded password does not look like BCrypt
原因:SecurityConfig 必须 Bean 的形式实例化
/** * 配置用户身份的configure()方法 * * @param auth * @throws Exception */ @Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { auth.userDetailsService(userDetailsService).passwordEncoder(new BCryptPasswordEncoder()); }
解决方案
/** * 强散列哈希加密实现 * 必须 Bean 的形式实例化,否则会报 :Encoded password does not look like BCrypt */ @Bean public BCryptPasswordEncoder bCryptPasswordEncoder() { return new BCryptPasswordEncoder(); } /** * 配置用户身份的configure()方法 * * @param auth * @throws Exception */ @Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { auth.userDetailsService(userDetailsService).passwordEncoder(bCryptPasswordEncoder()); }