~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0

People sign in to the console as themselves, at their own PDS

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/group-host:host/console-login

What changes

Signing in to the console (console_login.rs). People sign in as themselves, at their own PDS. The host is a confidential OAuth client of it, as knotless-serve is of its accounts'. Its client id is <CONSOLE_URL>/console/client-metadata.json, and its ES256 key is derived from the host's secret.

It asks for atproto alone. The console's methods act as the group, never as the person, so the host needs only to know who they are.

The steps:

  • /console/login resolves the person's handle or DID to their PDS and its authorization server, pushes the request with PKCE, DPoP, a client assertion and their handle as the hint, and sends the browser there to approve.
  • /console/callback checks the browser coming back is the one that started (a cookie naming the state) and that the answer is from that server, then exchanges the code. It checks the token's sub is the person who started, revokes the token at once, and signs them in. The host keeps nothing of theirs.
  • /console/logout signs out, and refuses every cookie signed before.

The session is a cookie the host signs, naming the person: HttpOnly, SameSite=Lax, and Secure on an https console, good for thirty days. Every method that asks who calls (caller) now takes it beside service auth. Sign-ins under way are kept in SQLite for fifteen minutes; sign-outs by person.

Reaching only public servers. Every server a handle leads to is reached only at a public address, as a client's metadata is. The pinned public fetch from the OAuth pull is now a shared client (Host::pinned, Host::public_json).

The console forwards /console/* to the host, cookies and all (hooks.server.ts), and its header has a sign-in form (SignIn).

atproto::jose gains json_of.

Also from the provisioning review: signing-in.md now says what a provisioning that fails after the group is made leaves.

Why

Step 7's first part, and step 6's last line in docs/design/README.md: the console signs its people in at their own PDS, as a confidential client, as knotless does. It differs from knotless in keeping no session at the PDS. The console only needs to know who someone is, and a token it does not keep is one nobody can take from it.

How it was checked

tests/console_login.rs runs against a fake PDS and authorization server, each of whose answers can be made wrong:

  • signing in end to end: the pushed request's fields, the client assertion against the served metadata, the revocation;
  • the cookie as the caller of createGroup, and a forged or unknown one refused;
  • signing out, and older cookies refused after it;
  • a back outside the console sent home;
  • each refusal: no authorization server, an issuer that misnames itself, a refused, wordless or empty pushed request, a bad authorization endpoint, a nonce asked for twice, an unreachable server, an answer from another issuer, a denial with or without words, a refused token, another sub, a person not found, one with no PDS, an answer in a browser that did not start it;
  • a server without revocation;
  • a host on https reaching only https, with Secure cookies.

Local coverage is 100% of lines and functions. The web checks (svelte-check and the layers) pass.

Approved

This pull signs people in to the console at their own PDS. The host acts as a confidential OAuth client, learns the person's DID, revokes the token at once, and sets a signed session cookie. caller now accepts that cookie when there is no Authorization header. I read every file in the diff and found nothing that blocks merging.

What I checked:

  • Callback binding: the state-naming cookie, the iss check, PKCE, the sub check against the DID that started the sign-in, and the pinned public-address fetches for every outbound call are all sound.
  • Redirect target: back_to only lets local paths through.
  • Sign-out: iat > at refuses every cookie signed before a sign-out.
  • Fallback in caller: it applies only when Authorization is absent, so a bad service-auth header does not quietly fall back to a cookie.
  • Checks: all of them pass on this head.

Two small things, neither blocking:

  • The cookie signature is compared with != on strings (console_login.rs:204). Comparing the MAC in constant time is cheap insurance.
  • docs/reference/config.md still describes CONSOLE_URL only as where /authorize lives. It is now also the console's OAuth client id and callback origin, and it decides whether cookies are Secure. AGENTS.md asks for that page to change with an environment variable's meaning.
crates/group-host/src/console_login.rsline 204Outdated

These lines can no longer be read.

review.knotless.dev

This compares the MAC as plain strings, which is not constant time. Compare the decoded bytes with a constant-time equality instead.

Merged as ee0ba62