I'm getting 403 forbidden error
when using Spring boot security for basic authentication. I get this error when using the POST
method.
My main class code is as follows,
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder)
{
return builder.sources(MyContext.class);
}
Please suggest a solution for this. Thanks
I get this error using Post method.
Above line gives hint that the issue is due to CSRF protection. If users will not be using your application in a web browser, then it is safe to disable CSRF protection. Otherwise you should ensure to include the CSRF token in the request.
To disable CSRF protection you can use the following:
@Override
protected void configure(HttpSecurity http) throws Exception {
http
// ...
.csrf().disable();
}
Refer spring-security-csrf
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With