Skip to content

Sign in with passkeys - #27

Merged
ssenerg merged 1 commit into
mainfrom
passkeys
Oct 25, 2026
Merged

ssenerg merged 1 commit into
mainfrom
passkeys

Conversation

@ssenerg

@ssenerg ssenerg commented Oct 25, 2026

Copy link
Copy Markdown
Owner

Stacked on #26 (gallery), which is stacked on #25 (folder share end dates). Merge #25, then #26, then this one.

What it does

  • Passkeys in the account menu (/.auth/passkeys): add one per device, up to 10, after confirming your password. Each one shows when it was added and last used, and can be deleted.
  • Sign-in page:
    • a Sign in with a passkey button;
    • the browser offers your passkeys in the username autofill (autocomplete="username webauthn", conditional mediation).
  • No second code. A passkey is a second factor in itself, so two-factor sign-in asks for no code after one.
  • Admin password reset deletes passkeys. A new temporary password (admin page or goftp user passwd) deletes the user's passkeys, as after a break-in. Changing your own password keeps them.

How it works

  • Uses github.com/go-webauthn/webauthn v0.18.2. Credentials are discoverable, user verification is required, and no attestation is requested.
  • Site binding:
    • the passkey's site ID is the request's host name and its origin is c.BaseURL(), so passkeys are bound to the host the site is reached at;
    • browsers only allow passkeys over HTTPS or on http://localhost (not on bare IP addresses).
  • Ceremony state is kept in memory: 5 minutes, one use, at most 10,000 at a time.
  • Rate limits:
    • starting a passkey sign-in is limited to 30 a minute per client;
    • a refused passkey counts against the client's existing failure budget;
    • adding one goes through the existing password check limits.
  • Storage: migration 012 adds a passkeys table holding the credential record as JSON: public key, sign counter and flags. A signature counter that goes backwards means a cloned key, and is refused.
  • Login code: the user handle is the 8-byte user ID. Store.UserByID is added for the lookup.
  • Browser code: uses PublicKeyCredential.parse*OptionsFromJSON and toJSON() where the browser has them, with base64url fallbacks for older ones.
  • Refactor: the small-body reading of forms became readSmallBody, shared with the new JSON endpoints.

Tests

The software authenticator github.com/descope/virtualwebauthn (test-only) drives these:

  • Auth, on both the memory and Postgres stores:
    • wrong password, bad names, someone else's or a repeated ceremony;
    • excluding a device's existing passkey;
    • sign-in, and last-used being recorded;
    • refusal from another origin, another site ID, an unknown passkey or a deleted one;
    • no code needed when two-factor is on;
    • reset deleting passkeys;
    • the limit of 10.
  • Server: the whole HTTP flow, including:
    • the cookie, and next that can't point to another site;
    • the login log entry;
    • refusals, a wrong content type, deletion, and the start limit.
  • Changed test: TestSymlinks looked for the bare word pub anywhere in the page, which the new inline script contains (publicKey); it now looks at listing entries.
  • Full suite: passes with -race and Postgres on macOS, except the known macOS-only TestLongNonASCIIPath. TestFolderSharing once hit the test client's 5-second timeout under full-suite race load; it passes 3 of 3 on its own. CI runs Linux.
  • Browser: checked on http://localhost:
    • the button and the Passkeys page render;
    • the autofill request starts with no errors;
    • Chrome's parseCreationOptionsFromJSON and parseRequestOptionsFromJSON accept the server's options (site ID, user, 32-byte challenge, resident key and user verification required);
    • the fallback base64url decoding matches.
  • Not exercised: a real authenticator dialog (Touch ID and the like). That needs a person at the device.

After deploy

Check that adding a passkey on ftp.ssenerg.com works. It depends on the proxy passing the real Host (and X-Forwarded-Proto) through, which share links already rely on.

🤖 Generated with Claude Code

Users can add passkeys under Passkeys in their account menu, after
their password, and then sign in with one from the sign-in page's
button, or by picking it where the browser offers it under the
username. Passkeys are discoverable WebAuthn credentials that need user
verification, bound to the site's host name; signing in with one asks
no two-factor code, as it is a second factor in itself.

A new temporary password deletes the user's passkeys, as after a
break-in. Starting passkey sign-ins is limited per client, and refused
passkeys count against the client's sign-in budget.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ssenerg
ssenerg changed the base branch from gallery to main October 25, 2026 18:53
@ssenerg
ssenerg merged commit fda3029 into main Oct 25, 2026
4 checks passed
@ssenerg
ssenerg deleted the passkeys branch October 25, 2026 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant