Skip to content

Rate limit all routes with a global default - #31

Merged
amrtgaber merged 1 commit into
mainfrom
rate-limit-all-routes
Jul 28, 2026
Merged

Rate limit all routes with a global default#31
amrtgaber merged 1 commit into
mainfrom
rate-limit-all-routes

Conversation

@amrtgaber

Copy link
Copy Markdown
Contributor

Follow-up to the observation in #27: non-auth routes had no rate limiting at all. Adds a 300/min per-client-IP default to every non-exempt route via the existing in-house middleware (the immune pattern — not slowapi's SlowAPIMiddleware path that FastAPI ≥0.137 breaks), with /, /health, /docs, /openapi.json, and /.well-known/security.txt exempt. Auth endpoints keep their stricter per-path limits and don't double-consume the default bucket. Canary + exemption tests included; 124/124 green.

Auth endpoints kept their strict per-path limits but every other route
was unlimited. Apply a 300/min per-client-IP default to all non-exempt
routes through the existing in-house middleware (immune to the FastAPI
>=0.137 / slowapi issue #281 SlowAPIMiddleware regression), exempting
the infrastructure paths probes and docs rely on. The limit is consumed
regardless of auth outcome, so unauthenticated traffic is capped too.
Add canary and exemption tests plus a limiter-reset fixture so request
counts don't leak across tests.
@amrtgaber
amrtgaber merged commit 86cf06d into main Jul 28, 2026
@amrtgaber
amrtgaber deleted the rate-limit-all-routes branch July 28, 2026 03:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant