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

Access 3, infrastructure and clouds: the admin-only routes ask may() in shadow #18409

opened this

Merged 1h 41m ago, live in production

The infrastructure and cloud routes now check may() in shadow next to their existing admin check. The existing check still decides, so nobody's access changes. When the two answers differ, one row is written to accessdisagreement under infra .

Notes

opened this

The infrastructure and cloud routes now check may() in shadow next to their existing admin check. The existing check still decides, so nobody's access changes. When the two answers differ, one row is written to access_disagreement under infra <route>.

  • src/http/infra_routes.ts: the shared guard now takes the route's name: guard(ctx, "build"), "plan", "apply", "ending", … (13 routes). The /infra/live check goes through the same path, as door infra live. A small local infraAdmin passes only the old boolean to mayBeside(ctx, "infra <route>", "forge.administer", old) and returns that old boolean. Anonymous visitors are still sent to sign in, and signed-in non-admins still get the not-found page.
  • src/http/api/cloud.ts: GET /api/v1/cloud/accounts asks under infra cloud accounts. The admin-only catalog refresh inside GET /api/v1/places asks under infra places refresh, using the old condition (admin and an rw token).
  • test/infra-routes-may.test.ts sends real requests through forgeHttp. An admin, an everyday member, an agent's token and an anonymous visitor each get the same status as before, and none of them writes a row. The forced disagreement is an admin's ro token on /infra/build: it still gets 200 and writes exactly one row (infra build, forge.administer, ro_token, may 0). That test fails without this change. A last test checks the source so the cloud doors can't slip back to a bare check.

Two things the test shows about the current behaviour:

  • /infra/* and /api/v1/cloud/accounts are marked admin in route_marks, so admin_gate refuses an everyday account with 403 before these handlers run. The new check only ever sees admins, agents that get past the gate, and anonymous visitors.
  • The cloud routes can't produce a disagreement through a normal request: a token without rw is refused before the admin check, and that matches what may requires.

I reused mayBeside and added no grant table and no admin shortcut. The two commits carry a No door: line: nothing new is shown to people, so there is nothing to add to the terminal side or the how-to.

bun x tsc --noEmit, the gate (0 failing rules) and 22 related test files (infra, cloud accounts, places, admin gate, route marks, unused exports, duplicate imports, web pages) all pass, 235 tests in total. scripts/fast.ts named too many files to run, so I picked these myself. I did not keep a plan on the issue.

Try it on the preview: open /infra/build as the admin, then call it with the admin's ro token. It still returns 200, and one access_disagreement row appears under infra build.

🤖 Generated with Claude Code

Closes #18404

commented

The infrastructure and cloud routes now check may() in shadow next to their existing admin check. The existing check still decides, so nobody's access changes. When the two answers differ, one row is written to access_disagreement under infra <route>.

  • src/http/infra_routes.ts: the shared guard now takes the route's name: guard(ctx, "build"), "plan", "apply", "ending", … (13 routes). The /infra/live check goes through the same path, as door infra live. A small local infraAdmin passes only the old boolean to mayBeside(ctx, "infra <route>", "forge.administer", old) and returns that old boolean. Anonymous visitors are still sent to sign in, and signed-in non-admins still get the not-found page.
  • src/http/api/cloud.ts: GET /api/v1/cloud/accounts asks under infra cloud accounts. The admin-only catalog refresh inside GET /api/v1/places asks under infra places refresh, using the old condition (admin and an rw token).
  • test/infra-routes-may.test.ts sends real requests through forgeHttp. An admin, an everyday member, an agent's token and an anonymous visitor each get the same status as before, and none of them writes a row. The forced disagreement is an admin's ro token on /infra/build: it still gets 200 and writes exactly one row (infra build, forge.administer, ro_token, may 0). That test fails without this change. A last test checks the source so the cloud doors can't slip back to a bare check.

Two things the test shows about the current behaviour:

  • /infra/* and /api/v1/cloud/accounts are marked admin in route_marks, so admin_gate refuses an everyday account with 403 before these handlers run. The new check only ever sees admins, agents that get past the gate, and anonymous visitors.
  • The cloud routes can't produce a disagreement through a normal request: a token without rw is refused before the admin check, and that matches what may requires.

I reused mayBeside and added no grant table and no admin shortcut. The two commits carry a No door: line: nothing new is shown to people, so there is nothing to add to the terminal side or the how-to.

bun x tsc --noEmit, the gate (0 failing rules) and 22 related test files (infra, cloud accounts, places, admin gate, route marks, unused exports, duplicate imports, web pages) all pass, 235 tests in total. scripts/fast.ts named too many files to run, so I picked these myself. I did not keep a plan on the issue.

Try it on the preview: open /infra/build as the admin, then call it with the admin's ro token. It still returns 200, and one access_disagreement row appears under infra build.

🤖 Generated with Claude Code

commented

The admin-only /infra routes and the two cloud API checks now also ask may() in shadow. The old admin check still decides every answer, and when may() disagrees, one row is written to access_disagreement under the route's own door name. Nobody's access changes.

  • src/http/infra_routes.ts: guard(ctx, route) calls mayBeside(ctx, "infra <route>", "forge.administer", old) itself. The old answer still decides: an anonymous visitor is sent to sign in, and a signed-in non-admin gets the not-found page. infraLive calls mayBeside directly too, so the file has one way to ask, and the earlier infraAdmin wrapper is gone.
  • src/http/api/cloud.ts: GET /api/v1/cloud/accounts asks under infra cloud accounts. The admin-only catalog refresh in GET /api/v1/places asks under infra places refresh, using the old condition (an admin with an rw token).
  • test/infra-routes-may.test.ts sends real requests through forgeHttp and checks both the status and the rows written:
    • An admin, an everyday member, an agent's token and an anonymous visitor each get their previous answer, and none of them writes a row.
    • /api/v1/places answers 200 with no row for an admin's rw token, an admin's ro token and an agent's token.
    • An admin's ro token on /infra/build still gets 200 and writes exactly one row (infra build, forge.administer, ro_token, may 0).
    • No request can force a disagreement on the two cloud doors: they already require an rw token, and that is all may() adds to the admin check. Those two door names are tested by calling mayBeside directly, each writing one row.
    • The test that read the source files as text is gone.

Everyday members never reach these handlers: /infra/*, /api/v1/cloud/accounts and /api/v1/places count as admin pages for that gate (admin_gate), and it refuses them with 403 first. That was already the case before this change.

I reused mayBeside; nothing new is exported. The commits say No door: because nothing shown to people changes.

The type check, the gate (0 failing rules) and 6 related test files (49 tests) pass. They cover the new test, infra pages, the places and cloud-accounts APIs, unused exports and duplicate imports. I didn't run the full suite; the forge runs it on the push.

To try it on the preview: GET /api/v1/places with an admin's ro token returns 200 and writes no row. Opening /infra/build with that same token returns 200 and writes one row under infra build.

🤖 Generated with Claude Code

Sign in to join this conversation.

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

Keyboard shortcuts

Docs