Repository navigation
fix(id-web): rate-limit POST /api/identity/register per source (#1766) - #10674
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 58 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Summary
Implements the #1766 remainder (triage task 11963, 2026-11-16): rate-limit
POST /api/identity/registerin id-web. The admission cap (#4143) already bounds how many identities can exist; the register handler itself was unthrottled, so a caller on a non-loopback bind could burn request-rate CPU/IO and cap-squat slots with junk registrations.Changes
RegisterRateLimiter(id-web/src/lib.rs), following theSaveRateLimiterpattern: a per-source sliding-window limiter (default 10 successful registrations per source per 60s), with the id(web): SaveRateLimiter's per-file map grows without bound — entries expire after the 5s cooldown but are never evicted #1713 sweep discipline — entries are dropped once they can no longer refuse, so the map holds only sources active in the current window. Only successful registrations are counted; a refusal at the admission cap does not consume budget.id-web/src/routes.rs): the source key is the peer IP from the listener's connect-info. Forwarded headers are never consulted — on the direct listener they are client-spoofable (thesecurity.rsdoctrine). Over-limit returns the structured refusal used by the save limiter (id(comms): per-peer frame/byte accounting + structured rate-limit refusal (P0 of #2032) #2244): 429 with aRetry-Afterheader and body{"error": "registration_rate_limited", "reason": "rate_limited", "retry_after_ms": …}.id-cli/src/commands/serve.rs): the web router is now served withinto_make_service_with_connect_info::<SocketAddr>()so connect-info exists in production. The program router served by publication listeners carries no identity routes, so it needs no change.lifecycle-retention-1766.Tests
Retry-After, andGET /api/identity/mefor an already-registered identity still returns 200 (the limit is on registration only).cargo test -p id-web --lib registerfrompkgs/id— see the PR checks/comments for the result line.Queue task 17434, lane code-b. Resumed from an earlier session's checkpoint; its worktree was verified clean with no landed implementation before this change was written.
Closes #1766
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.