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

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

Context

The login and registration endpoints have no protection against brute-force attacks or abuse. This is a P1 security gap before any production use.

Roadmap reference: P1 Error handling and resilience

What to do

  1. Add a rate-limiting middleware or decorator to api.py / auth.py.
  2. Recommended library: slowapi (FastAPI-compatible wrapper around limits).
  3. Apply limits: e.g. 10 requests/minute per IP on /auth/login, 5 requests/minute on /auth/register.
  4. Make the limits configurable via environment variables (RATE_LIMIT_LOGIN, RATE_LIMIT_REGISTER).
  5. Return HTTP 429 with a Retry-After header on limit breach.

Acceptance criteria

  • Exceeding the rate limit returns 429, not 200 or 5xx.
  • Limits are configurable without code changes.
  • Unit tests cover the rate-limit response.
  • slowapi (or chosen library) is added to requirements.txt.
## Context The login and registration endpoints have no protection against brute-force attacks or abuse. This is a P1 security gap before any production use. Roadmap reference: P1 Error handling and resilience ## What to do 1. Add a rate-limiting middleware or decorator to `api.py` / `auth.py`. 2. Recommended library: `slowapi` (FastAPI-compatible wrapper around `limits`). 3. Apply limits: e.g. 10 requests/minute per IP on `/auth/login`, 5 requests/minute on `/auth/register`. 4. Make the limits configurable via environment variables (`RATE_LIMIT_LOGIN`, `RATE_LIMIT_REGISTER`). 5. Return HTTP 429 with a `Retry-After` header on limit breach. ## Acceptance criteria - Exceeding the rate limit returns 429, not 200 or 5xx. - Limits are configurable without code changes. - Unit tests cover the rate-limit response. - `slowapi` (or chosen library) is added to `requirements.txt`.
AI-Manager added the P1agent-readysmallsecurity labels 2026-03-29 05:22:28 +00:00
Author
Owner

This issue has been resolved. The changes are already merged into main.

Rate limiting added via slowapi in api.py and requirements.txt. Login and register endpoints are rate-limited.

Closing as completed.

This issue has been resolved. The changes are already merged into main. Rate limiting added via slowapi in api.py and requirements.txt. Login and register endpoints are rate-limited. 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#880