-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
Request to support rate limit mechanism #4044
Comments
目前 halo 本身就是引入了google guava 的可以直接使用 guava 提供的 RateLimiter https://github.com/google/guava/blob/master/guava/src/com/google/common/util/concurrent/RateLimiter.java |
/assign |
Hi! I have tried adding a login rate limiter with google guava. Does it look correct? |
Thanks for your investigation! But I have three questions to the implementation:
Would love to hear your feedback. |
Thank you for your advice! Based on the implementation of Guava Rate Limiter, it is not a blocking operation. In the codes, the For question 2 and 3. I think we can define a ApiRateLimiter class like below, which includes an object to map users' IP addresses to rate limiters. This class can be used whenever needed.
|
I also made a simple implementation about Rate Limit mechanism using https://github.com/resilience4j/resilience4j. Please see https://github.com/halo-dev/halo/compare/main...JohnNiang:halo:feat/rate-limit?expand=1 for more. Why should I choose the resilience4j?
|
Your code looks complete and well-structured. I am not sure if there is still any part that I can contribute to at this point. I would be happy to help in any way I can. |
/milestone 2.7.x |
Hi @JustinLiang522 , I will try to implement rate limit for login endpoint, and you can have a try on comment endpoint. /assign |
#### What type of PR is this? /kind feature /area core #### What this PR does / why we need it: This PR introduces https://github.com/resilience4j/resilience4j to archive the feature. The login endpoint has limited login failures at a rate of 3 per minute. See #4044 for more. #### Which issue(s) this PR fixes: Fixes #4044 #### Special notes for your reviewer: 1. Start Halo. 2. Try to login with incorrect credential 4 times 3. Check the response. #### Does this PR introduce a user-facing change? ```release-note 增加登录失败次数限制功能 ```
#### What type of PR is this? /kind feature /kind core #### What this PR does / why we need it: This PR limited comment creation at a rate of 10 per minute. See #4044 for more. #### Special notes for your reviewer: 1. Start Halo. 2. Create 11 new comments 3. Check the response. #### Does this PR introduce a user-facing change? ```release-note 增加发表评论频率限制功能 ```
Your current Halo version
2.7.0-SNAPSHOT
Describe this feature
Currently, everyone can request all APIs without limit, such as
login
andcomments
APIs, which is very dangerous and provides opportunity for brute-force attack and injecting large amounts of invalid data.Learn more about RateLimit, please refer to
Additional information
/kind feature
/area core
The text was updated successfully, but these errors were encountered: