I want to expose an unsecure Restful endpoint in a Springboot secured application. GET requests to the endpoint /api/notify work, but POST requests result in a 403. How do I configure so that remote clients can POST to /api/notify from there server?
My extended WebSecurityConfigurerAdapter looks like this:
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/").permitAll()
.antMatchers("/signup").permitAll()
.antMatchers("/reset").permitAll()
.antMatchers("/api/notify").permitAll()
.anyRequest().authenticated();
http
.formLogin()
.defaultSuccessUrl("/home")
.failureUrl("/login?error")
.loginPage("/login")
.permitAll()
.and()
.logout()
.permitAll();
}
I think this is what you are looking for:
@Configuration
@EnableWebMvcSecurity
public class SecurityCtxConfig extends WebSecurityConfigurerAdapter {
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring()
.antMatchers(HttpMethod.POST,
"<YOUR URL>");
}
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