feat(permissions): add rebase_branch permission#9124
Open
Conversation
Until now rebasing a branch required super_admin, even when the user already had merge_branch and merge_proposed_change. That left admins with no way to delegate rebase to a regular user. Add a rebase_branch global permission alongside the existing merge permissions, register it during first time initialization, and add a checker that gates the BranchRebase mutation. Closes #8050
edb825f to
2a7f382
Compare
polmichel
approved these changes
May 4, 2026
Contributor
polmichel
left a comment
There was a problem hiding this comment.
LGTM! I have just written an optional comment
| action=GlobalPermissions.REBASE_BRANCH.value, decision=PermissionDecision.ALLOW_ALL.value | ||
| ) | ||
|
|
||
| async def supports(self, db: InfrahubDatabase, account_session: AccountSession, branch: Branch) -> bool: # noqa: ARG002 |
Contributor
There was a problem hiding this comment.
This is an optional comment:
It seems that all checkers are using this exact logic, except backend/infrahub/graphql/auth/query_permission_checker/anonymous_checker.py.
Would promote this behavior as default behavior of the interface be a good idea? The down side of this solution would be that persons that would implement future other classes could miss customizing this behavior.
Otherwise, creating another abstract class named AuthenticatedQueryPermissionCheckerBase which overrides the support method could be another option?
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.
Why & What
Until now rebasing a branch required super_admin, even when the user already had merge_branch and merge_proposed_change. That left admins with no way to delegate rebase to a regular user.
Add a rebase_branch global permission alongside the existing merge permissions, register it during first time initialization, and add a checker that gates the BranchRebase mutation.
Closes #8050
In a follow-up PR, that will target
develop, I will probably try to get rid of checkers for branch merge and branch rebase. Havingraise_for_permissioncall in the mutation code should suffice. This PR targetsstablethat why I went with another checker, to be consistent with what already exists.Checklist
uv run towncrier create ...)