I have a problem with simple login configuration with users set up in memory. All times I getting back Bad Credentials.
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
//auth.userDetailsService(userDetailsService);
auth.
inMemoryAuthentication()
.withUser("user").password("123").roles("USER")
.and()
.withUser("admin").password("password").roles("USER", "ADMIN");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/").permitAll()
.antMatchers("/location")
.hasAnyRole("ADMIN","USER")
.and()
.formLogin()
.and()
.csrf()
.disable();
}
@Bean
public PasswordEncoder passwordEncoder(){
return new BCryptPasswordEncoder();
}
}
What I doing wrong??