Public: anyone can read this; the crew can change it.
Roles, part 3c: a token a member mints carries scopes only over that member's own repositories and apps #2401
A token minted by a non-admin person now reaches only that person's own repositories and apps, and can't carry the admin scope. An admin's minting is unchanged. The type check is clean and the new test file passes.
stopped parked by the crew deploy b2d7105
A token minted by a non-admin person now reaches only that person's own repositories and apps, and can't carry the admin scope. An admin's minting is unchanged. The type check is clean and the new test file passes. I also ran the roles, tokens, schema-additive, API, auth, MCP, proposal-token-doors and account suites, and all passed. I did not run the whole suite.
What changed
- Flag on the token: a new migration adds
token.own_only(ALTER TABLE … ADD COLUMNwith a default of 0, so it is additive).createTokeninsrc/actions/users.tssets it for any non-admin human account. Tokens minted before this keep what they could reach. - Refusal at minting: asking for
adminas a non-admin person returnstoo_wide.- On
POST /api/v1/tokensthat is a 403 with the line "a token you mint reaches only your own repositories and apps: choose read or read and write". - On
/settings/tokensthe same line shows as a flash. The form no longer offers the admin option to non-admins.
- On
- Refusal at use:
src/http/own_gate.tsruns after the proposal gate on each request. For a flagged token, a git path (/:owner/:name.git/…) or an API path (/api/v1/repos/:owner/:name/…) under another account returns 403. Paths that name no repository pass as before. - Docs:
docs/ROLES.mdhas a short "Tokens" section. - Tests:
test/token-own-only.test.tscovers:- A member's token works on their own repository.
- The same token gets 403 on another account's repository, over the API and over git.
- The admin scope is refused on the API and the page.
- An admin's admin token still reaches every repository.
- How
ownerNamedreads a path.
What I chose not to do
- Roles: guests are treated like members here, since they can't own anything anyway. Agents and organizations are untouched.
- Org-owned repositories: a member's token is refused on them, even where the member could write through a team. "Own" means the member's own account.
- Other-account lookups:
/api/v1/users/:username/reposand/api/v1/orgs/…name no repository, so they still pass the gate. Those routes act as the member and expose nothing new. - Per-repository or per-app scopes: I did not add scopes tied to a single repository or app. Scopes stay
ro,rwandadmin.
To try it: as a non-admin, curl -X POST $URL/api/v1/tokens -d '{"username":…,"password":…,"scope":"rw"}'. Use the token on /api/v1/repos/<you>/<repo> (200) and on /api/v1/repos/<other>/<repo> (403). Asking for "scope":"admin" gets the 403 above.
🤖 Generated with Claude Code
Parked by the crew: the check failed ("branches on a native repo > a reader who cannot write is refused, and a stranger sees nothing") and the decider saw no point in another try
A token minted by a non-admin person now reaches only that person's own repositories and apps, and can't carry the
adminscope. An admin's minting is unchanged. The type check is clean and the new test file passes. I also ran the roles, tokens, schema-additive, API, auth, MCP, proposal-token-doors and account suites, and all passed. I did not run the whole suite.What changed
token.own_only(ALTER TABLE … ADD COLUMNwith a default of 0, so it is additive).createTokeninsrc/actions/users.tssets it for any non-admin human account. Tokens minted before this keep what they could reach.adminas a non-admin person returnstoo_wide.POST /api/v1/tokensthat is a 403 with the line "a token you mint reaches only your own repositories and apps: choose read or read and write"./settings/tokensthe same line shows as a flash. The form no longer offers the admin option to non-admins.src/http/own_gate.tsruns after the proposal gate on each request. For a flagged token, a git path (/:owner/:name.git/…) or an API path (/api/v1/repos/:owner/:name/…) under another account returns 403. Paths that name no repository pass as before.docs/ROLES.mdhas a short "Tokens" section.test/token-own-only.test.tscovers:ownerNamedreads a path.What I chose not to do
/api/v1/users/:username/reposand/api/v1/orgs/…name no repository, so they still pass the gate. Those routes act as the member and expose nothing new.ro,rwandadmin.To try it: as a non-admin,
curl -X POST $URL/api/v1/tokens -d '{"username":…,"password":…,"scope":"rw"}'. Use the token on/api/v1/repos/<you>/<repo>(200) and on/api/v1/repos/<other>/<repo>(403). Asking for"scope":"admin"gets the 403 above.🤖 Generated with Claude Code
Closes #2386