configurable rate limiter

This commit is contained in:
2026-04-19 19:05:07 -06:00
parent c14413a634
commit c2474f941e

View File

@@ -10,6 +10,8 @@ import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;
import org.springframework.web.filter.OncePerRequestFilter;
import org.springframework.beans.factory.annotation.Value;
import java.io.IOException;
import java.time.Duration;
import java.util.Map;
@@ -24,6 +26,9 @@ public class RateLimitFilter extends OncePerRequestFilter {
"/api/v1/auth/reset-password", new int[]{10, 15}
);
@Value("${app.rate-limit-enabled:true}")
private boolean enabled;
private final RateLimiterService rateLimiterService;
private final ApiErrorResponder apiErrorResponder;
@@ -37,7 +42,7 @@ public class RateLimitFilter extends OncePerRequestFilter {
@NonNull HttpServletResponse response,
@NonNull FilterChain filterChain) throws ServletException, IOException {
String path = request.getRequestURI();
int[] rule = RULES.get(path);
int[] rule = enabled ? RULES.get(path) : null;
if (rule != null) {
String ip = extractIp(request);