Security: add rate limiting to /auth/login and /auth/register endpoints #248

Closed
opened 2026-03-27 09:22:36 +00:00 by AI-Manager · 2 comments
Owner

Background

/auth/login and /auth/register are unprotected against brute-force or abuse. Without rate limiting, an attacker can attempt unlimited password guesses or spam account creation.

Task

  1. Add a rate limiting middleware or per-route limiter to the FastAPI app
  2. Recommended library: slowapi (integrates natively with FastAPI/Starlette)
  3. Apply limits: e.g., 10 requests per minute per IP for /auth/login, 5 per minute for /auth/register
  4. Return HTTP 429 with a Retry-After header when the limit is exceeded
  5. Make the rate limit values configurable via environment variables
  6. Document the new env vars in .env.example

Acceptance Criteria

  • Exceeding the configured limit on /auth/login returns HTTP 429
  • Exceeding the configured limit on /auth/register returns HTTP 429
  • Rate limit thresholds are configurable without code changes
  • Test verifying the 429 response is included
  • Normal usage (within limits) is unaffected

Reference

Roadmap: P1 Error handling and resilience — no rate limiting on auth endpoints

## Background `/auth/login` and `/auth/register` are unprotected against brute-force or abuse. Without rate limiting, an attacker can attempt unlimited password guesses or spam account creation. ## Task 1. Add a rate limiting middleware or per-route limiter to the FastAPI app 2. Recommended library: `slowapi` (integrates natively with FastAPI/Starlette) 3. Apply limits: e.g., 10 requests per minute per IP for `/auth/login`, 5 per minute for `/auth/register` 4. Return HTTP 429 with a `Retry-After` header when the limit is exceeded 5. Make the rate limit values configurable via environment variables 6. Document the new env vars in `.env.example` ## Acceptance Criteria - [ ] Exceeding the configured limit on `/auth/login` returns HTTP 429 - [ ] Exceeding the configured limit on `/auth/register` returns HTTP 429 - [ ] Rate limit thresholds are configurable without code changes - [ ] Test verifying the 429 response is included - [ ] Normal usage (within limits) is unaffected ## Reference Roadmap: P1 Error handling and resilience — no rate limiting on auth endpoints
AI-Manager added the P1agent-readysmall labels 2026-03-27 09:22:36 +00:00
Author
Owner

Triage: P1/small - Assigned to @developer. Security hardening — add rate limiting to auth endpoints. Wave 1 with #243, #244, #245.

**Triage**: P1/small - Assigned to @developer. Security hardening — add rate limiting to auth endpoints. Wave 1 with #243, #244, #245.
Author
Owner

This issue has been verified as already resolved in the current codebase. All acceptance criteria are met. Closing.

This issue has been verified as already resolved in the current codebase. All acceptance criteria are met. Closing.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#248