-
Notifications
You must be signed in to change notification settings - Fork 0
Add ratelimiting #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ratelimiting #37
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds rate limiting to the API using SlowAPI with Redis as the storage backend. The implementation protects authentication endpoints (OTP send/validate) and expensive external API operations (Hackatime integrations) from abuse while maintaining a reasonable default limit for all other endpoints.
Key changes:
- Created centralized rate limiting configuration in
lib/ratelimiting.pywith Redis storage - Integrated SlowAPI middleware and exception handling into the FastAPI application
- Applied strict rate limits (5/hour) to OTP authentication endpoints
- Applied moderate rate limits (5/minute) to Hackatime integration endpoints
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
lib/ratelimiting.py |
New module defining rate limiter configuration with Redis backend, default 120 requests/minute |
main.py |
Integrated SlowAPI middleware, exception handler, and limiter into FastAPI app; improved import organization |
api/v1/auth/main.py |
Applied 5/hour rate limits to OTP send and validate endpoints |
api/v1/users/main.py |
Applied 5/minute rate limits to Hackatime time recalculation and account linking retry endpoints |
api/v1/projects/main.py |
Applied 5/minute rate limits to Hackatime project link/unlink endpoints |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
thesleepyniko
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
No description provided.