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.
xxxxxxxxxx
1
package com.example.config;
2
3
import org.springframework.context.annotation.Bean;
4
import org.springframework.context.annotation.Configuration;
5
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
6
import org.springframework.security.web.SecurityFilterChain;
7
8
9
public class SpringSecurityConfig {
10
11
12
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
13
http
14
.csrf().disable()
15
.authorizeHttpRequests()
16
.anyRequest().permitAll();
17
return http.build();
18
}
19
}
0 commentsShow commentsAdd comment