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

Access 3, terminal, games and infrastructure: the entries' own gates are deleted once may() has been asked beside them and agrees #18428

opened this

Merged 10h 51m ago, live in production

The /infra pages and the cloud API now decide access only through may(forge.administer). Their inline isAdmin checks are deleted, and every kind of caller gets the same status as before. This pull covers only the infrastructure part of #18425.

Notes

opened this

The /infra pages and the cloud API now decide access only through may(forge.administer). Their inline isAdmin checks are deleted, and every kind of caller gets the same status as before. This pull covers only the infrastructure part of #18425. As the issue's risks allowed, the terminal and games parts are split into #18426 and #18427. #18425 and the umbrella #586 now both wait on them.

What changed

  • src/http/infra_routes.ts: guard() and the /infra/live check ask may of the account behind the request. A signed-out caller is sent to sign in, and an account that isn't the admin gets not found, as before. Every change still reads its form with readForm(ctx, "admin"), so token scope is enforced where it was. An admin's ro token still opens the pages and is still refused a change with 403.
  • src/http/api/cloud.ts: GET /api/v1/cloud/accounts asks may with the credential sent. forge.write refuses an ro token (403), replacing the scopeAllows(…, "rw") check. forge.administer refuses anyone who isn't the admin (404). The places catalog refreshes only when forge.administer is granted, which gives the same answer as isAdmin && rw did.
  • Gate rule from #18410: src/design/door_checks.ts now also reads src/http/infra_routes.ts and src/http/api/cloud.ts. test/door-inline-checks.test.ts checks that both files are read.
  • Docs: docs/features/may.md has a paragraph on the infrastructure and cloud doors. The "not asked yet" list is unchanged.

What to look at test/infra-routes-may.test.ts checks the status for an admin, a non-admin person, an agent's rw and admin tokens, an admin's ro token (reads and a POST), and an anonymous caller. I also ran it against the old src/: every status matched, and the only failure was the shadow rows the old code wrote, which are now gone.

Not done here

  • The terminal entries and mayOnGame are in #18426 and #18427.
  • PUT /api/v1/places/pin still uses the shared accountAdmin helper from api/admin.ts, which is used by other admin routes, so I left it.
  • I could not read production's access_disagreement table: the sandbox denies the forge database. The rows for the infra … doors are unchecked. The only parting the old shadow could record there was an admin's ro token on a page, and this pull keeps that case's old answer.

Checks

  • bun x tsc --noEmit and bun scripts/gate.ts pass.
  • I ran 179 test files covering infra, cloud, places, door, may, dead-code and duplicate-import: 1434 passed, 1 failed. The failure was test/cloud-inventory.test.ts ("the duty's own fetch carries redirect: error"). It passed alone, both on this branch and on the old src/, so it looks like a timing flake under load.
  • The commit carries No door: because nobody's access changed and the terminal has no infrastructure screen.

Try it: on the preview, open /infra as the admin (it loads) and as an everyday account (not found). curl -H "authorization: Bearer <ro token>" $PREVIEW/api/v1/cloud/accounts answers 403.

🤖 Generated with Claude Code

Closes #18425

commented

The /infra pages and the cloud API now decide access only through may(forge.administer). Their inline isAdmin checks are deleted, and every kind of caller gets the same status as before. This pull covers only the infrastructure part of #18425. As the issue's risks allowed, the terminal and games parts are split into #18426 and #18427. #18425 and the umbrella #586 now both wait on them.

What changed

  • src/http/infra_routes.ts: guard() and the /infra/live check ask may of the account behind the request. A signed-out caller is sent to sign in, and an account that isn't the admin gets not found, as before. Every change still reads its form with readForm(ctx, "admin"), so token scope is enforced where it was. An admin's ro token still opens the pages and is still refused a change with 403.
  • src/http/api/cloud.ts: GET /api/v1/cloud/accounts asks may with the credential sent. forge.write refuses an ro token (403), replacing the scopeAllows(…, "rw") check. forge.administer refuses anyone who isn't the admin (404). The places catalog refreshes only when forge.administer is granted, which gives the same answer as isAdmin && rw did.
  • Gate rule from #18410: src/design/door_checks.ts now also reads src/http/infra_routes.ts and src/http/api/cloud.ts. test/door-inline-checks.test.ts checks that both files are read.
  • Docs: docs/features/may.md has a paragraph on the infrastructure and cloud doors. The "not asked yet" list is unchanged.

What to look at test/infra-routes-may.test.ts checks the status for an admin, a non-admin person, an agent's rw and admin tokens, an admin's ro token (reads and a POST), and an anonymous caller. I also ran it against the old src/: every status matched, and the only failure was the shadow rows the old code wrote, which are now gone.

Not done here

  • The terminal entries and mayOnGame are in #18426 and #18427.
  • PUT /api/v1/places/pin still uses the shared accountAdmin helper from api/admin.ts, which is used by other admin routes, so I left it.
  • I could not read production's access_disagreement table: the sandbox denies the forge database. The rows for the infra … doors are unchecked. The only parting the old shadow could record there was an admin's ro token on a page, and this pull keeps that case's old answer.

Checks

  • bun x tsc --noEmit and bun scripts/gate.ts pass.
  • I ran 179 test files covering infra, cloud, places, door, may, dead-code and duplicate-import: 1434 passed, 1 failed. The failure was test/cloud-inventory.test.ts ("the duty's own fetch carries redirect: error"). It passed alone, both on this branch and on the old src/, so it looks like a timing flake under load.
  • The commit carries No door: because nobody's access changed and the terminal has no infrastructure screen.

Try it: on the preview, open /infra as the admin (it loads) and as an everyday account (not found). curl -H "authorization: Bearer <ro token>" $PREVIEW/api/v1/cloud/accounts answers 403.

🤖 Generated with Claude Code

commented

Left #18425 open: 3 unticked items remain (Terminal: src/tui/screens/entries.ts offers an entry by its asks through may; the entry's own gate function is removed for entries that name an action. The two expected partings in docs/features/may.md (signed out on account screens; an admin agent on a person's screens) are decided in the pull and the test pins the decision. Entries that name no action keep their gate and say why beside it.; Games: mayOnGame (src/games/game_may.ts) answers alone for the box, server and game-door checks; the grant tables stay the data behind game.view/game.operate/game.own (no new grant table). The ro-token-operates-a-server parting is decided and tested.; The gate rule from #18410 covers these files.).

Sign in to join this conversation.

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

Keyboard shortcuts

Docs