Repository navigation
fix(auth): a scoped token gets the intersection of its scopes and its owner's rights - #528
Merged
Merged
Conversation
… owner's rights Scope targets were only a filter over the owner's assigned targets, so a token scoped to a target not assigned to its owner (an admin's token limited to a fresh target) was denied everything. The evaluator now loads the scope targets by ID (one cached lookup, invalidated with the other permission-target writes) and allows a request iff a scope target and an owner target both allow it. Access never exceeds the owner's rights; assigned scopes behave as before. Docs updated.
Coverage
Go by area
Web by area (lines)
|
M0Rf30
added a commit
that referenced
this pull request
Nov 27, 2026
The bundle/copy authz mock loads token scope targets by ID (#528 made the evaluator read them).
Merged
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.
A token's
scopeswere only a filter over the owner's assigned permission targets, so a token scoped to a target that is not assigned to its owner (e.g. an admin's token limited to a freshci-dockertarget) was denied everything, although the docs promise the intersection.Now a request by a scoped token is allowed iff (a) at least one scope target (loaded by ID, assigned or not) covers repo/path/action and (b) the owner's own targets (
GetPermissionTargetsForPrincipal) allow it too. It never widens access beyond the owner; assigned scopes behave as before; a deleted scope target covers nothing; scoped tokens still get no project-role access; non-scoped principals are unchanged.EvaluatorStore.GetPermissionTargetsByIDs+ sqlc queryGetPermissionTargetsByIDs: one query for all scopes (at most 64), served by the auth cache (same map, keyed apart) and dropped by the existing permission-target write invalidation.EvaluateandPathReadFiltershareprincipalGrants/grantsAllow.scopes, RBAC page, upgrade notes;authorizeTokenScopescomment.internal/auth/permission_scope_test.go(unassigned scope + admin-all owner, owner lacking the right, assigned scope, deleted scope, several scopes, non-scoped, batch read filter) andTestAuthCache_ScopeTargetsVisible(integration).Fixes #509