[PRM-712] Upgraded re-registration-service dependencies#294
[PRM-712] Upgraded re-registration-service dependencies#294AndyFlintAnswerDigital wants to merge 17 commits intomainfrom
Conversation
| http | ||
| .csrf(AbstractHttpConfigurer::disable) |
Check failure
Code scanning / CodeQL
Disabled Spring CSRF protection High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 days ago
In general, the fix is to avoid globally disabling CSRF. Instead, either (a) keep CSRF enabled (Spring’s default) and ensure state-changing requests from browsers use CSRF tokens, or (b) if the service really is stateless and only used by non-browser clients, explicitly document and constrain that, and selectively disable CSRF only for those endpoints or authentication mechanisms where it is safe.
For this specific code, the minimal, functionality-preserving change is to remove the explicit .csrf(AbstractHttpConfigurer::disable) call and allow Spring Security’s default CSRF configuration. This will re-enable CSRF protection. Because the code uses SessionCreationPolicy.STATELESS and HTTP Basic, re-enabling CSRF might block unsafe HTTP methods if used from a browser without CSRF tokens; however, that is precisely the protection we want if browsers are clients. Since we must not assume any framework changes elsewhere, the safest change inside this file is simply to delete the disabling call and leave the rest of the chain intact. No additional imports or methods are required.
Concretely:
- Edit
securityFilterChaininSecurityConfig.java. - Remove the line
.csrf(AbstractHttpConfigurer::disable)from thehttpconfiguration chain. - Keep session management, HTTP Basic, and authorization rules unchanged.
| @@ -96,7 +96,6 @@ | ||
| @Bean | ||
| public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { | ||
| http | ||
| .csrf(AbstractHttpConfigurer::disable) | ||
| .sessionManagement(sm -> sm.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) | ||
| .httpBasic(Customizer.withDefaults()) | ||
| .authorizeHttpRequests(auth -> auth |
No description provided.