Skip to content

Fix the token picker: offer each permission at the level the API accepts - #193

Merged
samuelmbabhazi merged 1 commit into
mainfrom
fix/token-picker-exact-scope
Nov 7, 2026
Merged

samuelmbabhazi merged 1 commit into
mainfrom
fix/token-picker-exact-scope

Conversation

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator

What changed

The token scope picker now offers each permission only at the exact level the API accepts it: organization, project or environment.

Why

A bug in #186. Choosing an organization offered deploy.run, secret.write and others. The tenant policy (validPermissionScope) accepts each permission at one level only, so the API refused the whole token with 403, even for an owner. Deploying and secrets need an environment, because its protection decides them.

I had assumed a wider scope covers narrower resources. My unit tests encoded the same wrong assumption, and the browser test only tried combinations that happened to be valid. Writing a real CLI token for M8.2b exposed it.

How it was tested

  • Unit tests now pin the exact list at each level.
  • Browser test: an environment-level token holding environment.read and deploy.run, created through the picker, gets 200 on the environment's applications and 403 on the project. tenant.browser.spec.ts passes in Chromium with a local PostgreSQL 18.4.

Limitation

The picker chooses one target, so one token cannot mix levels from the UI, for example node.manage on the organization with deploy.run on an environment. The API allows that. Create two tokens for now.

Security considerations

Narrows what is offered; the API remains the authority.

Checklist

  • Tests
  • No new shell invocation, no new secret exposure path
  • No new state change

@samuelmbabhazi
samuelmbabhazi merged commit 7c92553 into main Nov 7, 2026
@samuelmbabhazi
samuelmbabhazi deleted the fix/token-picker-exact-scope branch November 7, 2026 13:01
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