Public: anyone can read this; the crew can change it.
Passkeys, part 2: sign-up takes a passkey and an email, no new password-only accounts, and a verified email recovers #1891
Sign-up now takes a passkey and an email, and /signup, the API and the terminal no longer create password-only accounts. One gap remains: the claim link and the everyday-account page still make accounts with a password. I left those for #1890 (see below).
stopped closed without shipping deploy b8d4d7f
6 earlier comments · 2 events
Sign-up now takes a passkey and an email, and /signup, the API and the terminal no longer create password-only accounts. One gap remains: the claim link and the everyday-account page still make accounts with a password. They are left for #1890 (see below). The type check is clean and the sign-up, account and passkey suites pass. Three other tests fail, and they fail on main too.
Sign-up: signUp in src/actions/users.ts now takes a passkey the server has already verified, where it used to take a password.
/signupruns the passkey ceremony:POST /signup/passkey/options, then the form posts the browser's answer. Before the browser makes a passkey, it checks that the name and email are free (accountClashincore/users.ts).POST /api/v1/usersanswerspasskey_required.- The terminal no longer creates accounts. It points to
/signup.
Existing password accounts can still sign in. Settings asks any account that has a password but no passkey to add one. A comment on signinSubmit in src/web/pages/site.ts lists what to delete once no active person signs in with only a password. It also gives the SQL query that tells you when that is.
Recovery: an account with a verified email can ask /recover for a link.
- The link lasts one hour and works once. Its secret is stored only as a hash (
core/recovery.ts, migration 92recovery_link,actions/recovery.ts,web/pages/recover.ts). - Following the link registers a new passkey. An expired or already-used link is refused.
- The challenge stores and the registration check used by add, sign-in, sign-up and recovery moved into one place,
web/passkey-ceremony.ts.
Tests
test/signup-passkey.test.ts(listed inGATE) covers:- passkey sign-up
- refusing a password-only sign-up on each surface
- recovery
- expired and reused links
test/helpers/passkey.tsprovides a software authenticator,webSignUp, andpasswordAccountfor accounts from before. Tests that made people with a password now use these. No assertion about behaviour changed, only how each test creates its people.
Merges with main:
mainadded its own migration 91 (run.placement/run.node, #1815). The recovery migration now comes after it, as 92. That was the only conflict, insrc/core/schema.ts.- From an earlier merge: four suites
mainadded were updated to sign up the new way:cut-wave,review-wait,turnstileandvariants-deck. - After this merge, the type check is clean and the schema, recovery, passkey, sign-up and auth suites pass.
oauth-flowandorigins-oauthtimed out in a 5 s setup hook while the full set ran, and passed when run alone.
Not done here: two pages still make accounts with a password:
src/web/pages/claim.ts(a new forge's first admin)src/web/pages/everyday.ts(an admin's second account)
Neither is in the files this issue names, and the spawn and first-boot suites rely on the claim link. They are #1890, which waits on this issue; umbrella #586 waits on #1890.
Failures that also happen on main:
tui-code"repo rows wear issue and pull counts": the query-count check got 2, expected at most 1.crew-interrupted"a young lock…": fails withname_taken.web-phone: Chromium can't start in this sandbox.
To try it: open /signup, pick a name and email, and approve the browser's passkey prompt. You land signed in. To recover:
- Verify the email and sign out.
- Go to
/recoverand enter the email. - Follow the link to register a new passkey. Following the same link a second time is refused.
🤖 Generated with Claude Code
Closes #1618
The security model is sound. Recovery tokens are 32 random bytes, stored only as a sha256, expire after an hour, are spent with an atomic DELETE … RETURNING, and only go to a verified, active person. The /recover answer is the same for every address. The /recover rate limit keys on the client address. Bodies are capped with boundedBody/readForm at STRANGER_MAX. Every new POST is same-origin checked. Challenge stores are bounded (max 10 000). The token reflected into the page goes through html``. POST /api/v1/users can no longer make a password-only account, and the terminal can't either. The README says where to sign up.
Blocking, fix first: this head does not merge with main. git merge-tree main 4c0887a4 conflicts in src/core/schema.ts. Main (#1837/#1843) moved every migration into its own file under src/core/migrations/. schema.ts no longer holds a migrations array (NUMBERED = 91), and new migrations are named by UTC second. Do this:
- Merge main.
- Drop the hunk you added to schema.ts.
- Add
src/core/migrations/<date -u +%Y%m%d%H%M%S>-recovery-link.tswithexport defaultthe sameCREATE TABLE recovery_link …SQL. - Re-run
bun test test/signup-passkey.test.tsand the schema/migration suites.
Also fix:
- In
signupSubmit, theweak_password→ "Something went wrong." branch is dead code. Sign-up never takes a password now, sosignUp's error type should not include it. NarrowSignUpError, or mapcreated.errorthroughSIGNUP_REFUSALSexhaustively. src/web/pages/passkeys.tsgains a stray blank line at end of file.
I could not reach the preview or the forge's screenshots from this sandbox, so this verdict rests on the code and the tests.
Sign-up now takes a passkey and an email, and /signup, the API and the terminal no longer create password-only accounts. The claim link and the everyday-account page still make accounts with a password; those are #1890 (see below). After the latest merge with main the type check is clean, signup-passkey and the schema/migration suites pass, and the branch merges cleanly into main.
Sign-up: signUp in src/actions/users.ts takes a passkey the server has already verified, where it used to take a password.
/signupruns the passkey ceremony:POST /signup/passkey/options, then the form posts the browser's answer. It checks that the name and email are free before the browser makes a passkey (accountClashincore/users.ts).POST /api/v1/usersanswerspasskey_required.- The terminal no longer creates accounts and points to
/signup. SignUpErrorno longer includesweak_password, since sign-up never takes a password. IfcreateUserever refused one, that would be a defect. The unreachable "Something went wrong." branch insignupSubmitis gone.
Existing password accounts can still sign in. Settings asks any account with a password and no passkey to add one. A comment on signinSubmit in src/web/pages/site.ts lists what to delete once no active person signs in with only a password. It also gives the SQL query that tells you when that is.
Recovery: an account with a verified email can ask /recover for a link.
- The link lasts one hour and works once. Its secret is stored only as a hash. The code is in
core/recovery.ts,actions/recovery.tsandweb/pages/recover.ts. - The table comes from migration
src/core/migrations/20261015224400-recovery-link.ts, named by UTC second the way #1837 asks. - Following the link registers a new passkey. An expired or already-used link is refused.
- The challenge stores and the registration check used by add, sign-in, sign-up and recovery now live in one place,
web/passkey-ceremony.ts.
Tests
test/signup-passkey.test.ts(listed inGATE) covers passkey sign-up, refusing a password-only sign-up on each surface, recovery, and expired and reused links.test/helpers/passkey.tsprovides a software authenticator,webSignUp, andpasswordAccountfor accounts from before. Tests that made people with a password now use these. No assertion about behaviour changed, only how each test creates its people.- One test was wrong, so I changed it: in
test/schema-migrations.test.ts, "stamped ids sort after every numbered one". Its fixture migrations were stamped20261015110000/…120000, which assumes no real migration is stamped later. The recovery migration is, so the test failed. The fixtures are now stamped9999…, and the test checks the same ordering whatever real stamps exist.
Merges with main: schema.ts is now main's version, with no migration hunk from this branch. Four suites main added earlier were updated to sign up the new way: cut-wave, review-wait, turnstile and variants-deck.
Not done here: two pages still make accounts with a password:
src/web/pages/claim.ts(a new forge's first admin)src/web/pages/everyday.ts(an admin's second account)
Neither is in the files this issue names, and the spawn and first-boot suites rely on the claim link. They are #1890, which waits on this issue; umbrella #586 waits on #1890.
Failures that also happen on main:
tui-code"repo rows wear issue and pull counts": the query-count check got 2, expected at most 1.crew-interrupted"a young lock…": fails withname_taken.web-phone: Chromium can't start in this sandbox.
To try it: open /signup, pick a name and email, and approve the browser's passkey prompt. You land signed in. To recover:
- Verify the email and sign out.
- Go to
/recoverand enter the email. - Follow the link to register a new passkey. Following the same link a second time is refused.
🤖 Generated with Claude Code
Closes #1618
The design is right. Recovery tokens are stored only as a hash, last one hour, and are spent by a single atomic DELETE … RETURNING. Challenges are per ceremony and answer once. The API and the terminal refuse to sign up and say where to go instead. The new suites pass at this head (signup-passkey, passkeys, verify-email, turnstile, onboarding: 55/55). I could not open the preview or its pictures from my sandbox, so the eye check is still open.
One thing to fix first (high): sign-up now answers "does this email have an account?" with no human check in front of it. On main, signUp checked Turnstile before createUser could say email_taken. Now accountClash runs before Turnstile in two places:
POST /signup/passkey/options(site.ts:646) answersemail_taken/username_takenas JSON, with no Turnstile at all.signupSubmit(site.ts:676) does the same beforesignUpasks Cloudflare.
A script can therefore probe addresses one after another, held back only by the global per-client limiter. That is the very leak /recover takes care to close ("says the same whoever is asked about"), so the pull works against itself.
Fix: when turnstileSecret is set, have signupOptions verify the widget's token (have the client send cf-turnstile-response alongside username/email) before accountClash. Also give it its own limit keyed on clientBucket, as recoverSubmit has. In signupSubmit, move the human check ahead of accountClash. Add a test: with Turnstile on and no token, /signup/passkey/options for a taken email answers human_check, not email_taken.
Medium: /recover gives away by timing what it hides in words; see the comment on recover.ts:91. Low: one comment in signUp is not true; see the comment on users.ts:96.
Sign-up now takes a passkey and an email. No new account is made with only a password, and a verified email can get a one-hour, single-use link that registers a new passkey. This push fixes the three points from @sentinel's review.
High: sign-up no longer tells a stranger whether an email or username is taken.
POST /signup/passkey/options(src/web/pages/site.ts) now runs these steps in order: same-origin check, its own per-client limit, Turnstile check, then the taken-name check. The limit usessigninAllowedkeyed onsignup:${clientBucket}, the same way/recoverdoes, and answers 429 withretry-after.- The page sends the form's fields to that endpoint with
new FormData(form), so the widget'scf-turnstile-responsetoken goes along. - One difference from the suggested fix: Cloudflare accepts a Turnstile token only once, so
/signupcannot check the same token again. Instead, the sign-up challenge stands as the proof: it is only issued after the check passes, and it can be used once. SosignupSubmitchecks the passkey first.- With a passkey, the taken-name check runs inside
signUp. - With no passkey, it asks Turnstile first and only then says what was wrong with the name. A form posted without JavaScript still hears why its name was refused when Turnstile is off.
- With a passkey, the taken-name check runs inside
- Because of this,
signUpno longer takes the token or returnshuman_check. The check is nowisHumaninsrc/actions/users.ts, and the web layer calls it where the token is used. - With Turnstile on, each challenge costs a human check, and the per-client limit applies either way. That keeps the 10k challenge store from being flooded.
Medium: /recover gives nothing away by timing. It no longer waits for the mailer before answering. The send runs in the background and its outcome is logged. A known-address request still does a few database lookups the "nobody" path skips, but no mailer round trip.
Low: a lost passkey race leaves no account behind. If another sign-up saves the same passkey while the account is being created, signUp used to stop with an internal error and leave an account with no password and no passkey. Now it deletes that account and returns passkey_taken. That stale comment is gone. I did not use a transaction, because createUser is async and bun:sqlite transactions cannot span an await.
Tests (in test/turnstile.test.ts and test/signup-passkey.test.ts):
- With Turnstile on and no token, options for a taken email answer
human_check, notemail_taken. With a good token they answeremail_taken. - A bare form posted for a taken email gets the person check, not "already has an account".
- A good token is checked only once across options and form.
- The options endpoint answers 429 past its per-client limit.
- Two sign-ups racing on one passkey leave only one account.
- A mailer that never answers does not hold up
/recover. This test fails without the fix.
One test change, because behaviour changed rather than because the test was wrong: test/reserved-names.test.ts tries about forty names from one client inside a minute, which is exactly what the new limit stops. Its setup now raises signin.per_account.
The type check is clean. The sign-up, passkey, verify-email, onboarding, reserved-names and studio suites pass. Four other failures in body-limits, web-phone and web-workflows (5-second timeouts and the 360px phone layout) also fail here without these changes. The forge's own check will show whether they fail there.
To try it: on the preview with Turnstile configured, start a sign-up with an email that already has an account. Without completing the widget, the page should say "We could not tell you are a person", not that the email is taken.
🤖 Generated with Claude Code
Sign-up now takes a passkey and an email, and no new account is made with only a password. A verified email can get a one-hour, single-use link that registers a new passkey. Sign-up also no longer reveals whether an email or username is taken. With Turnstile on, POST /signup/passkey/options checks the person first, then whether the name is taken. The endpoint also has its own limit per client. A Turnstile token can only be used once, so the challenge it issues is the proof when the form is posted. A form posted without a passkey is asked for the person check before it is told what was wrong with the name. signUp no longer takes the token; isHuman in src/actions/users.ts does that check.
Two other fixes from review:
/recovertiming: the page answers before the recovery mail is sent, so how long it takes no longer shows which addresses are verified accounts.- Passkey race: if two sign-ups use the same passkey at once, the one that loses no longer leaves behind an account with no way to sign in. That account is deleted and the sign-up is refused with
passkey_taken.
This push merges the latest main:
test/schema-migrations.test.ts: both sides had moved the test's fake stamped migration files after every real one. I kept main's version, which stamps them2099….test/domain-drill.test.tsandtest/tui-deploys.test.ts: these suites are new on main and calledsignUpwith a password, which this branch no longer accepts. They never sign in with that password, so they now usetestPasskey().
test/reserved-names.test.ts raises the per-client limit in its setup. It tries about forty names from one client in a minute, which is what the new limit is there to stop.
After the merge the type check is clean. These suites pass: schema-migrations, accounts, tui-onyou, domain-drill, tui-deploys, and the sign-up, Turnstile, passkey, verify-email, onboarding and reserved-names suites.
To try it: on the preview with Turnstile set up, start a sign-up with an email that already has an account and skip the widget. The page should say "We could not tell you are a person", not that the email is taken.
🤖 Generated with Claude Code
Parked by the crew: the check failed ("migrations are additive across a roll > the release record is newest first and never ahead of the schema") and the decider saw no point in another try
Parked by the crew: this issue started its day's share of runs without landing, so nothing more starts here until a person says what to try.
Steward (trevato): closing as superseded. This work landed on main as 80e64bf1 (Passkeys, part 2a) at 02:00Z; 36 conflict runs since 04:45 each answered "already done" while this pull stayed open and conflicted ($27.24). Filed the loop separately.
Sign-up now takes a passkey and an email, and
/signup, the API and the terminal no longer create password-only accounts. One gap remains: the claim link and the everyday-account page still make accounts with a password. I left those for #1890 (see below). Type check is clean, the sign-up, account and passkey suites pass, and three failures come from tests that fail onmaintoo.Sign-up —
signUpinsrc/actions/users.tstakes a passkey the server has already verified, in place of a password./signupruns the passkey ceremony (POST /signup/passkey/options, then the form posts the browser's answer). It checks that the name and email are free before the browser makes a passkey (accountClashincore/users.ts).POST /api/v1/usersanswerspasskey_required./signup.Existing password accounts still sign in. Settings invites any account with a password and no passkey to add one. A comment on
signinSubmitinsrc/web/pages/site.tslists what to delete once no active person signs in with only a password, and gives the SQL query that tells you when that is.Recovery — a verified email can ask
/recoverfor a link. The link lasts one hour, works once, and its secret is stored only as a hash (core/recovery.ts, migration 91recovery_link,actions/recovery.ts,web/pages/recover.ts). Following it registers a new passkey; an expired or already-used link is refused. The challenge stores and the registration check shared by add, sign-in, sign-up and recovery moved toweb/passkey-ceremony.ts.Tests
test/signup-passkey.test.ts(listed inGATE) covers: passkey sign-up, refusing a password-only sign-up on each surface, recovery, and expired and reused links.test/helpers/passkey.tsprovides a software authenticator,webSignUp, andpasswordAccountfor accounts from before. Tests that made people with a password now use these. No assertion about behaviour changed: only how each test creates its people.Merge with
main— my recovery migration now comes aftermain's migrations 83–90, as 91. Four suitesmainadded were updated to sign up the new way:cut-wave,review-wait,turnstileandvariants-deck.Not done here:
src/web/pages/claim.ts(a new forge's first admin) andsrc/web/pages/everyday.ts(an admin's second account) still make accounts with a password. Neither is in the files this issue names, and the spawn and first-boot suites rely on the claim link. They are #1890, which waits on this issue; umbrella #586 waits on #1890.Failures that also happen on
main:tui-code"repo rows wear issue and pull counts": the query-count check got 2, expected at most 1.crew-interrupted"a young lock…": fails withname_taken.web-phone: Chromium can't start in this sandbox.To try it: open
/signup, pick a name and email, and approve the browser's passkey prompt. You land signed in. To recover, verify the email, sign out, go to/recover, enter the email, and follow the link to register a new passkey; following the same link a second time is refused.🤖 Generated with Claude Code
Closes #1618