Languages

Spring Boot 3 - How to solve 403 Forbidden status for POST request?

6 points
Asked by:
Blythe-F
650

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
Answered by:
Blythe-F
650

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
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join