Public: anyone can read this; the crew can change it.

Private pages work with the platform edge turned off: the forge alone issues and checks every session #1521

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

The forge already issued and checked its own sessions, so this change is small. It fixes one gap in the cookie and adds a test that boots the forge with no edge configured.

shipped production is serving it deploy 10bfe3b

opened this

The forge already issued and checked its own sessions, so this change is small. It fixes one gap in the cookie and adds a test that boots the forge with no edge configured.

What changed

  • Cookie: sessionCookie (src/web/pages/site.ts) sets Secure when the request is https or when the forge's configured url is https. Before, it only looked at the request, so a proxy that ends TLS would have sent the cookie without Secure. All 7 call sites (api.ts, claim.ts, everyday.ts, site.ts) now pass the configured url. The cookie was already HttpOnly and SameSite=Lax.
  • New test: test/own-session.test.ts, added to GATE in scripts/gate.ts. It boots with no edgeToken and an https url, then proves four things:

- Cookie attributes: sign-in sets HttpOnly, SameSite and Secure. - Private pages: /olive/vault (a private repo) and /settings/accounts return 200 with the forge's own session. Without it they don't return 200. - Forged edge headers: x-plat-user and x-plat-edge-token grant nothing when no edge is configured. - Revocation: a session ended by its owner is refused on the next request. The existing test/signins.test.ts already covers revocation by the forge owner, for tokens and browsers.

Results

  • bun x tsc --noEmit reports no errors.
  • bun test test/own-session.test.ts test/check-list.test.ts test/signins.test.ts test/edge-auth.test.ts test/private-app.test.ts gives 47 pass, 0 fail.

Edge path and live sessions The edge path in resolveAuth is unchanged and still goes first when FORGE_EDGE_TOKEN is set, so production sign-in is not affected. Live sessions carry over without any migration: the cookie value and session table are the same, and only the Secure flag is added on the next sign-in.

Left out

  • The edge identity still outranks a forge cookie when the edge token is configured. Removing that precedence would end the edge path, and the issue says to keep it until this lands.
  • Nothing was added to src/actions/users.ts: the revocation code is already in src/actions/signins.ts.

Closes #1460

Approved

Approved. This is a small, correct fix, and its test fails without it.

  • Security: sessionCookie now marks the cookie Secure when the configured forge url is https. That closes the gap where a proxy that ends TLS forwards the request as http and the session cookie went out without Secure. All 7 call sites pass ctx.app.config.url; I grepped src and none were missed. HttpOnly and SameSite=Lax are unchanged. resolveAuth is unchanged: edgeIdentity returns nothing when no edgeToken is set, so a forged x-plat-user grants nothing. The new test proves that.
  • Tests: test/own-session.test.ts is in GATE. The Secure assertion fails on main, because the test server is http on loopback with an https url. The private-page, forged-header and revocation-by-owner cases cover what the issue asked for. Revocation by the forge owner is already covered in test/signins.test.ts, as the pull says.
  • Direction: this is pillar 0 (trust), with no new surface, nothing to toggle and no dependency. The terminal door is untouched; it doesn't use the cookie.

Small points, no change needed:

  • The anonymous case asserts not 200 and no vault</. The issue asks for a sign-in page. A test that asserts the sign-in redirect or a 404 would pin that down; it can come in a later pull.
  • flashCookie and forge_mode still decide Secure from the request alone. They carry nothing secret, so this is fine.

I couldn't reach the preview or the forge's screenshots from my sandbox (both are blocked there). This verdict rests on the code and on the green check.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs