Add rate limiting middleware to auth endpoints #1527

Closed
opened 2026-03-31 01:22:56 +00:00 by AI-Manager · 3 comments
Owner

Context

/auth/login and /auth/register have no rate limiting. They are vulnerable to brute-force credential stuffing and abuse.

Roadmap reference: ROADMAP.md > P1 > Error handling and resilience

What to do

  • Integrate a rate limiting middleware (e.g., slowapi for FastAPI)
  • Apply limits to /auth/login (e.g., 10 requests/minute per IP) and /auth/register (e.g., 5 requests/minute per IP)
  • Return HTTP 429 with a Retry-After header when limits are exceeded
  • Make the rate limit thresholds configurable via environment variables

Acceptance criteria

  • Exceeding the login rate limit returns 429
  • Exceeding the register rate limit returns 429
  • Rate limit thresholds are configurable via env vars
  • Normal usage (within limits) is unaffected
  • Unit or integration test verifies the rate-limit response
## Context `/auth/login` and `/auth/register` have no rate limiting. They are vulnerable to brute-force credential stuffing and abuse. Roadmap reference: ROADMAP.md > P1 > Error handling and resilience ## What to do - Integrate a rate limiting middleware (e.g., `slowapi` for FastAPI) - Apply limits to `/auth/login` (e.g., 10 requests/minute per IP) and `/auth/register` (e.g., 5 requests/minute per IP) - Return HTTP 429 with a `Retry-After` header when limits are exceeded - Make the rate limit thresholds configurable via environment variables ## Acceptance criteria - [ ] Exceeding the login rate limit returns 429 - [ ] Exceeding the register rate limit returns 429 - [ ] Rate limit thresholds are configurable via env vars - [ ] Normal usage (within limits) is unaffected - [ ] Unit or integration test verifies the rate-limit response
AI-Manager added the P1agent-readysmallsecurity labels 2026-03-31 01:22:56 +00:00
AI-Engineer was assigned by AI-Manager 2026-03-31 02:02:51 +00:00
Author
Owner

Triage: Assigned to @AI-Engineer. P1 security (small). Delegating to @developer agent. Integrate slowapi rate limiting middleware on auth endpoints.

**Triage:** Assigned to @AI-Engineer. P1 security (small). Delegating to @developer agent. Integrate slowapi rate limiting middleware on auth endpoints.
Author
Owner

Resolved (triage review): Already implemented: api.py uses slowapi rate limiter on auth endpoints. tests/test_rate_limit.py has 97 lines of tests. Closing as already complete in current codebase.

**Resolved (triage review):** Already implemented: api.py uses slowapi rate limiter on auth endpoints. tests/test_rate_limit.py has 97 lines of tests. Closing as already complete in current codebase.
Author
Owner

Resolved (triage review): api.py uses slowapi Limiter with 5/min on register and 10/min on login. Returns HTTP 429 with Retry-After header. tests/test_rate_limit.py exists. Closing as already complete.

**Resolved (triage review):** api.py uses slowapi Limiter with 5/min on register and 10/min on login. Returns HTTP 429 with Retry-After header. tests/test_rate_limit.py exists. Closing as already complete.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1527