Repository navigation
Conversation
People add passkeys in Settings and sign in with their fingerprint, face or screen lock: from the email field's suggestions or a button. Where two-factor is required, a passkey also counts as the second factor, after a password or Google, and the page that requires it offers one as the quickest way. WebAuthn checks live in fctl-domain (with a small CBOR decoder); WebCrypto checks the ES256, EdDSA and RS256 signatures.
- Sign-in challenges are signed, not stored: the sign-in page asks for one on every load without writing rows or using up the rate limit that passkey sign-ins need; a challenge is recorded once used. - Adding a passkey counts and checks for duplicates in its insert, and removing one checks again in its delete, so that racing requests can't pass the limits or leave an account without a way in. - An admin's reset removes passkeys only where they are the second factor required, and never a person's only way in. - Settings and the CLI say when passkeys are the second factor (TwoFactor.on). - The add flow replaces options that ran out, and a retry in the proof dialog gets a new challenge. - The client gets methods for the passkey options, add and sign-in endpoints.
This was referenced Oct 19, 2026
kalaspuff
merged commit Oct 19, 2026
93f6259
into
fctl/49-add-optional-2fa-totp-enforcement-of-all
5 of 6 checks passed
kalaspuff
pushed a commit
to hyperstructure/fctl-site
that referenced
this pull request
Oct 19, 2026
The privacy policy says what app.fctl.sh keeps for two-factor sign-in, which hyperstructure/fctl#103 adds: - **What we collect**: for people who turn it on, or whose admins require it, the secret their authenticator app makes codes from (encrypted), a hash of each recovery code and when it was used, when the app was set up and last used, the count of wrong codes in a row, and whether Google sign-ins ask for a code. While a sign-in waits for its code, who it is for and why it waits, and for a password reset a hash of the new password until the code checks out. - **Cookies**: the third cookie, `__Host-fctl-2fa`, which holds a sign-in waiting for its code for 10 minutes. - **Email**: the notices about two-factor changes, sign-ins with a recovery code and wrong codes after a password, with the purpose and legal basis (legitimate interests: account security) and Resend's row. - **Retention**: two-factor data until it's turned off, reset or the account deleted; new recovery codes replace the old; waiting sign-ins expire after 10 minutes. - **Rights and security**: the export includes two-factor sign-in without its secrets, Settings corrects it, and the security summary names the encrypted secrets and hashed recovery codes. Merge it together with hyperstructure/fctl#103, when that deploys. #23 adds passkeys, with hyperstructure/fctl#104. Session: https://app.fctl.sh/s/ses_01M58KEJWPFJKBCENF5HKRV5HV --------- Co-authored-by: fctl-sh[bot] <343971779+fctl-sh[bot]@users.noreply.github.com>
kalaspuff
pushed a commit
to hyperstructure/fctl-site
that referenced
this pull request
Oct 19, 2026
The privacy policy says what app.fctl.sh keeps for passkeys, which hyperstructure/fctl#104 adds: - **What we collect**: for each passkey, its public key and credential ID (the private key stays on the person's device or with their password manager), its name, the authenticator model (AAGUID, which names the provider), whether it syncs, how the browser reaches it, its signature counter, and when it was added and last used. Also the challenges passkeys sign, for ten minutes. - **Email**: the notice when a passkey is added to an account. - **Retention**: passkeys stay until removed in Settings, the account is deleted, or an admin's reset removes them where the instance requires two-factor; challenges are deleted within an hour of expiring. - **Rights and security**: the export lists passkeys, Settings corrects them, and the security summary says only public keys are kept. Stacked on #22 (two-factor sign-in): merge that first, and this one together with hyperstructure/fctl#104. Session: https://app.fctl.sh/s/ses_01M58KEJWPFJKBCENF5HKRV5HV Co-authored-by: fctl-sh[bot] <343971779+fctl-sh[bot]@users.noreply.github.com>
kalaspuff
pushed a commit
that referenced
this pull request
Oct 19, 2026
…in with passkeys (#104) Adds two-factor sign-in with authenticator apps (TOTP). Anyone can turn it on for themselves, and admins can require it of everyone on the instance. Until now a password, or a password reset link, was enough to get into an account that holds a Claude subscription, starts agents that push to the project's repositories and reads its secrets. ## What people get - **Settings → Two-factor sign-in.** "Set up" opens a dialog with a QR code that ripples in from the middle, the key in groups of four for apps that can't scan, and an "Open in your app" link on phones (iOS and Android hand `otpauth://` links to the passwords app or the authenticator). The code field is a single input drawn as two groups of three boxes, so pasting, the phone's one-time-code suggestions and password managers fill it at once, and it submits on the sixth digit. Then come ten recovery codes to copy, download as a text file, or print on a page of their own. **Replace** (new phone) asks for a code from the current app or a recovery code first. **Turn off** asks for a code too. Recovery codes show how many are left and suggest new ones at three. A switch, **Ask for a code when I sign in with Google too**, sits beside them. - **Signing in.** After a correct password the page asks for the code, showing who is signing in ("Not you?"). A wrong code shakes the boxes, and after the second miss the page says to check that the phone sets its clock automatically. A recovery code works in place of the app code. Five wrong codes in a row make codes from the app wait a minute, then twice as long each time, up to an hour, with a live countdown; recovery codes still work meanwhile. Signing in with a recovery code says how many are left. - **Google.** Google sign-ins don't ask for a code, since Google has its own two-step verification, unless the person turns that on or the admins do for everyone. Then Google's callback lands on `/two-factor`, which finishes the sign-in and goes on to where it started. - **Password resets.** A reset link for an account with two-factor asks for a code, and the new password takes effect only once the code checks out. Whoever reads someone's email can't lock them out with a reset link alone. - **Admin → Settings → Sign-in.** **Require two-factor sign-in** applies to everyone who signs in with a password. **Ask for codes on Google sign-in too** applies to Google sign-ins, and with the requirement on, to people who sign in only with Google. A meter shows how many people use it and who doesn't yet. Turning either switch on when it would stop people asks first and names them, including the admin. Someone it is required of who hasn't set it up sees a page that sets it up instead of the app, and the control plane refuses their other requests, from browser sessions and CLI and access tokens alike, with `two_factor_setup_required`. - **Admin → Users** shows who has two-factor, notes who still has to set it up, and has **Reset two-factor** for people who lost their phone and their recovery codes. Only owners can reset an owner's. - **CLI.** `fctl account two-factor` (or `2fa`) has `status`, `enable` (prints the QR code in the terminal, asks for the code, shows recovery codes; `--json` plus `confirm` without a terminal), `disable`, `recovery-codes` and `google on|off`. Admins get `fctl admin set --require-two-factor on --two-factor-google on` and `fctl admin reset-two-factor <email>`. `fctl whoami` and `fctl admin users` show two-factor too. `fctl login` approves the device in the browser, so the codes are asked for there. - **Email**, when it's set up: turning two-factor on, replacing the app, turning it off, an admin's reset, a sign-in with a recovery code, and the first wait after wrong codes (whoever it was knew the password) email the person. All of these go in the audit log. ## How it works TOTP per RFC 6238 (HMAC-SHA1, six digits, 30-second steps, one step of drift either way), in `fctl-domain` with RFC 4226 and RFC 6238 test vectors. The QR code is made in Rust (`qrcode` crate, no default features), so the web app and the terminal draw the same modules. - **Setup.** Nothing is stored until the app's first code confirms the secret. Until then the secret travels sealed for the person (AES-GCM under the master key, bound to `totp-setup:<user>`, 15 minutes). D1 then keeps it sealed again (`authenticator_apps`, bound to `totp:<user>`), with SHA-256 hashes of the recovery codes (`recovery_codes`). Setting up an app takes the password unless the browser signed in within 15 minutes; CLI and access tokens always count as old. - **Sign-in.** A sign-in that asks for a code starts no session. It leaves a challenge (`sign_in_challenges`, ten minutes, kept by its hash) in an `HttpOnly` `__Host-fctl-2fa` cookie, so the second step works the same after a password, after Google's redirect and after a reset link, and survives a reload. Each code works once (`last_step`). A code is checked, then the challenge claimed, then the code used up, so racing requests yield one session and burn nothing. - **The requirement** is checked on every request without an extra round trip: the token lookup reads the instance's settings in the same query. The reasoning, and what it leaves open (enrollment races, older CLIs showing `two_factor_setup_required` as an HTTP 403), is in [ADR 0022](docs/adr/0022-two-factor-sign-in-with-authenticator-apps.md). docs/architecture.md, docs/security.md, docs/cli.md, docs/self-hosting.md and docs/getting-started.md describe the behavior. **Compatibility.** `AuthResponse.me` becomes optional, since login and reset answer with `two_factor` when a code is needed. Successful sign-ins answer exactly as before, and nothing but the web app reads it. New fields (`Me.two_factor`, `User.two_factor`, the instance settings) are optional with defaults. Migration `0011_two_factor.sql` adds three tables and a column. `ErrorCode::TwoFactorSetupRequired` is new; a CLI from before it shows such errors as an HTTP 403 with the message. ## How I verified it - `cargo xtask check` passes: fmt, generated types, Biome and TypeScript, Clippy native and wasm, `cargo test`, Vitest, production builds. New tests cover the TOTP vectors, base32, replay, the lockout schedule, the policy (who needs it, when Google asks), recovery codes, the QR matrix, the terminal QR (read back module by module), the code input (paste, autofill, six-digit cap), the QR component and the web helpers. - End to end on `cargo xtask dev`, with the CLI, curl and Playwright, computing codes from the secrets: - setting up in Settings and from the CLI (with and without a terminal), and replacing the app (current code first); - signing in with password and code, wrong codes, five wrong codes sent at once (all counted), the wait (app codes refused, recovery codes accepted), a recovery code used twice (refused); - a reset link with two-factor (the old password keeps working until the code is entered); - Google's second step (challenge inserted the way the callback leaves it); - requiring two-factor (the confirmation names who isn't set up), the setup-only page, an access token refused until setup, and an admin reset putting someone back on that page; - the downloaded recovery codes file, and the print view, which shows only the codes, from the dark theme too. - The QR codes in the screenshots decode to the expected `otpauth://` links (jsQR), with the key shown under "Can't scan it?". - A code review pass found seven issues, all fixed here: tokens counting as fresh sign-ins, replacing without a code, wrong codes counted by read-modify-write, the wait being usable to lock owners out, a code burned when a racing request claimed the challenge, the terminal quiet zone, and `fctl admin set` when the requirement also stops the admin. ## Screenshots At 31c7878, from `cargo xtask dev`'s accounts. The code step after the password, and after five wrong codes: | Code | Waiting | |---|---| |  |  | Setting it up in Settings: the QR code with the key behind "Can't scan it?", then the recovery codes, and the section once it's on: | Scan | Recovery codes | |---|---| |  |  |  When the instance requires it, someone without it sees this instead of the app (dark theme, and at 390 px): | Desktop | Phone | |---|---| |  |  | Admin → Settings → Sign-in, the confirmation that names who isn't set up, and Admin → Users:  | Confirmation | Users | |---|---| |  |  | The CLI's `enable`, in a terminal (the QR code prints dark on a light ground with ANSI colors): ``` $ fctl account two-factor enable Scan this with your authenticator app: █▀▀▀▀▀█ █ ▄ ▄█▄ ▀█▄▄▀ █▀▀▀ ▀█▄ █▀▀▀▀▀█ █ ███ █ ▄▀█ ▀▄▀▀ ▀ ▀▄▄ █▄ ▄ ▀▄▄▀ █ ███ █ … Or type in this key: M3K3 E46S BSGG LMTY KBWJ TFXL APJ3 K57W Code from the app: 123456 ✓ Two-factor sign-in is on: signing in with your password now also takes a code. Recovery codes: each one signs you in once if you lose your phone. Save them somewhere safe now, such as your password manager: they are shown once. WCQJK-QRVVQ DJHTP-FXPTT … ``` ## Related - hyperstructure/fctl-site#22: the privacy policy says what two-factor sign-in keeps. Merge the two together. - #104: passkeys, stacked on this pull request. Session: https://app.fctl.sh/s/ses_01M58KEJWPFJKBCENF5HKRV5HV --------- Co-authored-by: fctl-sh[bot] <343971779+fctl-sh[bot]@users.noreply.github.com>
This was referenced Oct 19, 2026
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds passkeys. People sign in with their fingerprint, face or screen lock: no password, no code, and nothing a fake site could catch. Where admins require two-factor sign-in, a passkey also counts as the second factor, so meeting the requirement takes a tap.
Stacked on #103 (two-factor sign-in): review that one first. This pull request's own changes are the commits after it. Once #103 merges,
maingets merged in here.What people get
fctl account passkeys list|rename|remove(adding takes a browser),fctl whoamilists passkeys,fctl admin userscounts them,fctl account two-factorsays when passkeys are the second factor. The client also gets methods for the options, add and sign-in endpoints, which take an authenticator's answer. Like feat: add two-factor sign-in with authenticator apps #103's second step, the passkey second step is cookie-based and browser-only.How it works
userVerification: "required", and no attestation ("none"). Keys: ES256, EdDSA, RS256. The relying party id is the host name ofFCTL_PUBLIC_URL; in development, anylocalhostport.fctl_domain::webauthnchecks what browsers send (client data, origin, relying party hash, user presence and verification, backup flags, COSE keys, DER signatures). It uses a strict, bounded CBOR decoder infctl_domain::cbor. WebCrypto in the Worker checks the signatures (crypto::verify_passkey), so the Worker gains no crypto code.clientDataJSON), so nothing else travels with them. Registration and second-factor challenges are stored by their SHA-256 (passkey_challenges). Sign-in challenges are signed with the master key instead: the sign-in page asks for one on every load, so page loads write nothing and cost no rate limit. A sign-in challenge is recorded once used, so it works once.0012_passkeys.sqladds two tables. The policy infctl_domain::two_factornow takesFactors { authenticator, passkeys }, andTwoFactor.onsays when password sign-ins ask for a second factor. Housekeeping, account deletion and the export cover passkeys.The reasoning is in ADR 0023. docs/architecture.md (Passkeys), docs/security.md, docs/cli.md, docs/self-hosting.md (passkeys belong to the host name) and docs/getting-started.md describe the behavior.
How I verified it
cargo xtask checkpasses. New tests: RFC 8949's CBOR examples, plus refusals of truncated, indefinite, oversized and deeply nested input; WebAuthn registration and assertion checks (wrong type, origin, relying party, presence, verification, backup flags, trailing bytes, unsupported keys); DER signatures; counters; provider names; the passkey policy; base64url and option conversion in the web app.cargo xtask dev:whoami,admin users, and an admin reset that removes a required passkey (and keeps passkeys elsewhere).TwoFactor.on, options outliving their challenge, retries in the proof dialog, a refetch racing a successful verify, a duplicated helper, client methods). One more, the cookie-based second-step endpoints, stays browser-only by design.Screenshots
At 27bc8bc, from
cargo xtask dev's accounts.Signing in: the passkey button, which the email field's suggestions join where the browser has them:
Settings → Passkeys, just after adding one (highlighted), and the page in the dark theme beside two-factor sign-in:
After a password sign-in on a device that can keep passkeys:
Where two-factor is required, the setup-only page offers a passkey first:
The second step with a passkey, alone and next to an authenticator app:
Admin → Users with passkeys (fingerprint) next to authenticator apps (shield):
Related
Session: https://app.fctl.sh/s/ses_01M58KEJWPFJKBCENF5HKRV5HV