Skip to content

fix(auth): 移除共享 IP 限流中间件,避免正常登录被误拦截 - #325

Open
xiaocheny214 wants to merge 1 commit into
1024XEngineer:mainfrom
xiaocheny214:fix/ratelimit
Open

fix(auth): 移除共享 IP 限流中间件,避免正常登录被误拦截#325
xiaocheny214 wants to merge 1 commit into
1024XEngineer:mainfrom
xiaocheny214:fix/ratelimit

Conversation

@xiaocheny214

Copy link
Copy Markdown
Contributor

Summary

  • 删除 RateLimitMiddleware 及其在 create_app 中的装配。该中间件把 /auth/login/auth/register/auth/send-code 等认证动作和普通 API 都按 IP 计入同一组 Redis 桶,共享出口 IP 或页面流量会把正确密码登录误拦成 429。
  • 用户级桶因中间件顺序在 AuthMiddleware 之前,实际上拿不到 user_id,声明的 120 次/分钟从未生效。
  • 保留账号级保护:密码连续失败锁定、发码 60 秒冷却。本次不改业务响应 envelope、JWT 时效或登录页 UI。

Fixes #292

变更

  • 删除 backend/packages/app/src/windup_app/web/middleware/ratelimit.py
  • create_app 不再注册 RateLimitMiddleware;请求路径变为 CORS → Auth → 路由

Test plan

  • create_app() 可正常装配
  • import-linter 两条分层契约 KEPT
  • auth/user 相关测试 80 passed
  • 同一 IP 在一分钟内已有其他认证端点或普通 API 流量后,连续正确密码登录不再被 429 误拦
  • /auth/send-code 单邮箱 60 秒冷却仍生效
  • 错误密码达到既定阈值后仍会锁定,成功登录后错误计数按现有契约清理

Made with Cursor

RateLimitMiddleware 把登录/注册/发码等认证动作和普通 API 都按 IP 计入同一组桶,共享出口 IP 和页面流量会把正常登录误拦成 429。账号级错误密码锁定和发码冷却仍保留。

Fixes 1024XEngineer#292

Co-authored-by: Cursor <cursoragent@cursor.com>
@vercel

vercel Bot commented Aug 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
windup Ignored Ignored Preview Aug 14, 2026 3:06pm

@codecov

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

本次检查了固定提交范围 10798cb76cb7832089ed1265ee1cdbf7ca3f6bb7...27e63275527dfaf2fb98ab792865c325e95dbc87,重点覆盖应用中间件装配、认证白名单、账号级登录失败锁定和验证码冷却。移除 RateLimitMiddleware 后没有发现残留导入或会破坏现有认证流程的变更;按 issue #292 约定,粗粒度限流由外部 nginx 网关承担,因此没有可提交的代码审查问题。

已验证:git diff --check、相关 Python 文件语法编译、删除模块的全仓库引用检查均通过。环境未安装 uvpytest,因此未能运行测试套件和 import-linter。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: 认证限流共享 IP 计数桶导致正常登录被误拦截

1 participant