Код: Выделить всё
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http
.csrf(csrf -> csrf.disable())
.authorizeHttpRequests(auth -> auth
.requestMatchers("/api/users/user/register").permitAll()
.requestMatchers("/api/users/user/login").permitAll()
.requestMatchers("/api/users/user/refresh-token").permitAll()
.requestMatchers("/api/users/user/change-password").permitAll()
.anyRequest().authenticated()
)
.sessionManagement(session -> session
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
)
.authenticationProvider(authenticationProvider)
.addFilterBefore(rateLimitingFilter, UsernamePasswordAuthenticationFilter.class)
.addFilterBefore(jwtAuthFilter, UsernamePasswordAuthenticationFilter.class);
return http.build();
}
< /code>
@Component
@RequiredArgsConstructor
public class JwtAuthenticationFilter extends OncePerRequestFilter {
private final JwtService jwtService;
private final UserDetailsService userDetailsService;
....
@Override
protected boolean shouldNotFilter(HttpServletRequest request) {
String path = request.getServletPath();
return path.equals("/api/users/user/register") ||
path.equals("/api/users/user/login") ||
path.equals("/api/users/user/refresh-token") ||
path.equals("/api/users/user/change-password");
}
}
.
Что может вызвать эту проблему, и как я могу должным образом исключить фильтр применить к конечной точке/API/пользователя/пользователя/обновления?
Подробнее здесь: https://stackoverflow.com/questions/794 ... tionfilter