Skip to content

apikeys with groups, groups and members commands, TYPETORCH_FLEET_KEY alias (backend plans/38) - #51

Open
phasenull wants to merge 5 commits into
mainfrom
feat/permissions
Open

phasenull wants to merge 5 commits into
mainfrom
feat/permissions

Conversation

@phasenull

Copy link
Copy Markdown
Member

The CLI side of the backend permissions redesign (plans/38). Pairs with typetorch/backend#93, and works against an older backend.

What changes

  • typetorch apikeys create --name <n> --group fleet[,viewer…] creates a key in one or more groups. --role is kept as an alias for one group (game = fleet).
    • apikeys list shows a groups column. It also explains the built-in env keys in plain words, using the backend's about line.
    • apikeys groups <id> --group … (PATCH) replaces a key's groups.
    • apikeys revoke is unchanged.
    • typetorch keys create|list|revoke|groups still works and runs the same code.
  • typetorch groups list|create|edit|delete and typetorch members list|add|edit|remove are new, in src/groups.ts and src/commands/groups.ts.
    • members takes a UserId or a username. Usernames are looked up with the backend's existing GET /v1/identity?name=.
  • TYPETORCH_FLEET_KEY is read as an alias of TYPETORCH_API_KEY in backendCredentials, init (key generation and the existing-backend prompts), repair and doctor.
    • If both are set with different values, the key is refused (the server does the same).
    • init still writes TYPETORCH_API_KEY, and the server env writers are unchanged, so an older backend build still works.
    • backend setup still writes the env key into backend.key / fleet.token. That is now tested with the alias alone.
  • doctor explains which key is which in its Config section: the fleet key is what game servers send data with, and the admin key is what your CLI uses.
  • Settings-record key check (endpoints.ts): when /v1/auth/check reports permissions, the key must hold exactly ingest:write. Otherwise the check fails and --force can't override it.
    • The reason: the backend's derived role is "game" for any key with ingest:write and no explorer:read. A custom group that adds access:manage would otherwise pass and be signed into a record every game script can read.
    • Without permissions (an older backend), the check still goes by role.
  • A 403 that carries an error body now shows the backend's reason (and need), not "refused the admin token". New examples are "can't grant permissions you don't hold" and "can't change the key you are using".

Older backends (no groups or members)

  • Create: a key in exactly one role's group sends role too, so an older backend makes the same key.
    • Any other set of groups is sent without role. The older backend then answers 400 "role is one of", and the CLI says it predates groups and that no key was made. It never makes a narrower key.
  • apikeys groups: an older backend answers 405, and the CLI says it predates groups.
  • Groups and members routes: an older backend answers 404 {error:"not found"}. The CLI then asks /v1/auth/check:
    • no permissions in the answer: the backend predates groups;
    • 404 there too: the admin IP allow list doesn't include this PC;
    • permissions present: the route is unknown to this backend.
  • apikeys list: groups are derived from each key's role, with a note saying so.

Judgment calls

  • The settings-record key must be fleet-only (ingest:write and nothing else), with no --force escape. A key in fleet plus any other group is refused.
  • The admin step still requires role admin, which means every permission. A narrower key is named by what it may do, not accepted.
  • The 403 message changes for every admin command when the backend sends a reason.
  • An input that is all digits is treated as a UserId.
  • A username resolves only for players the backend has seen, because /v1/identity?name= returns identity rows. There is no fallback to users.roblox.com; for anyone else the CLI asks for the UserId.
  • apikeys groups and members edit --group replace the groups rather than add to them.
  • --group is only checked for shape, not against a fixed list, because custom groups exist.
  • src/commands/backend.ts is untouched (Security fixes from the 2026-12-05 audit #48 and typetorch settings secrets: move the record's tokens to the Roblox Secrets Store #50 edit it), so its messages still name only TYPETORCH_API_KEY.
  • The new apikeys, groups and members commands get their own "Backend access" group in typetorch help.
  • CHANGELOG.md is gitignored; it was updated on disk in the main checkout.

Expected conflicts

Checks

  • bunx tsc --noEmit: clean.
  • bun test: 932 pass, 0 fail. An earlier run under load had two debug-macros timeouts; they pass alone and in the final run.
  • bun run build and node scripts/smoke.mjs: pass.
  • New tests are in test/groups.test.ts, with additions to test/apikeys.test.ts, test/endpoints.test.ts, test/backend.test.ts and test/init-backend.test.ts.

🤖 Generated with Claude Code

phasenull and others added 5 commits December 5, 2026 15:56
…gs-record key check goes by permissions when the backend reports them (only ingest:write may go in)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… typetorch groups and typetorch members (backend plans/38); an older backend is named as such

keys create|list|revoke stay and also take groups; --role is an alias of one group (game = fleet). A 403 that says
why shows the backend's reason.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…servers send data with it; admin key = your CLI); TYPETORCH_FLEET_KEY shown when used

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ey in plain words; TYPETORCH_FLEET_KEY

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ests for init and backend setup with the alias alone; server strings in key lists cleaned for the terminal

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant