feat(auth): add login brute-force protection - #2723
Open
koishi514-Z wants to merge 2 commits into
Open
Conversation
lyingbug
reviewed
Aug 20, 2026
| retryAfter = 1 | ||
| } | ||
| return func(c *gin.Context) { | ||
| if !limiter.Allow(c.Request.Context(), c.ClientIP(), max) { |
Collaborator
There was a problem hiding this comment.
这会不会导致公司网络使用同一个出口IP情况下集体被封禁。或者有恶意用户刷接口导致集体429
sakitam-fdd
added a commit
to sakitam-fdd/WeKnora
that referenced
this pull request
Aug 21, 2026
Port Tencent#2723 onto the current fork staging branch using GitHub's three-way merge.
sakitam-fdd
added a commit
to sakitam-fdd/WeKnora
that referenced
this pull request
Aug 21, 2026
Port Tencent#2723 after current-main three-way validation.
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.
Description
Add protection for password login attempts to prevent online brute-force attacks.
POST /api/v1/auth/loginby client IP.Retry-Afterheader when the limit is exceeded.auth.login_rate_limit_maxauth.login_rate_limit_window_minutesType of Change
Related Issue
Fixes #2513
Testing
The following checks passed:
Manual verification:
Start the rebuilt Docker services.
Submit 10 password-login attempts from the same IP.
Verify that the next request returns 429 and includes Retry-After.
Verify that the login page displays the rate-limit notice and countdown, disables password login during the countdown, and re-enables it afterward.
Checklist
git diff --check origin/main...HEADpassesgolangci-lint run --new-from-rev=origin/main ./...)docs/, Swagger annotations, etc.)Screenshots / Recordings