Skip to content

feat: add rate limiting to auth service login endpoints - #1210

Open
Mrsandeep27 wants to merge 9418 commits into
Vacademy-io:mainfrom
Mrsandeep27:feature/rate-limiting-auth-login
Open

feat: add rate limiting to auth service login endpoints#1210
Mrsandeep27 wants to merge 9418 commits into
Vacademy-io:mainfrom
Mrsandeep27:feature/rate-limiting-auth-login

Conversation

@Mrsandeep27

Copy link
Copy Markdown

Summary

Closes #1199

  • Created RateLimitingFilter extending OncePerRequestFilter for login endpoint protection
  • Limits to 5 attempts per minute per IP using in-memory sliding window
  • Returns HTTP 429 with Retry-After header when limit exceeded
  • Covers all auth endpoints: /login-root, /login-otp, /login-whatsapp-otp, /request-otp, /request-whatsapp-otp, /verify-generic-whatsapp-otp-login
  • Uses X-Forwarded-For for correct IP detection behind nginx/load balancer
  • Zero external dependencies (uses ConcurrentHashMap + AtomicInteger)

Test plan

  • Send 6+ rapid POST requests to /auth-service/v1/login-root and verify 429 on 6th
  • Verify Retry-After header is present in 429 response
  • Confirm non-login endpoints are not rate limited
  • Wait 60s and verify requests succeed again

Generated with Claude Code

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add rate limiting to auth service login endpoint

9 participants