EN
Spring Boot 3 - How to solve 403 Forbidden status for POST request?
1
answers
6
points
I have decided to upgrade my application to Spring Boot 3 attaching Spring Boot Security dependency.
And now I am not able to do POST requests.
REST API returns 403 Forbidden status.
Any idea how to solve it?
1 answer
2
points
It is not recommended, by it you added just Spring Boot Security dependency, you can disable SCRF protection and let to request to all endpoints - in the future take care of security.
Example SpringSecurityConfig.java file.
package com.example.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.web.SecurityFilterChain;
@Configuration
public class SpringSecurityConfig {
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http
.csrf().disable()
.authorizeHttpRequests()
.anyRequest().permitAll();
return http.build();
}
}
0 comments
Add comment