Repository navigation
[M2.3f1b3] Web: API token scopes and project tokens - #186
Merged
Merged
Conversation
Signed-off-by: review <[email protected]>
3 tasks done
samuelmbabhazi
added a commit
that referenced
this pull request
Nov 7, 2026
…pts (#193) ## 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 - [x] Tests - [x] No new shell invocation, no new secret exposure path - [x] No new state change Signed-off-by: review <[email protected]> Co-authored-by: review <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
profile.readonly, so it could do nothing else. The form now offers: profile only (default), or an organization, optionally narrowed to a project and an environment, with permissions ticked one by one. Nothing is granted until it is ticked, and creating a token with no permission is refused.Why
PLAN M2.3f1b3, the last part of M2.3f1.
How it was tested
token-scope-picker.spec.ts: default grant, nothing granted until ticked, narrowing drops permissions the level no longer offers, binding only on request and cleared with the project, everything cleared on an organization change, profile only when organizations cannot load.token-form-store.spec.ts: the grant and project reach the request, and an empty grant sends nothing.access.spec.ts: listing and revoking project tokens, and hiding panels on 404.Local gate only (CI off). Not exercised in a real browser or against a running API, so the API's acceptance of these scope shapes rests on reading
parseApiScopes, not on a run.Security considerations
audit.readon one project would grant nothing, so it is not offered.member.managestays out because those routes are session only.docs/generated/route-role-matrix.md, and no test ties them together. A new bearer route needs an entry here. A stale list only hides an option; it cannot widen access.Checklist