fix: make rate limiting auth-aware under shared proxy ips#412
fix: make rate limiting auth-aware under shared proxy ips#412lc0rp wants to merge 5 commits intoopenclaw:mainfrom
Conversation
|
@lc0rp is attempting to deploy a commit to the Amantus Machina Team on Vercel. A member of the Team first needs to authorize it. |
fix header precedence in docs to match code Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
|
@greptileai I addressed the comments. Thoughts? |
|
Looks good! Both issues are resolved:
The auth-aware enforcement logic is clear, the retry/header parsing improvements are solid, and test coverage looks thorough. Good to merge. |
|
@greptileai Do you edit the score added to the description when comments are addressed? |
|
No, I don't automatically edit the score in the PR description when comments are addressed. The score reflects my assessment at the time of the last full review (commit If you'd like an updated score after addressing comments, you would typically:
The score in the description is essentially a snapshot from that review moment, not a living counter that updates as discussion progresses. |
|
Gotcha, @greptileai re-review the PR and update the score |
Summary
Today, API rate limiting blocks based on IP or key. In proxied/shared-egress environments, IP sharing can deny legitimate authenticated users.
Ref issues: #349, #390
x-forwarded-for->x-real-ip->fly-client-ipauth,userAllowed,ipAllowed,ipSource,hasClientIp)Rationale
ip OR keydeny behavior can block valid authenticated users behind shared egress/proxy IPsx-forwarded-forfirst hop is the more common client-IP signal in trusted proxy chainsWork done
convex/lib/httpRateLimit.tsx-forwarded-forfirstconvex/lib/httpRateLimit.test.tsconvex/httpApiV1.handlers.test.tsdocs/http-api.md,docs/api.mdTesting
bun run lint bunx vitest run convex/lib/httpRateLimit.test.ts convex/httpApiV1.handlers.test.ts bun run testChecklist
Tag-teamed w/ codex 5.3 on this 🤖
Fixes #411, #349, #390
Greptile Summary
Modified rate limiting from IP OR key enforcement to auth-aware enforcement: authenticated requests now consume only user buckets, while anonymous requests use IP buckets. This prevents legitimate authenticated users from being blocked by shared proxy IPs while preserving IP-based protection for anonymous traffic.
Key changes:
x-forwarded-for→x-real-ip→fly-client-ip(more common proxy pattern)Retry-Afterheaders with jitterX-RateLimit-*) and standardized (RateLimit-*) formatsConfidence Score: 5/5
Last reviewed commit: a176658