Repository navigation
feat(rate-limit): SlowAPI rate limiting for critical routes (#62) - #84
Open
SarthakB11 wants to merge 1 commit into
Open
SarthakB11 wants to merge 1 commit into
SarthakB11 wants to merge 1 commit into
Conversation
Adds a global SlowAPI limiter wired in main.py (state.limiter, RateLimitExceeded handler, SlowAPIMiddleware) and a new app/limiter.py module so routers can import the shared instance without circular imports. Rate limits applied per issue avantifellows#62: - POST /auth/create-access-token -> 2/second - POST /auth/refresh-token -> 2/second - POST /user/ -> 10/second The two /auth/ handlers gain a 'request: Request' parameter, which SlowAPI requires for key extraction via get_remote_address. Fixes avantifellows#62
Author
|
@suryabulusu bumping this, still mergeable and rebased on main whenever you have a chance to look. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements #62.
What
Wires SlowAPI into the FastAPI app and applies per-route limits on the three endpoints flagged in the issue:
The limiter uses `slowapi.util.get_remote_address` as the rate-limit key and returns HTTP 429 via SlowAPI's default `_rate_limit_exceeded_handler` on violation.
How
Scope notes
Verification
Smoke-tested locally with a minimal FastAPI + TestClient harness replicating the wiring: first two requests return 200, third returns 429 as expected. Pre-commit checks (black, flake8) pass on all touched files.