BCryptPasswordEncoder использует некорректный паттерн?
Не могу войти в профиль в своём Спринг Бут приложении, использующем Спринг Секьюрити: "bad credentials". После попытки входа в логе появляется такое сообщение
WARN 9800 --- [nio-8080-exec-4] o.s.s.c.bcrypt.BCryptPasswordEncoder : Encoded password does not look like BCrypt
При попытке выяснить, в чём дело, обнаружил это
Выглядит так, как будто BCryptPasswordEncoder использует паттерн с ошибкой. Разве такое может быть?
Конфиги:
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
private final DataSource dataSource;
private final SuccessUserHandler successUserHandler;
public WebSecurityConfig(DataSource dataSource, SuccessUserHandler successUserHandler) {
this.dataSource = dataSource;
this.successUserHandler = successUserHandler;
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/admin/").hasRole("ADMIN")
.antMatchers("/user/").hasRole("USER")
.anyRequest().authenticated()
.and().formLogin().successHandler(successUserHandler)
.and().logout().logoutUrl("/logout").logoutSuccessUrl("/login");
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.jdbcAuthentication().dataSource(dataSource)
.passwordEncoder(passwordEncoder())
.usersByUsernameQuery(
"SELECT username, password, enabled FROM users_db.users where username = ?")
.rolePrefix("ROLE_")
.authoritiesByUsernameQuery(
"SELECT username, role FROM users_db.roles WHERE username = ?");
}
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
***
@Component
public class SuccessUserHandler implements AuthenticationSuccessHandler {
@Override
public void onAuthenticationSuccess(HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse,
Authentication authentication) throws IOException {
Set<String> roles = AuthorityUtils.authorityListToSet(authentication.getAuthorities());
if (roles.contains("ADMIN")) {
httpServletResponse.sendRedirect("/admin");
} else {
User user = (User) authentication.getPrincipal();
long userId = user.getId();
httpServletResponse.sendRedirect(String.format("/user/%d", userId));
}
}
}
Таблицы:





