I cannot understand one particular thing.
I am using http-basic
authentication on my sever.
My code for that is:
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/user/save")
.permitAll()
.and()
.authorizeRequests()
.antMatchers("/user/**")
.hasRole("USER")
.and()
.authorizeRequests()
.antMatchers("/admin/**")
.hasRole("ADMIN")
.and()
.httpBasic()
.and()
.logout()
.permitAll()
.and()
.csrf().csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse());
}
And my request mapping for /user
is:
@GetMapping
public Principal user(Principal user){
return user;
}
When I query the endpoint /user
with the username and password in the postman app, I get the desired authenticated result.
However, when I update the headers with an intentional wrong password, I still get the authenticated result. I cannot understand why this is so.
Also, the POST
request on the endpoint /logout
fails with:
{
"timestamp": "2018-07-30T07:42:48.172+0000",
"status": 403,
"error": "Forbidden",
"message": "Forbidden",
"path": "/logout"
}
I cannot understand. Any help is appreciated.