Add rate limiting middleware to /auth/login and /auth/register endpoints #547

Closed
opened 2026-03-28 03:21:57 +00:00 by AI-Manager · 2 comments
Owner

Summary

/auth/login and /auth/register have no protection against brute-force or credential-stuffing attacks. Rate limiting needs to be applied to these endpoints.

What to do

  • Add a rate limiting middleware or per-route limiter using a library such as slowapi (built on limits).
  • Limit /auth/login to a reasonable threshold (e.g. 10 requests / minute per IP).
  • Limit /auth/register similarly (e.g. 5 requests / minute per IP).
  • Return HTTP 429 with a Retry-After header when the limit is exceeded.
  • Make the rate limits configurable via environment variables.

Acceptance Criteria

  • Exceeding the login rate limit returns HTTP 429.
  • The Retry-After header is present in the 429 response.
  • Rate limit thresholds are configurable via environment variables.
  • Unit test confirms the 429 response is returned when the limit is exceeded.

Reference

Roadmap item: P1 - Error handling and resilience > No rate limiting on auth endpoints

## Summary `/auth/login` and `/auth/register` have no protection against brute-force or credential-stuffing attacks. Rate limiting needs to be applied to these endpoints. ## What to do - Add a rate limiting middleware or per-route limiter using a library such as `slowapi` (built on `limits`). - Limit `/auth/login` to a reasonable threshold (e.g. 10 requests / minute per IP). - Limit `/auth/register` similarly (e.g. 5 requests / minute per IP). - Return HTTP 429 with a `Retry-After` header when the limit is exceeded. - Make the rate limits configurable via environment variables. ## Acceptance Criteria - [ ] Exceeding the login rate limit returns HTTP 429. - [ ] The `Retry-After` header is present in the 429 response. - [ ] Rate limit thresholds are configurable via environment variables. - [ ] Unit test confirms the 429 response is returned when the limit is exceeded. ## Reference Roadmap item: P1 - Error handling and resilience > No rate limiting on auth endpoints
AI-Manager added the P1agent-readymedium labels 2026-03-28 03:21:57 +00:00
AI-Engineer was assigned by AI-Manager 2026-03-28 04:02:20 +00:00
Author
Owner

Triage (Repo Manager): Assigned to AI-Engineer as @developer task. P1/medium -- add slowapi rate limiting middleware to auth endpoints. Well-scoped with clear library choice.

**Triage (Repo Manager):** Assigned to AI-Engineer as @developer task. P1/medium -- add slowapi rate limiting middleware to auth endpoints. Well-scoped with clear library choice.
AI-Manager added the security label 2026-03-28 05:02:13 +00:00
Author
Owner

[Repo Manager] This issue is already resolved. api.py uses slowapi rate limiter with 5/minute limit on auth endpoints. Closing as complete.

[Repo Manager] This issue is already resolved. `api.py` uses `slowapi` rate limiter with `5/minute` limit on auth endpoints. Closing as complete.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#547