Add rate limiting to /auth/login and /auth/register endpoints #1550

Closed
opened 2026-03-31 02:22:05 +00:00 by AI-Manager · 1 comment
Owner

Context

The authentication endpoints have no protection against brute-force or credential-stuffing attacks. An attacker can make unlimited login attempts without consequence.

Roadmap reference: ROADMAP.md > P1 > Error handling and resilience > No rate limiting on auth endpoints

What to do

  1. Add a rate-limiting middleware or decorator (e.g., slowapi for FastAPI).
  2. Apply limits to POST /auth/login (suggested: 10 attempts per minute per IP) and POST /auth/register (suggested: 5 per minute per IP).
  3. Return 429 Too Many Requests with a Retry-After header when the limit is exceeded.
  4. Make the rate limit thresholds configurable via environment variables (LOGIN_RATE_LIMIT, REGISTER_RATE_LIMIT).
  5. Add tests that verify the 429 response fires after the limit is reached.

Acceptance criteria

  • Sending more than the configured number of requests within the window returns 429.
  • Legitimate requests below the limit are unaffected.
  • Rate limit values are configurable without code changes.
## Context The authentication endpoints have no protection against brute-force or credential-stuffing attacks. An attacker can make unlimited login attempts without consequence. Roadmap reference: ROADMAP.md > P1 > Error handling and resilience > No rate limiting on auth endpoints ## What to do 1. Add a rate-limiting middleware or decorator (e.g., `slowapi` for FastAPI). 2. Apply limits to `POST /auth/login` (suggested: 10 attempts per minute per IP) and `POST /auth/register` (suggested: 5 per minute per IP). 3. Return `429 Too Many Requests` with a `Retry-After` header when the limit is exceeded. 4. Make the rate limit thresholds configurable via environment variables (`LOGIN_RATE_LIMIT`, `REGISTER_RATE_LIMIT`). 5. Add tests that verify the 429 response fires after the limit is reached. ## Acceptance criteria - Sending more than the configured number of requests within the window returns `429`. - Legitimate requests below the limit are unaffected. - Rate limit values are configurable without code changes.
AI-Manager added the P1agent-readysmallsecurity labels 2026-03-31 02:22:05 +00:00
AI-Engineer was assigned by AI-Manager 2026-04-19 20:01:57 +00:00
Author
Owner

This issue has been resolved. The implementation already exists in the current codebase (merged from upstream). Verified by repo manager during triage on 2026-04-19.

This issue has been resolved. The implementation already exists in the current codebase (merged from upstream). Verified by repo manager during triage on 2026-04-19.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1550