mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-12-04 02:29:06 +00:00
fix(recovery): allow 10 recovery starts an hour, not 3 (#307)
Three locked a real owner out for an hour after a few honest retries
("Too many recovery attempts. Try again in 1 minute(s)."). The guess budget
stays negligible: 10 codes x 5 tries an hour against 10^8, and every start
mails the owner. Confirmation links share the same allowance.
Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
parent
e04531b73a
commit
c38ffdeff1
2 changed files with 12 additions and 6 deletions
|
|
@ -308,9 +308,12 @@ test("codes expire after 15 minutes and die after 5 wrong tries", async () => {
|
|||
assert.equal(after.status, 410, "the right code is dead after five wrong ones");
|
||||
});
|
||||
|
||||
test("start is rate limited to 3 per hour per user", async () => {
|
||||
// u_e has used 2 starts above; one more is allowed, the next is not.
|
||||
assert.equal((await call(keys.u_e, "POST", "/api/opencreds/recovery/start")).status, 200);
|
||||
test("start is rate limited per hour per user, with room for honest retries", async () => {
|
||||
assert.equal(vr.STARTS_PER_HOUR, 10);
|
||||
// u_e has used 2 starts above; the rest of the hour's allowance works, the next does not.
|
||||
for (let i = 2; i < vr.STARTS_PER_HOUR; i++) {
|
||||
assert.equal((await call(keys.u_e, "POST", "/api/opencreds/recovery/start")).status, 200, `start ${i + 1}`);
|
||||
}
|
||||
const limited = await call(keys.u_e, "POST", "/api/opencreds/recovery/start");
|
||||
assert.equal(limited.status, 429);
|
||||
assert.equal(limited.body.code, "rate_limited");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue