I'm using spring security 5 for the first time and whene I try to login I get this error:Encoded password does not look like BCrypt this is my securityConfig.java
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(securedEnabled=true)
public class SecurityConfig extends WebSecurityConfigurerAdapter{
@Autowired
public void globalConfig(AuthenticationManagerBuilder auth, DataSource dataSource) throws Exception {
auth.jdbcAuthentication()
.dataSource(dataSource)
.usersByUsernameQuery("select username as principal,password as credentials, true from users where username = ?").passwordEncoder(new BCryptPasswordEncoder())
.authoritiesByUsernameQuery("select user_username as principal, roles_role as role from users_roles where user_username = ?")
.rolePrefix("ROLE_");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.csrf().disable()
.authorizeRequests()
.antMatchers("/css/**","/js/**","/images/**").permitAll()
.anyRequest()
.authenticated()
.and()
.formLogin()
.loginPage("/login.html")
.permitAll()
.defaultSuccessUrl("/index.html");
}
}
I use password encoder like this:
.usersByUsernameQuery("select username as principal,password as credentials,
true from users where username = ?").passwordEncoder(new
BCryptPasswordEncoder())
Does anyone know where does the problem come from!