Files
orangecat/docs/operations/passkeys.md
CatoandClaude Fable 5.1 2077bfc207 feat(auth,docs): developer page for "Sign in with OrangeCat"; passkeys (#1185)
* feat(docs): developer page for "Sign in with OrangeCat" + round-trip script

Step D9 of ADR-0009. OrangeCat has been a real OpenID Connect provider
since June and five relying parties sign people in through it, but a site
that wanted the button had the standard and nothing else.

/docs/sign-in-with-orangecat: what you get (one identity keyed by sub,
passwords optional, people can disconnect you), self-service registration
with its rules, the Auth.js config Solon/Heidi/Loki run and the by-hand
authorize/token/userinfo/refresh calls, button wording (prompt=create,
login_hint), sessions and what invalid_grant means, and every scope with
its consent-screen wording. Every URL, scope and lifetime is derived from
the provider's own config (snippets.ts), and a unit test pins the snippets
to the discovery document, so the page cannot quote an endpoint the server
does not serve.

scripts/oauth/sign-in-roundtrip.mjs registers a client, opens the sign-in,
catches the code on loopback, exchanges it with PKCE, checks iss/aud/nonce,
reads userinfo, refreshes, and proves the spent token is refused — the
same steps any relying party takes, runnable before writing a line.

Linked from /docs. ADR-0009 status updated: D1–D4 shipped, relying parties
now honour revocation (solon#203, heidi#145).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QDMxjTqKNLXETMYYuapMa3

* fix(docs): userinfo snippet uses a shell variable for the token

gitleaks (curl-auth-header) reads 'Bearer THE_ACCESS_TOKEN' as a leaked
token; $ACCESS_TOKEN is what a person would paste anyway.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QDMxjTqKNLXETMYYuapMa3

* chore(security): allowlist the docs bearer-token placeholder for gitleaks

The developer page's userinfo example used 'Bearer THE_ACCESS_TOKEN', which
gitleaks' curl-auth-header rule reads as a leak. The tree now uses a shell
variable; the placeholder in history is allowlisted instead of rewriting it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QDMxjTqKNLXETMYYuapMa3

* feat(auth): passkeys — add/list/remove in settings, sign in with a passkey

Step D5 of ADR-0009. The self-hosted auth server (GoTrue) supports WebAuthn
passkeys and the browser client already carries the ceremony; what was
missing was the UI, the wrapper, and the switch.

- Settings → Security → Passkeys: the person's passkeys with name, date and
  last use; "Add a passkey" (browser prompt, then named); remove.
- /auth: "Sign in with a passkey" beside the emailed code — nothing typed.
- Both are hidden until the auth server reports passkeys_enabled: true
  (lib/auth/passkeys-availability reads GoTrue's public settings, cached
  five minutes, fails closed). A button that cannot work is a dead end.
- docs/operations/passkeys.md is the switch: GOTRUE_PASSKEY_ENABLED and the
  relying-party id/origins, with why the id is orangecat.ch and not the
  API host. scripts/auth/passkeys-e2e.mjs drives add → sign in → remove
  with Chromium's virtual authenticator and exits 2 while the switch is off.

services/supabase/auth/passkeys.ts wraps registerPasskey / passkey.list /
update / delete / signInWithPasskey in the auth service's shape; a passkey
is named in a second call and a failed rename still returns a working key.
Unit tests cover the availability parser and the wrappers.

Also: the two CLI scripts under scripts/ carry the no-console pragma their
siblings use.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QDMxjTqKNLXETMYYuapMa3

* fix(scripts): throwaway inbox password from crypto.randomBytes

CodeQL (js/insecure-randomness) flags Math.random() for a password, even
a disposable one; the real generator costs nothing.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QDMxjTqKNLXETMYYuapMa3

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-09-29 02:45:52 -07:00

3.3 KiB

created_date, last_modified_date, last_modified_summary
created_date last_modified_date last_modified_summary
2026-09-29 2026-09-29 First version — switching passkeys on at the auth server

Passkeys (WebAuthn)

OrangeCat's code supports passkeys end to end (Settings → Security → Passkeys to add and remove them; "Sign in with a passkey" on /auth), but the auth server ships with them OFF, and the UI hides both until it says otherwise. This is the one switch that turns them on.

The app never guesses: /auth and the settings page read passkeys_enabled from GoTrue's public settings document (/auth/v1/settings) and show nothing while it is false. A button that cannot work is a dead end, so there is no button.

What the box needs

GoTrue (Supabase Auth, self-hosted) reads its configuration from the service environment in /opt/orangecat (the same place the social-login providers are configured — see oauth-social-login.md). Add:

GOTRUE_PASSKEY_ENABLED=true
GOTRUE_WEBAUTHN_RP_ID=orangecat.ch
GOTRUE_WEBAUTHN_RP_DISPLAY_NAME=OrangeCat
GOTRUE_WEBAUTHN_RP_ORIGINS=https://orangecat.ch
  • RP_ID is the domain the passkey is bound to. The page that runs the ceremony is https://orangecat.ch, so the id is orangecat.ch — NOT supabase.orangecat.ch, even though that is where the API lives. A passkey created for one id never works for another, so get this right before the first person creates one; changing it later strands every passkey.
  • RP_ORIGINS must be https (GoTrue refuses http except on localhost) and must list every origin the ceremony runs on. Add https://www.orangecat.ch too if the site is ever served there without a redirect.
  • Optional: GOTRUE_PASSKEY_MAX_PASSKEYS_PER_USER (default 10) and GOTRUE_RATE_LIMIT_PASSKEY (default 30 per interval).

Restart the auth service. Then:

curl -s https://supabase.orangecat.ch/auth/v1/settings -H "apikey: $NEXT_PUBLIC_SUPABASE_ANON_KEY" | jq .passkeys_enabled
# true

Within five minutes (the app caches the settings document that long) the passkeys card appears under Settings → Security and the sign-in button on /auth.

Verify

  1. Signed in, open Settings → Security → Passkeys → Add a passkey. The browser's own prompt appears (Touch ID, Windows Hello, a phone). The new passkey is listed with its name and date.
  2. Sign out. On /auth, "Sign in with a passkey" → the browser prompt → signed in, with no email or password typed.
  3. Settings → Security → remove the passkey. Signing in with it now fails with the browser's own "no passkey" message.

scripts/auth/passkeys-e2e.mjs drives exactly those steps against a deployment with Chromium's virtual authenticator standing in for a fingerprint reader (BASE=https://orangecat.ch node scripts/auth/passkeys-e2e.mjs). It exits 2, not 0, while the server still reports passkeys_enabled: false, so it cannot be mistaken for a pass before the switch is thrown.

What passkeys do NOT change

  • Recovery. A passkey is a way in, not a way back in; losing every device still means the emailed code or a linked provider (ADR-0009, D6).
  • Two-factor. A passkey already proves possession and presence; GoTrue does not ask for TOTP after a passkey sign-in.
  • Other products. Solon, Loki and Heidi sign in through OrangeCat, so a passkey registered here signs the person in everywhere.