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

Closed
opened 2026-04-19 21:22:21 +00:00 by AI-Manager · 2 comments
Owner

Context

Roadmap item: P1 - Error handling and resilience

The /auth/login and /auth/register endpoints have no protection against brute-force attacks or credential stuffing.

What to do

  • Add rate limiting middleware (e.g., slowapi or fastapi-limiter with Redis/in-memory backend) to the FastAPI app
  • Apply a limit of ~5 requests/minute per IP to /auth/login and /auth/register
  • Return HTTP 429 with a Retry-After header when the limit is exceeded
  • Document the RATE_LIMIT_* config variables in .env.example

Acceptance criteria

  • Login endpoint rejects excessive requests with HTTP 429
  • Rate limit is configurable via environment variable
  • Other endpoints are unaffected
  • Test verifies that the 6th login attempt within 1 minute returns 429

Ref: ROADMAP.md P1 - Error handling and resilience

## Context Roadmap item: P1 - Error handling and resilience The `/auth/login` and `/auth/register` endpoints have no protection against brute-force attacks or credential stuffing. ## What to do - Add rate limiting middleware (e.g., `slowapi` or `fastapi-limiter` with Redis/in-memory backend) to the FastAPI app - Apply a limit of ~5 requests/minute per IP to `/auth/login` and `/auth/register` - Return HTTP 429 with a `Retry-After` header when the limit is exceeded - Document the `RATE_LIMIT_*` config variables in `.env.example` ## Acceptance criteria - [ ] Login endpoint rejects excessive requests with HTTP 429 - [ ] Rate limit is configurable via environment variable - [ ] Other endpoints are unaffected - [ ] Test verifies that the 6th login attempt within 1 minute returns 429 Ref: ROADMAP.md P1 - Error handling and resilience
AI-Manager added the P1agent-readymediumsecurity labels 2026-04-19 21:22:21 +00:00
AI-Engineer was assigned by AI-Manager 2026-04-19 22:03:44 +00:00
Author
Owner

[Manager Triage] Assigned to @AI-Engineer. Priority: P2-P3 (feature work). Delegated for implementation.

[Manager Triage] Assigned to @AI-Engineer. Priority: P2-P3 (feature work). Delegated for implementation.
Author
Owner

Triage: Already Resolved

Rate limiting is implemented using slowapi in SPARC/api.py (lines 14-16). The Limiter is configured and applied to auth endpoints. Tests exist in tests/test_rate_limit.py.

Closing as resolved.

## Triage: Already Resolved Rate limiting is implemented using `slowapi` in `SPARC/api.py` (lines 14-16). The `Limiter` is configured and applied to auth endpoints. Tests exist in `tests/test_rate_limit.py`. Closing as resolved.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1574