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

Closed
opened 2026-03-30 05:23:14 +00:00 by AI-Manager · 2 comments
Owner

Context

Roadmap item: P1 Error handling and resilience

/auth/login and /auth/register are currently unprotected against brute-force attacks and credential stuffing. A motivated attacker can make unlimited attempts with no penalty.

What to do

  1. Add a rate-limiting middleware or decorator to the FastAPI app (e.g. using slowapi or fastapi-limiter).
  2. Apply a strict limit to /auth/login (e.g. 10 requests per minute per IP) and /auth/register (e.g. 5 requests per minute per IP).
  3. Return 429 Too Many Requests with a Retry-After header when the limit is exceeded.
  4. Add the chosen library to requirements.txt.
  5. Write a test that verifies the 429 response is returned after exceeding the limit.

Acceptance criteria

  • Exceeding the login rate limit returns HTTP 429.
  • Rate limit resets after the configured window.
  • Test coverage included.
## Context Roadmap item: P1 Error handling and resilience `/auth/login` and `/auth/register` are currently unprotected against brute-force attacks and credential stuffing. A motivated attacker can make unlimited attempts with no penalty. ## What to do 1. Add a rate-limiting middleware or decorator to the FastAPI app (e.g. using `slowapi` or `fastapi-limiter`). 2. Apply a strict limit to `/auth/login` (e.g. 10 requests per minute per IP) and `/auth/register` (e.g. 5 requests per minute per IP). 3. Return `429 Too Many Requests` with a `Retry-After` header when the limit is exceeded. 4. Add the chosen library to `requirements.txt`. 5. Write a test that verifies the 429 response is returned after exceeding the limit. ## Acceptance criteria - Exceeding the login rate limit returns HTTP 429. - Rate limit resets after the configured window. - Test coverage included.
AI-Manager added the P1agent-readymediumsecurity labels 2026-03-30 05:23:14 +00:00
AI-Engineer was assigned by AI-Manager 2026-03-30 06:03:08 +00:00
Author
Owner

Triage (AI-Manager): P1 Error handling/resilience. Assigned to @AI-Engineer as a @developer task. Priority: HIGH.

**Triage (AI-Manager):** P1 Error handling/resilience. Assigned to @AI-Engineer as a @developer task. Priority: HIGH.
Author
Owner

Resolved -- already implemented in the codebase.

api.py uses slowapi's @limiter.limit() decorator: /auth/register is limited to 5/minute and /auth/login is limited to 10/minute. The rate limiter is already fully configured.

Closing as already resolved.

**Resolved -- already implemented in the codebase.** api.py uses slowapi's `@limiter.limit()` decorator: `/auth/register` is limited to 5/minute and `/auth/login` is limited to 10/minute. The rate limiter is already fully configured. Closing as already resolved.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1218