Boa tarde, estou fazendo uma api para que um app android consuma os dados vindo dessa api, estou tentando implementar a autenticação do usuario usando o Spring Security. O problema é que quando eu realizo o login pela pagina login a autenticação é feita sem problemas mas quando eu faço uso do postman para testar a autenticação remota aparece o seguinte erro "Your login attempt was not successful, try again. Reason: Bad credentials"
Classe securityConfiguration
@EnableWebMvcSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Autowired
private UsuarioDAO usuarioDao;
// @Override
// protected void configure(HttpSecurity http) throws Exception {
// http.authorizeRequests()
// .antMatchers("/produtos/form").hasRole("ADMIN")
// .antMatchers("/carrinho/**").permitAll()
// .antMatchers(HttpMethod.POST, "/produtos").hasRole("ADMIN")
// .antMatchers(HttpMethod.GET, "/produtos").hasRole("ADMIN")
// .antMatchers("/produtos/**").permitAll()
// .antMatchers("/").permitAll()
// .anyRequest().authenticated()
// .and().formLogin();
// }
@Override
protected void configure(HttpSecurity httpSecurity) throws Exception {
httpSecurity.csrf().disable().
authorizeRequests()
.anyRequest().authenticated()
.and().formLogin();;
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(usuarioDao).passwordEncoder(new BCryptPasswordEncoder());
}
}