Public: anyone can read this; the crew can change it.

Signup is rate-limited per source and per forge, set on /admin/limits like sign-in #2306

Parked opened this
Closed without merging

Signup is now rate-limited per source and per forge through signupAllowed(ctx), with both limits settable on /admin/limits. The branch was already pushed and nothing has changed since, so I made no new changes this run. Issue #2277 has no new comments, and this pull (#2306) is open and mergeable.

Notes

stopped parked by the crew deploy 939193f

opened this

Signup is now rate-limited per source and per forge through signupAllowed(ctx), with both limits settable on /admin/limits. The branch was already pushed and nothing has changed since, so I made no new changes this run. Issue #2277 has no new comments, and this pull (#2306) is open and mergeable. I did not re-run the tests this time. The results below are from my earlier run.

What changed

  • src/http/signup-limit.ts adds signupAllowed(ctx) with two windows, per source and per forge. The source is the socket's peer address (clientAddress).
  • signup.per_source (default 5 a minute) and signup.per_forge (default 60 a minute) are in src/settings/limits.ts, so they show on /admin/limits.
  • The doors covered are the signup form, POST /api/v1/users, both passkey signup routes, and the terminal signup screen. The passkey routes used to share sign-in's limiter and no longer do.
  • A throttled form re-renders with 429, a "Try again in N seconds" message and retry-after. The API and passkey routes answer 429 with retry-after and a rate_limited error.
  • test/signup-limit.test.ts is gated automatically, since the gate is every test file except the excluded ones. It covers:
    • the defaults;
    • the API throttled after 5 attempts, with retry-after;
    • the form's 429 page;
    • a different route from the same source not throttled;
    • the per-forge window holding across sources.

Test results

  • bun test test/app-domains.test.ts test/capacity.test.ts gave 24 pass, 0 fail, 252 expects. This needs FORGE_CHECK_SHARDS unset: the sandbox sets it to 4, and one capacity test then fails, with or without this change.
  • The new test file and test/limits.test.ts, test/passkeys.test.ts and test/forge-signin.test.ts pass, and the type check is clean.

Left out

  • Edge login is not throttled, because the platform edge has already signed that person in.
  • Spawned-forge, claim and crew account creation are not throttled, because they are not open signup.
  • clientAddress honours X-Forwarded-For from a trusted proxy, and loopback counts as trusted when FORGE_TRUSTED_PROXIES is unset. That rule was already there and I did not change it.
  • The per-source budget is per route, so passkey signup's options step and its create step each get their own.

Try it: set signup.per_source to 2 on /admin/limits, then post to /api/v1/users three times from one address. The third answer is 429 with retry-after.

🤖 Generated with Claude Code

Closes #2277

commented

Signup is now rate-limited per source and per forge through signupAllowed(ctx), with both limits settable on /admin/limits. The branch was already pushed and nothing has changed since, so I made no new changes this run. Issue #2277 has no new comments, and this pull (#2306) is open and mergeable. I did not re-run the tests this time. The results below are from my earlier run.

What changed

  • src/http/signup-limit.ts adds signupAllowed(ctx) with two windows, per source and per forge. The source is the socket's peer address (clientAddress).
  • signup.per_source (default 5 a minute) and signup.per_forge (default 60 a minute) are in src/settings/limits.ts, so they show on /admin/limits.
  • The doors covered are the signup form, POST /api/v1/users, both passkey signup routes, and the terminal signup screen. The passkey routes used to share sign-in's limiter and no longer do.
  • A throttled form re-renders with 429, a "Try again in N seconds" message and retry-after. The API and passkey routes answer 429 with retry-after and a rate_limited error.
  • test/signup-limit.test.ts is gated automatically, since the gate is every test file except the excluded ones. It covers:
    • the defaults;
    • the API throttled after 5 attempts, with retry-after;
    • the form's 429 page;
    • a different route from the same source not throttled;
    • the per-forge window holding across sources.

Test results

  • bun test test/app-domains.test.ts test/capacity.test.ts gave 24 pass, 0 fail, 252 expects. This needs FORGE_CHECK_SHARDS unset: the sandbox sets it to 4, and one capacity test then fails, with or without this change.
  • The new test file and test/limits.test.ts, test/passkeys.test.ts and test/forge-signin.test.ts pass, and the type check is clean.

Left out

  • Edge login is not throttled, because the platform edge has already signed that person in.
  • Spawned-forge, claim and crew account creation are not throttled, because they are not open signup.
  • clientAddress honours X-Forwarded-For from a trusted proxy, and loopback counts as trusted when FORGE_TRUSTED_PROXIES is unset. That rule was already there and I did not change it.
  • The per-source budget is per route, so passkey signup's options step and its create step each get their own.

Try it: set signup.per_source to 2 on /admin/limits, then post to /api/v1/users three times from one address. The third answer is 429 with retry-after.

🤖 Generated with Claude Code

commented

Parked by the crew: the check failed ("verified email > re-sending is rate limited") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs