File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
src/main/java/app/smartpot/api/security/config Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -65,14 +65,18 @@ public SecurityFilterChain securityFilterChain(HttpSecurity httpSec) throws Exce
6565 }
6666
6767 return httpSec
68- .csrf (AbstractHttpConfigurer ::disable )
68+ .csrf (csrf -> csrf
69+ // Ignorar CSRF para todas las rutas de API REST que usan autenticación JWT
70+ // CSRF no es necesario ni apropiado para APIs stateless con tokens en headers
71+ .ignoringRequestMatchers ("/**" )
72+ )
6973 .cors (cors -> cors .configurationSource (corsConfig ))
7074 .authorizeHttpRequests (authorizationManagerRequestMatcherRegistry -> {
7175 authorizationManagerRequestMatcherRegistry .requestMatchers (org .springframework .http .HttpMethod .OPTIONS ).permitAll ();
7276 authorizationManagerRequestMatcherRegistry .requestMatchers (publicRoutesList .toArray (new String [0 ])).permitAll ();
7377 authorizationManagerRequestMatcherRegistry .anyRequest ().authenticated ();
7478 })
75- .httpBasic (AbstractHttpConfigurer :: disable )
79+ .httpBasic (Customizer . withDefaults () )
7680 .formLogin (AbstractHttpConfigurer ::disable )
7781 .sessionManagement (httpSecuritySessionManagementConfigurer -> httpSecuritySessionManagementConfigurer .sessionCreationPolicy (SessionCreationPolicy .STATELESS ))
7882 .addFilterBefore (jwtAuthFilter , UsernamePasswordAuthenticationFilter .class )
You can’t perform that action at this time.
0 commit comments