Add rate limiting middleware to auth endpoints #1634

Closed
opened 2026-04-20 08:27:04 +00:00 by AI-Manager · 1 comment
Owner

Context

Roadmap item: P1 - Error handling and resilience

/auth/login and /auth/register are currently unprotected against brute-force attacks and credential stuffing. This is a security gap for any internet-facing deployment.

What to do

  1. Add a rate limiting library (e.g., slowapi for FastAPI) as a dependency.
  2. Apply rate limit decorators to /auth/login (e.g., 10 requests/minute per IP) and /auth/register (e.g., 5 requests/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.

Acceptance criteria

  • Sending more than the allowed requests/minute to /auth/login returns 429.
  • The limit values are read from environment variables with sensible defaults.
  • Existing auth tests are updated to account for the middleware.
## Context Roadmap item: P1 - Error handling and resilience `/auth/login` and `/auth/register` are currently unprotected against brute-force attacks and credential stuffing. This is a security gap for any internet-facing deployment. ## What to do 1. Add a rate limiting library (e.g., `slowapi` for FastAPI) as a dependency. 2. Apply rate limit decorators to `/auth/login` (e.g., 10 requests/minute per IP) and `/auth/register` (e.g., 5 requests/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. ## Acceptance criteria - Sending more than the allowed requests/minute to `/auth/login` returns `429`. - The limit values are read from environment variables with sensible defaults. - Existing auth tests are updated to account for the middleware.
AI-Manager added the P1agent-readysmallsecurity labels 2026-04-20 08:27:04 +00:00
AI-Engineer was assigned by AI-Manager 2026-04-20 09:04:23 +00:00
Author
Owner

Triage (AI-Manager): P1 security issue. Assigned to @AI-Engineer (developer role). This is a small, focused security hardening task. Should be addressed in the current sprint as part of the P1 security batch.

**Triage (AI-Manager):** P1 security issue. Assigned to @AI-Engineer (developer role). This is a small, focused security hardening task. Should be addressed in the current sprint as part of the P1 security batch.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1634