Sign-in finishes on any replica #113

Merged
jcoffey-dev merged 1 commits from fix/signin-across-replicas into main 2026-11-18 21:59:21 +00:00
1 Commits
Author SHA1 Message Date
jcoffey-dev a39bafccaf Sign-in finishes on any replica
ci / node (pull_request) Skipped
ci / version (pull_request) Skipped
ci / docker-build (pull_request) Skipped
ci / publish (pull_request) Skipped
github/ci (branch) GitHub Actions
ci / github (pull_request) Successful in 2m5s
ci / announce (pull_request) Skipped
A sign-in through the server's page kept its state and PKCE verifier in a
Map in the process that started it. With two replicas behind a balancer,
the callback reached the other one about half the time, and the person
saw "This sign-in didn't start in this browser". Sealed cookie sessions
(K-W1) let a signed-in session move between replicas; the sign-in itself
still couldn't.

The pending sign-in now travels in the state cookie the browser already
carried: <state>.<sealed record>, AES-256-GCM under a key derived from
APP_SECRET with its own label, opened under APP_SECRET_PREVIOUS too. The
callback checks the state inside the sealed record against the URL's.

Each sign-in is still good for one attempt: the callback deletes the
cookie, and the server takes each code once and only with that sign-in's
verifier. The 10,000-sign-in cap goes with the Map: nothing is held here
any more. The cookie is about 420 bytes and lives 10 minutes on
/api/auth only.
2026-11-18 14:43:14 -07:00