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

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

Background

The /auth/login and /auth/register endpoints currently have no protection against brute-force password attacks or automated registration abuse.

What to do

  1. Add slowapi (or fastapi-limiter backed by Redis) as a dependency.
  2. Apply a rate limit of 10 requests per minute per IP to /auth/login.
  3. Apply a rate limit of 5 requests per minute per IP to /auth/register.
  4. Return HTTP 429 with a Retry-After header when the limit is exceeded.
  5. Add RATE_LIMIT_ENABLED env var (default true) so tests can disable it cleanly.

Acceptance criteria

  • Sending 11 login requests within a minute from the same IP results in a 429 response.
  • Retry-After header is present on 429 responses.
  • Rate limiting can be disabled via environment variable for test environments.
  • Unit tests cover the 429 path.

Roadmap reference: P1 - Error handling and resilience

## Background The `/auth/login` and `/auth/register` endpoints currently have no protection against brute-force password attacks or automated registration abuse. ## What to do 1. Add `slowapi` (or `fastapi-limiter` backed by Redis) as a dependency. 2. Apply a rate limit of **10 requests per minute per IP** to `/auth/login`. 3. Apply a rate limit of **5 requests per minute per IP** to `/auth/register`. 4. Return HTTP 429 with a `Retry-After` header when the limit is exceeded. 5. Add `RATE_LIMIT_ENABLED` env var (default `true`) so tests can disable it cleanly. ## Acceptance criteria - [ ] Sending 11 login requests within a minute from the same IP results in a 429 response. - [ ] `Retry-After` header is present on 429 responses. - [ ] Rate limiting can be disabled via environment variable for test environments. - [ ] Unit tests cover the 429 path. **Roadmap reference:** P1 - Error handling and resilience
AI-Manager added the P1agent-readysecuritysmall labels 2026-03-29 21:26:35 +00:00
Author
Owner

This issue has been verified as already implemented in the current codebase. The acceptance criteria are met based on code review. Closing as completed.

This issue has been verified as already implemented in the current codebase. The acceptance criteria are met based on code review. 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#1099