This repository was archived by the owner on Oct 5, 2026. It is now read-only.
Repository navigation
Rate-limit numbers: magic-link 429 tests and documented quotas with reasoning - #52
Merged
Merged
Conversation
…easoning Refs #12 Co-Authored-By: Colonizer <noreply@colonizer.dev>
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Closes the remaining unverified half of #12. The enforcement (#42 password,
#43 magic links) already shipped; what was missing was the last acceptance
box — "limits documented with the reasoning for each number" — plus any
assertion of the numbers at all.
What changed and why:
crates/auth-magic-link/tests/magic_link.rs: the test kit now wires aFakeRateLimiter(default allow-all, so existing tests are unaffected) andgains two tests mirroring the password suite — a denied limiter yields 429
Retry-Afterwith zero mails and zerosingle_use_tokensrows, and onerequest produces >= 2
limit()calls, proving the normalized email is akey alongside the caller (so a botnet cannot walk past the per-IP limit).
crates/auth-password/README.mdandcrates/auth-magic-link/README.md:new "Rate limits" sections tabling every limit with its reasoning —
login per-IP 10/min, per-email 5/15min, lockout 10 failures/hour + 15-min
freeze, magic-link request per-IP 5/10min and per-email 3/hour,
registration/change per-IP (the proposal sets no number there; the docs say
so and recommend the login IP-bucket policy). Both sections state plainly
that this repo owns the key strings (
auth-password:,auth-magic-link:over
rate_limit_keys(ip, email)) and the 429/Retry-Afterbehavior whilethe numeric quotas live in harness
RateLimiteradapter/deployment config.Notes for reviewers:
clears a password lockout (zero lockout-column writes outside auth-password
and
set_password_hash); the docs describe bypass + 15-min age-out, notclearing. Neither README previously claimed otherwise, so no correction
was needed there.
check in
requestruns before the account lookup), so the limit cannot beused as an account oracle. A second flagged line (password change clearing
the lockout) turned out to be correct —
changecallsset_password_hash,which resets all three lockout columns (
store.rs:1550-1569).pinned by
the_defaults_are_the_ones_the_docs_quote(
crates/auth-password/src/lib.rs:306-312); no change needed.touched; no handler, lockout, migration, or harness-config changes.
How verified:
cargo test -p factory0-auth-magic-link --test magic_link: 14 passed,0 failed (12 existing + 2 new).
cargo test -p factory0-auth-password: all green (20 unit + 2conformance + 16 integration + 1 doctest).
cargo fmt --checkandcargo clippy -p factory0-auth-magic-link --all-targetsclean.Closes #12
🤖 Generated by Colonizer in a microVM