У меня проблема с BCryptPasswordEncoder в Spring. Если я использую SQL Сервер для хранения зашифрованного пароля, при попытке войти в систему я получаю сообщение, подобное: «Кодированный пароль не похож на BCrypt».
Однако, когда я использую MySQL и тот же пароль, я могу войти в систему в обычном режиме.
Как я могу войти, используя SQL Сервер?
Вот код расширения файла WebSecurityConfigurerAdapter, который содержит BCryptPasswordEncoder
@Autowired
private UserServiceImpl userService;
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
@Autowired
public void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userService).passwordEncoder(passwordEncoder());
}
@Override
protected void configure(HttpSecurity http) throws Exception {
// TODO Auto-generated method stub
http.csrf().disable().authorizeRequests().antMatchers("/students").hasAnyRole("USER", "ADMIN")
.antMatchers("/students/addStudent").hasRole("ADMIN").antMatchers("/students/edit/*").hasRole("ADMIN")
.antMatchers("/students/{id}").hasRole("ADMIN").anyRequest().authenticated().and().formLogin()
.loginPage("/login").defaultSuccessUrl("/students").permitAll().and().logout()
.invalidateHttpSession(true).clearAuthentication(true)
.logoutRequestMatcher(new AntPathRequestMatcher("/logout")).logoutSuccessUrl("/login?logout")
.permitAll().and().exceptionHandling().accessDeniedPage("/access-denied");
}
введите описание изображения здесь