Repository navigation
Description
Parent
Auth: Clerk, companies and machine tokens on tier 0, spec §7.
What to build
The login door in front of a tier 0 page. A public patch serves exactly as today. A company patch opened with no session answers a 401 whose body is the door with one Sign in link; sign in at the Account Portal and land back on the patch; a colleague opens it without another sign-in; someone from another company, or a link that points at nothing, gets the same 404 byte for byte. Doored pages are never cached by a shared cache and their shell keeps the session fresh. Until the sharing ticket lands every patch is company-scoped, so after this PR every page is behind the door; the public path is built and tested here (tests write scope = public on the row directly) and becomes reachable from the CLI with the sharing ticket.
Do
- Serving: split the page routes into the two doored
/d/*registrations and the rest; the door is route-scoped middleware provided only to those two, built on Auth'sSessionandUsersand providing the viewer or nothing. The handler that loaded the patch decides:publicserves as today; else no session is the 401 (HTML door as body,no-store, the sign-in URL in a header, identical for every id, no redirect); no user row is a 303 to/joinwith the patch asreturn; another company is the 404 with no visit recorded; a deactivated user gets the deactivated page. FixHEADat the router for every route. - Two content-security policies: the public patch's is unchanged; the doored shell's allows
script-srcandconnect-srcfor the Frontend API host, no inline script, the frame's sandbox unchanged; the shell loads Clerk's headless script from that host and nothing else. Caching keyed to sharing: doored responsesprivate, no-storeon both URL shapes; a public patchpublic, max-age=60on both, the immutable year on version URLs dropped soshare … companycan take a page back inside within a minute (spec §7). The machine token never opens/d/*; noWWW-Authenticate. - The door page is Auth's renderer (the same template
/loginuses), so the 401 body and the page are one template. - Tests: the three wrong-person states and the public path in memory and on a socket with hops driven by hand; the two CSPs; the cache headers by scope; the 401 shape identical for a missing and a foreign patch;
HEAD. The packed e2e's viewer assertions become the doored case: every published patch fetched with no cookies answers 401 withcache-control: private, no-store; the public viewer assertions are parked and return with the sharing ticket. - Docs and glossary:
packages/serving/CONTEXT.md's Serving guarantee becomes the patch runs no script; the shell runs only Patchy's own session script, never analytics; caching keyed to sharing, a minute at most for a public page and never for a doored one and open to machines narrows to any agent that may open it; Page and Login door say what is now in code (three states, no request-access until owner-only returns); the stale comment block in the serving headers module says the same.docs/product.md§ Tier 0's guarantee sentence and the "(Today there is no login; the door arrives with auth)" parentheticals. Thepatchyskill: an agent reads a company patch through its user's browser and only public patches fetch by URL; whatpatchysays when a page refuses it.CONTEXT-MAP.md: Serving imports Auth for the door. The home page's copy stops describing public hosting. - Run the production handshake leg once against a live Clerk instance is blocked on this ticket and on a deployment with a domain; it is not run here.
Surfaces
Served pages (ui-consistency on the door and the shell); vocabulary and product shape; the CLI's skill line; the dev loop (the e2e's doored case).
Done when
- On a
pnpm devinstance:curl -iof a patch is 401 with the door andprivate, no-store; a row set topublicby hand serves 200 withpublic, max-age=60at both URL shapes; in a browser, one Sign in click lands back on the patch and a reload after 70 seconds is a flicker, not a sign-in. - A signed-in user of another company and a missing id produce identical 404 bodies and headers.
-
pnpm test,pnpm typecheck,pnpm lintand the packed e2e pass.
Decisions implemented
The login door on a tier 0 page; the login door end to end; Effect 4 HTTP for the door §5 and §6; ADR-0005, ADR-0006; spec §7. The prototype branch prototype/login-door has a working door and its nine offline tests; copy the shape, not the files.
Activity