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

Games: what a page draws for an ro token matches what its POST allows #18433

opened this

Merged 7h 49m ago, live in production

The game pages now draw Start/Stop/Restart, the command input, the plugin plan and the other operator controls only when the credential could use them, so an owner's ro token no longer gets controls the POST then refuses.

Notes

opened this

The game pages now draw Start/Stop/Restart, the command input, the plugin plan and the other operator controls only when the credential could use them, so an owner's ro token no longer gets controls the POST then refuses.

I ran tsc --noEmit, the gate and design-lint, and the 195 tests scripts/fast.ts named (2910 pass, 0 fail). I did not run the forge's full check.

What changed

  • mayOnGame asks the old grant check, which still decides, and may only in shadow. So it alone would not have turned an ro token away, and I added drawsOperator in src/games/game_may.ts.
  • drawsOperator(db, principalOf(ctx.auth), box, service) requires both the operator grant (through mayOnGame) and holds(…, "game.operate"). That is the same scope rule the POSTs enforce with readForm(ctx, "rw").
  • It replaces the draw-time checks in:
    • the box page's new-server block, per-server buttons and chat block;
    • the server page, its SSE stream and the container console;
    • the plugin config page;
    • the topology buttons and targets.
  • I reused holds, gameResource and mayOnGame; I wrote no similar function.

The ro read question I chose the second option from the issue and moved the two failing tests in test/game-proxy-jars.test.ts to rw tokens. The plugin plan is operator-only, so an ro token no longer sees it; it still reads the page. Both tests check operator content (the "moved aside" notice and the plugin plan rows), so the move is a real change in what ro sees, not a test mistake.

New test A test in the same file loads /games/mc/velocity with an ro and an rw token. The ro page has no /power or /command form; the rw page has both.

Left out

  • The terminal screens, so the commit says No door:. They have no token scope and already ask mayOnGame for the signed-in account.
  • A role parameter in games_config.ts's render that is now unused; I left it to keep the diff small.
  • The owner-only shell stream and the visible/viewer filters, which are reads and unchanged.

To try Open /games/<box>/<server> with an ro token: no power buttons and no command input. With an rw token they show.

Closes #18432

2 earlier comments
commented

The game pages now draw Start/Stop/Restart, the command input, the plugin plan and the other operator controls only when the credential could use them, so an owner's ro token no longer gets controls the POST then refuses.

I ran tsc --noEmit, the gate and design-lint, and the 195 tests scripts/fast.ts named (2910 pass, 0 fail). I did not run the forge's full check.

What changed

  • mayOnGame asks the old grant check, which still decides, and may only in shadow. So it alone would not have turned an ro token away, and I added drawsOperator in src/games/game_may.ts.
  • drawsOperator(db, principalOf(ctx.auth), box, service) requires both the operator grant (through mayOnGame) and holds(…, "game.operate"). That is the same scope rule the POSTs enforce with readForm(ctx, "rw").
  • It replaces the draw-time checks in:
    • the box page's new-server block, per-server buttons and chat block;
    • the server page, its SSE stream and the container console;
    • the plugin config page;
    • the topology buttons and targets.
  • I reused holds, gameResource and mayOnGame; I wrote no similar function.

The ro read question I chose the second option from the issue and moved the two failing tests in test/game-proxy-jars.test.ts to rw tokens. The plugin plan is operator-only, so an ro token no longer sees it; it still reads the page. Both tests check operator content (the "moved aside" notice and the plugin plan rows), so the move is a real change in what ro sees, not a test mistake.

New test A test in the same file loads /games/mc/velocity with an ro and an rw token. The ro page has no /power or /command form; the rw page has both.

Left out

  • The terminal screens, so the commit says No door:. They have no token scope and already ask mayOnGame for the signed-in account.
  • A role parameter in games_config.ts's render that is now unused; I left it to keep the diff small.
  • The owner-only shell stream and the visible/viewer filters, which are reads and unchanged.

To try Open /games/<box>/<server> with an ro token: no power buttons and no command input. With an rw token they show.

commented

I merged main into the branch, resolved the conflicts and pushed. The 2,911 tests that scripts/fast.ts names pass, with no failures. I did not run the forge's full check.

main had meanwhile made mayOnGame answer through may alone, so the "draw" door argument is gone and a read asks with the account behind the request (askingFor). The pull's own change survives.

  • Why drawsOperator stays: askingFor reads with the account on GET, so a page drawn from it would still show an ro token its buttons. drawsOperator is now just mayOnGame called with the credential sent (principalOf(ctx.auth)). The POSTs ask the same way.
  • Conflicts: I took main's seesGameBox and containerConsole and kept the draw check in the console.
  • Unchanged from before: the two plugin-plan tests are still on rw tokens, and the ro-versus-rw drawing test is still in test/game-proxy-jars.test.ts.
commented

I removed the dead role parameter from render in src/web/pages/games_config.ts, and the branch is pushed.

  • Dead parameter: I dropped the parameter, the got.role and role arguments at both call sites, and the Role import. tsc is clean and the gate passes.
  • Tests: I ran test/game-proxy-jars.test.ts and the games config tests. 52 pass, 0 fail. I did not re-run the wider set.
  • Docs: docs/features/games.md now says an ro token opens the box and server pages but is drawn none of their controls, and that an rw token is drawn them.

I did not do the second follow-up, passing the principal once instead of repeating principalOf(ctx.auth). It touches several call sites on the pages and the topology block, so I left it out of this pull.

Sign in to join this conversation.

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

Keyboard shortcuts

Docs