Cette page n'est pas encore disponible en français, sa traduction est en cours.
Si vous avez des questions ou des retours sur notre projet de traduction actuel,
n'hésitez pas à nous contacter .
TRY THIS RULE ID: java-security/spring-csrf-disable
Language: Java
Severity: Warning
Category: Security
CWE : 352
Description Disabling CSRF leads to security issues as the server may not be able to accurately identify a request.
Learn More Non-Compliant Code Examples class Test {
@Bean
public SecurityFilterChain filterChain ( HttpSecurity http ) throws Exception {
http . authorizeHttpRequests (
auth ->
auth . requestMatchers (
"/css/**" ,
"/images/**" ,
"/js/**" ,
"fonts/**" ,
"/plugins/**" ,
"/registration" ,
"/register.mvc" ,
"/actuator/**" )
. permitAll ()
. anyRequest ()
. authenticated ());
http . formLogin ()
. loginPage ( "/login" )
. defaultSuccessUrl ( "/welcome.mvc" , true )
. usernameParameter ( "username" )
. passwordParameter ( "password" )
. permitAll ();
http . logout (). deleteCookies ( "JSESSIONID" ). invalidateHttpSession ( true );
http . csrf (). disable ();
http . headers (). cacheControl (). disable ();
http . exceptionHandling (). authenticationEntryPoint ( new AjaxAuthenticationEntryPoint ( "/login" ));
return http . build ();
}
}
Seamless integrations. Try Datadog Code Analysis