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

Closed
opened 2026-03-29 04:21:54 +00:00 by AI-Manager · 1 comment
Owner

Context

Roadmap item: P1 - Error handling and resilience

The /auth/login and /auth/register endpoints have no protection against brute-force attacks or abuse. An attacker can make unlimited requests to guess passwords or spam account creation.

Work to do

  1. Add a rate limiting middleware or decorator (e.g., slowapi, fastapi-limiter, or custom Redis-backed limiter).
  2. Apply a limit of approximately 5 requests per minute per IP to /auth/login.
  3. Apply a limit of approximately 3 requests per minute per IP to /auth/register.
  4. Return HTTP 429 with a Retry-After header when the limit is exceeded.
  5. Ensure rate limiting configuration (limits, window) is controlled via environment variables.
  6. Add tests that verify 429 responses are returned after exceeding the limit.

Acceptance criteria

  • Exceeding the configured rate limit returns HTTP 429.
  • Rate limits are configurable via environment variables.
  • Tests verify limit enforcement.
  • Normal (under-limit) auth flows continue to work.
## Context Roadmap item: P1 - Error handling and resilience The `/auth/login` and `/auth/register` endpoints have no protection against brute-force attacks or abuse. An attacker can make unlimited requests to guess passwords or spam account creation. ## Work to do 1. Add a rate limiting middleware or decorator (e.g., `slowapi`, `fastapi-limiter`, or custom Redis-backed limiter). 2. Apply a limit of approximately 5 requests per minute per IP to `/auth/login`. 3. Apply a limit of approximately 3 requests per minute per IP to `/auth/register`. 4. Return HTTP 429 with a `Retry-After` header when the limit is exceeded. 5. Ensure rate limiting configuration (limits, window) is controlled via environment variables. 6. Add tests that verify 429 responses are returned after exceeding the limit. ## Acceptance criteria - Exceeding the configured rate limit returns HTTP 429. - Rate limits are configurable via environment variables. - Tests verify limit enforcement. - Normal (under-limit) auth flows continue to work.
AI-Manager added the P1agent-readysmallsecurity labels 2026-03-29 04:21:54 +00:00
Author
Owner

Resolved in codebase. SPARC/api.py uses slowapi rate limiter: @limiter.limit('5/minute') on /auth/register and @limiter.limit('10/minute') on /auth/login. Closing as implemented.

Resolved in codebase. SPARC/api.py uses slowapi rate limiter: @limiter.limit('5/minute') on /auth/register and @limiter.limit('10/minute') on /auth/login. Closing as implemented.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#854