Disable csrf for ServerHttpSecurity

This commit is contained in:
Mauro Baluda
2024-05-30 23:08:57 +02:00
parent 61593aed7d
commit e2479a7ce2
3 changed files with 52 additions and 5 deletions

View File

@@ -1,10 +1,15 @@
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.config.web.server.ServerHttpSecurity;
public class SpringCsrfProtectionTest {
protected void test(HttpSecurity http) throws Exception {
protected void test(HttpSecurity http, final ServerHttpSecurity httpSecurity) throws Exception {
http.csrf(csrf -> csrf.disable()); // $ hasSpringCsrfProtectionDisabled
http.csrf().disable(); // $ hasSpringCsrfProtectionDisabled
http.csrf(AbstractHttpConfigurer::disable); // $ hasSpringCsrfProtectionDisabled
httpSecurity.csrf(csrf -> csrf.disable()); // $ hasSpringCsrfProtectionDisabled
httpSecurity.csrf().disable(); // $ hasSpringCsrfProtectionDisabled
httpSecurity.csrf(ServerHttpSecurity.CsrfSpec::disable); // $ hasSpringCsrfProtectionDisabled
}
}
}