-
Notifications
You must be signed in to change notification settings - Fork 537
Rate limiting for login API #2484
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
Rate limiting for login API #2484
Conversation
Important Auto Review SkippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the To trigger a single review, invoke the WalkthroughThe recent update introduces Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
@coderabbitai review |
Quickstart template updates in |
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.
Review Status
Actionable comments generated: 1
Configuration used: .coderabbit.yaml
Files selected for processing (2)
- pyproject.toml (1 hunks)
- src/zenml/zen_server/routers/auth_endpoints.py (3 hunks)
Additional comments: 3
src/zenml/zen_server/routers/auth_endpoints.py (3)
- 30-31: The import statements for
Limiter
andget_remote_address
fromslowapi
are correctly placed and follow Python best practices.- 80-80: Initializing the
limiter
instance withLimiter(key_func=get_remote_address)
is appropriate for rate limiting based on the client's IP address. This setup is suitable for preventing misuse and excessive login attempts.- 262-262: Decorating the
token
function with@limiter.limit("5/minute;1000/day")
effectively implements rate limiting for login attempts. This rate limit is reasonable for preventing brute-force attacks while allowing legitimate users access. Ensure that the chosen rate limits are aligned with the expected usage patterns and consider making them configurable if necessary.
NLP template updates in |
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.
🦭 - Looks good as is, feel free to unify with cloud rate limiting
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.
I love how simple slowapi
is. I don't recommend we use fastapi_limiter for this, it's overkill.
I already closed the original vulnerability as informational on account of us not advertising the username/password authentication method as a full-fledged production-grade security scheme. If slowapi
doesn't work out, we could also give up and not fix this at all.
good catch - forgot about redis |
…-page-allows-bruteforce-attack
E2E template updates in |
…-page-allows-bruteforce-attack
docs/book/deploying-zenml/zenml-self-hosted/deploy-with-docker.md
Outdated
Show resolved
Hide resolved
Co-authored-by: Alex Strick van Linschoten <[email protected]>
…-page-allows-bruteforce-attack
Quickstart template updates in |
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.
Everything looks great. I love the minimalistic limiter implementation, definitely a lot better than having to hack our way into slowapi. I left a couple of comments with improvement suggestions. I leave it up to you if you want to address them or not.
Co-authored-by: Stefan Nica <[email protected]>
…-page-allows-bruteforce-attack
* set rate limits for login api * Auto-update of Starter template * Auto-update of NLP template * properly handle exceptions * configurable rates * Auto-update of E2E template * relax rate limit for tests * relax rate limit for tests * relax rate limit for tests * relax dev server rate limits * reduce limiter on successful requests * relax limit in tests again * toggle for rate limiting * darglint * update docs * Update docs/book/deploying-zenml/zenml-self-hosted/deploy-with-docker.md Co-authored-by: Alex Strick van Linschoten <[email protected]> * Auto-update of Starter template * use own rate limiter * lint and docstrings * check limits before processing request * review suggestions * Update src/zenml/zen_server/utils.py Co-authored-by: Stefan Nica <[email protected]> * review suggestions * fix 3.8/3.9 --------- Co-authored-by: GitHub Actions <[email protected]> Co-authored-by: Alex Strick van Linschoten <[email protected]> Co-authored-by: Stefan Nica <[email protected]>
Describe changes
I fixed the missing rate limit for login API to prevent misuse and too frequent login attempts.
Pre-requisites
Please ensure you have done the following:
develop
and the open PR is targetingdevelop
. If your branch wasn't based on develop read Contribution guide on rebasing branch to develop.Types of changes
Summary by CodeRabbit