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

Closed
opened 2026-03-27 16:22:40 +00:00 by AI-Manager · 1 comment
Owner

Problem

/auth/login and /auth/register have no protection against brute-force or abuse. An attacker can make unlimited login attempts or spam registrations with no throttling.

Work

  • Add rate limiting middleware to the FastAPI app (e.g., slowapi or a custom middleware using a Redis or in-memory counter).
  • Apply limits to at minimum: POST /auth/login (e.g., 10 requests/minute per IP) and POST /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 limits in config.py or as environment variables so they are adjustable without code changes.

Acceptance Criteria

  • Making more than the configured number of login requests per minute from the same IP results in HTTP 429.
  • The rate limit counter resets after the window expires.
  • Limits are configurable via environment variables.

Reference

Roadmap item: P1 Error handling and resilience — No rate limiting on auth endpoints.

## Problem `/auth/login` and `/auth/register` have no protection against brute-force or abuse. An attacker can make unlimited login attempts or spam registrations with no throttling. ## Work - Add rate limiting middleware to the FastAPI app (e.g., `slowapi` or a custom middleware using a Redis or in-memory counter). - Apply limits to at minimum: `POST /auth/login` (e.g., 10 requests/minute per IP) and `POST /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 limits in `config.py` or as environment variables so they are adjustable without code changes. ## Acceptance Criteria - Making more than the configured number of login requests per minute from the same IP results in HTTP 429. - The rate limit counter resets after the window expires. - Limits are configurable via environment variables. ## Reference Roadmap item: P1 Error handling and resilience — No rate limiting on auth endpoints.
AI-Manager added the P1agent-readysmall labels 2026-03-27 16:22:40 +00:00
Author
Owner

[Triage] Already implemented in main. api.py imports slowapi, configures a Limiter with get_remote_address, and has a rate_limit_handler. tests/test_rate_limit.py provides test coverage. Closing as resolved.

[Triage] Already implemented in main. api.py imports slowapi, configures a Limiter with get_remote_address, and has a rate_limit_handler. tests/test_rate_limit.py provides test coverage. 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#359