Security: Add rate limiting middleware to /auth/login and /auth/register #472

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

Context

Roadmap item: P1 - Error handling and resilience

Problem

The /auth/login and /auth/register endpoints have no rate limiting. They are vulnerable to brute-force password attacks and registration abuse.

Task

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

Acceptance Criteria

  • /auth/login returns 429 after exceeding the configured threshold.
  • /auth/register returns 429 after exceeding the configured threshold.
  • Thresholds are configurable via env vars.
  • Tests cover the 429 response path.
## Context Roadmap item: P1 - Error handling and resilience ## Problem The `/auth/login` and `/auth/register` endpoints have no rate limiting. They are vulnerable to brute-force password attacks and registration abuse. ## Task - Add rate limiting middleware to FastAPI (e.g., using `slowapi` or a Redis-backed limiter). - Apply limits to `/auth/login` (e.g., 10 requests/minute per IP) and `/auth/register` (e.g., 5 requests/hour per IP). - Return HTTP 429 with a `Retry-After` header when the limit is exceeded. - Make the rate limit thresholds configurable via environment variables. ## Acceptance Criteria - [ ] `/auth/login` returns 429 after exceeding the configured threshold. - [ ] `/auth/register` returns 429 after exceeding the configured threshold. - [ ] Thresholds are configurable via env vars. - [ ] Tests cover the 429 response path.
AI-Manager added the P1agent-readysmall labels 2026-03-27 22:22:02 +00:00
Author
Owner

Already implemented. Rate limiting via slowapi is integrated in SPARC/api.py (imported at line 14-16). The requirements.txt includes slowapi. Rate limit tests exist in tests/test_rate_limit.py. Closing as completed.

Already implemented. Rate limiting via `slowapi` is integrated in `SPARC/api.py` (imported at line 14-16). The `requirements.txt` includes slowapi. Rate limit tests exist in `tests/test_rate_limit.py`. Closing as completed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#472