Reputation: 61
I've defined securityConfig as following:
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.jdbcAuthentication()
.dataSource(dataSource)
.passwordEncoder(passwordEncoder())
.usersByUsernameQuery(\\some code\\)
.authoritiesByUsernameQuery(\\some code\\)
.getUserDetailsService();
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.anyRequest().authenticated()
.and()
.httpBasic().authenticationEntryPoint(entryPoint);
}
When I am entering the credentials in the form in my browser it works fine,
but when I try to send the request in postman using basic auth form
I get 403 error. What am I doing wrong?
Upvotes: 0
Views: 1660
Reputation: 16775
This is most likely caused by CSRF protection.
From the docs:
Our recommendation is to use CSRF protection for any request that could be processed by a browser by normal users. If you are only creating a service that is used by non-browser clients, you will likely want to disable CSRF protection.
CSRF protection can be disabled as follows:
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.anyRequest().authenticated()
.and()
.httpBasic().authenticationEntryPoint(entryPoint)
.and()
.csrf().csrf().disable()
}
Upvotes: 1