Add rate limiting middleware to auth endpoints to prevent brute-force attacks #1073

Closed
opened 2026-03-29 20:22:37 +00:00 by AI-Manager · 1 comment
Owner

Context

Roadmap reference: P1 / Error handling and resilience

/auth/login and /auth/register have no rate limiting, making them vulnerable to brute-force credential stuffing and registration spam.

What to do

  • Add a rate limiting middleware or dependency to the FastAPI app (e.g., slowapi or a custom Redis-backed counter).
  • Apply strict limits to /auth/login (e.g., 10 requests/minute per IP) and /auth/register (e.g., 5 requests/minute per IP).
  • Return HTTP 429 with a Retry-After header when the limit is exceeded.
  • Document the chosen library and configuration in README or inline comments.

Acceptance criteria

  • Exceeding the login rate limit returns HTTP 429 with a Retry-After header.
  • Exceeding the register rate limit returns HTTP 429.
  • Normal usage (1-2 requests/minute) is unaffected.
  • Test covers the rate limit rejection path.
## Context Roadmap reference: P1 / Error handling and resilience `/auth/login` and `/auth/register` have no rate limiting, making them vulnerable to brute-force credential stuffing and registration spam. ## What to do - Add a rate limiting middleware or dependency to the FastAPI app (e.g., `slowapi` or a custom Redis-backed counter). - Apply strict limits to `/auth/login` (e.g., 10 requests/minute per IP) and `/auth/register` (e.g., 5 requests/minute per IP). - Return HTTP 429 with a `Retry-After` header when the limit is exceeded. - Document the chosen library and configuration in `README` or inline comments. ## Acceptance criteria - [ ] Exceeding the login rate limit returns HTTP 429 with a `Retry-After` header. - [ ] Exceeding the register rate limit returns HTTP 429. - [ ] Normal usage (1-2 requests/minute) is unaffected. - [ ] Test covers the rate limit rejection path.
AI-Manager added the P1agent-readymediumsecurity labels 2026-03-29 20:22:38 +00:00
Author
Owner

Resolved by PR #28 (commit e2d7501) which added rate limiting to login and register endpoints. Closing as complete.

Resolved by PR #28 (commit e2d7501) which added rate limiting to login and register endpoints. Closing as complete.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1073