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

Access 3, web pages: the two known partings are decided, then each page's own isAdmin and sign-in check is deleted and may() alone decides #18430

opened this

Merged 10h 29m ago, live in production

Web pages now have one access check, may(), asked through src/http/pagemay.ts. The shadow that counted disagreements beside each page's old check is gone, and so are the old checks themselves. The two known disagreements, decided.

Notes

opened this

Web pages now have one access check, may(), asked through src/http/page_may.ts. The shadow that counted disagreements beside each page's old check is gone, and so are the old checks themselves.

The two known disagreements, decided. may is asked about the account behind the request, not the token:

  • Anonymous visit to a signed-in page: signedInPage(ctx) now asks forge.write instead of forge.read. Every account has forge.write; a visitor with no account does not, so may answers unauthorized and the page sends them to sign in, as before. No new action or table was added.
  • An ro token that posts: the token's scope is still checked where it was before, by the form a change reads (readForm(ctx, scope)). This is the same decision as the /infra pages in #18425, so nobody's access changes.

Admin pages: adminPage(ctx) asks forge.administer. A new personAdminPage(ctx) covers the admin pages that also turned away admin agents (kind !== "agent"), so they still do.

Call sites: every adminPage(ctx, door, <inline isAdmin>) and signedInPage(ctx, door) in src/web is now adminPage(ctx), personAdminPage(ctx) or signedInPage(ctx). Bare !ctx.auth.user / ctx.auth.user === undefined gates, and const user = ctx.auth.user; if (!user) return … gates, go through the same helpers. Two kind === "user" pages (runners.ts, app_templates.ts) and two render helpers (forge-template-setting.ts, the template control and its account check; account.ts, the token page's admin-scope check) keep that kind test next to adminPage(ctx). A few gates that mix the account with another condition on one line are unchanged (e.g. bets.ts, trace_imported.ts, series_pins.ts); the scan rule doesn't match them, so they stay as they were. src/http/may_beside.ts had no other caller and is deleted. Its helper names are updated in door_checks.ts, access_disagreement.ts and docs/ROLES.md.

Gate rule: doorSources in src/design/door_checks.ts now also reads src/web/pages. Nine lines are listed in DOOR_LINES, each with a reason: they are about an account being shown rather than the one asking, plain data passed in, a repository admin, or a token's scope. Nothing in scripts/gate.ts changed.

Tests:

  • test/web-pages-may.test.ts was a test of the shadow, which is deleted, so I rewrote it. It finds every page module that uses one of the helpers (more than 80). For each one it checks, by GET and POST, that the helper gives the same answer as the old inline check for an anonymous visitor, a signed-in person, the admin, an ro token, an rw token and an admin agent, and that access_disagreement stays empty. It also checks real responses from /settings and /maintenance. It fails on the old code.
  • In test/door-inline-checks.test.ts I changed one expected hint string (mayBeside → "forge.write") and added a check that the scan reads src/web/pages/account.ts.
  • No other test was changed.
  • bun x tsc --noEmit passes; the gate shows 0 failures and 3 notes; design-lint is clean. 524 page and route test files that I chose (fast.ts said the change was too broad to pick for me) pass with 0 failures, along with the dead-code, duplicate-import and page-budget tests.

Production count: I could not read SELECT * FROM access_disagreement WHERE door LIKE 'web %' on production, because the sandbox cannot reach the forge's database. No rows were given to me to decide.

docs/features/may.md now says web pages have one check, and the "worked out beside it" sentence is gone.

To try it on the preview:

  • Signed out, open /settings and /maintenance: both send you to sign in.
  • Signed in as a member who is not the admin: /settings opens and /maintenance answers 403, from the admin-path check that runs before the page.
[{"go":"/settings","look":"signed out","expect":"redirected to sign in"},{"go":"/maintenance","look":"signed in as a member who is not the admin","expect":"403, as before"},{"go":"/maintenance","look":"signed in as the admin","expect":"the maintenance page opens"}]

🤖 Generated with Claude Code

Closes #18424

commented

Web pages now have one access check, may(), asked through src/http/page_may.ts. The shadow that counted disagreements beside each page's old check is gone, and so are the old checks themselves.

The two known disagreements, decided. may is asked about the account behind the request, not the token:

  • Anonymous visit to a signed-in page: signedInPage(ctx) now asks forge.write instead of forge.read. Every account has forge.write; a visitor with no account does not, so may answers unauthorized and the page sends them to sign in, as before. No new action or table was added.
  • An ro token that posts: the token's scope is still checked where it was before, by the form a change reads (readForm(ctx, scope)). This is the same decision as the /infra pages in #18425, so nobody's access changes.

Admin pages: adminPage(ctx) asks forge.administer. A new personAdminPage(ctx) covers the admin pages that also turned away admin agents (kind !== "agent"), so they still do.

Call sites: every adminPage(ctx, door, <inline isAdmin>) and signedInPage(ctx, door) in src/web is now adminPage(ctx), personAdminPage(ctx) or signedInPage(ctx). Bare !ctx.auth.user / ctx.auth.user === undefined gates, and const user = ctx.auth.user; if (!user) return … gates, go through the same helpers. Two kind === "user" pages (runners.ts, app_templates.ts) and two render helpers (forge-template-setting.ts, the template control and its account check; account.ts, the token page's admin-scope check) keep that kind test next to adminPage(ctx). A few gates that mix the account with another condition on one line are unchanged (e.g. bets.ts, trace_imported.ts, series_pins.ts); the scan rule doesn't match them, so they stay as they were. src/http/may_beside.ts had no other caller and is deleted. Its helper names are updated in door_checks.ts, access_disagreement.ts and docs/ROLES.md.

Gate rule: doorSources in src/design/door_checks.ts now also reads src/web/pages. Nine lines are listed in DOOR_LINES, each with a reason: they are about an account being shown rather than the one asking, plain data passed in, a repository admin, or a token's scope. Nothing in scripts/gate.ts changed.

Tests:

  • test/web-pages-may.test.ts was a test of the shadow, which is deleted, so I rewrote it. It finds every page module that uses one of the helpers (more than 80). For each one it checks, by GET and POST, that the helper gives the same answer as the old inline check for an anonymous visitor, a signed-in person, the admin, an ro token, an rw token and an admin agent, and that access_disagreement stays empty. It also checks real responses from /settings and /maintenance. It fails on the old code.
  • In test/door-inline-checks.test.ts I changed one expected hint string (mayBeside → "forge.write") and added a check that the scan reads src/web/pages/account.ts.
  • No other test was changed.
  • bun x tsc --noEmit passes; the gate shows 0 failures and 3 notes; design-lint is clean. 524 page and route test files that I chose (fast.ts said the change was too broad to pick for me) pass with 0 failures, along with the dead-code, duplicate-import and page-budget tests.

Production count: I could not read SELECT * FROM access_disagreement WHERE door LIKE 'web %' on production, because the sandbox cannot reach the forge's database. No rows were given to me to decide.

docs/features/may.md now says web pages have one check, and the "worked out beside it" sentence is gone.

To try it on the preview:

  • Signed out, open /settings and /maintenance: both send you to sign in.
  • Signed in as a member who is not the admin: /settings opens and /maintenance answers 403, from the admin-path check that runs before the page.
[{"go":"/settings","look":"signed out","expect":"redirected to sign in"},{"go":"/maintenance","look":"signed in as a member who is not the admin","expect":"403, as before"},{"go":"/maintenance","look":"signed in as the admin","expect":"the maintenance page opens"}]

🤖 Generated with Claude Code

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs