fix: 管理员 IP 锁定不再阻断已认证 Cookie 与 API 令牌

This commit is contained in:
Nixevol
2026-09-30 10:43:13 +08:00
parent 479a08ee11
commit 8b4da3dc05
3 changed files with 87 additions and 6 deletions
+2 -6
View File
@@ -43,12 +43,8 @@ func (h *Handler) auth(next http.HandlerFunc) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ip := httpx.ClientIP(r, h.trusted)
if locked, retry := h.locks.Check(auth.LockKey{Kind: auth.LockAdminIP, IP: ip}); locked {
w.Header().Set("Retry-After", formatRetryAfter(retry))
httpx.WriteError(w, http.StatusTooManyRequests, "rate_limited", "登录已锁定,请稍后再试")
return
}
// 锁定只拦密码登录(login.go)与错误令牌试错累计;
// 已认证的 Cookie / 合法 API 令牌在锁定期仍可用(对齐 PRD D18)。
p, errCode, errMsg, status := h.authenticate(r, ip)
if status != 0 {
if status == http.StatusTooManyRequests {