Skip to content

Commit

Permalink
Return early for super admin
Browse files Browse the repository at this point in the history
  • Loading branch information
gmazoyer committed Nov 18, 2024
1 parent 6afc932 commit 8429d64
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions backend/infrahub/permissions/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ def get_permission_report( # noqa: PLR0911
action: str,
global_permission_report: dict[GlobalPermissions, bool],
) -> BranchRelativePermissionDecision:
if global_permission_report[GlobalPermissions.SUPER_ADMIN]:
return BranchRelativePermissionDecision.ALLOW

is_default_branch = branch.name in (GLOBAL_BRANCH_NAME, registry.default_branch)

if action != "view":
Expand Down Expand Up @@ -61,10 +64,6 @@ def get_permission_report( # noqa: PLR0911
permissions=permissions["object_permissions"], namespace=node.namespace, name=node.name, action=action
)

# What do we do if edit default branch global permission is set?
# if global_permission_report[GlobalPermissions.EDIT_DEFAULT_BRANCH]:
# decision |= PermissionDecisionFlag.ALLOW_DEFAULT

if (
decision == PermissionDecisionFlag.ALLOW_ALL
or (decision & PermissionDecisionFlag.ALLOW_DEFAULT and is_default_branch)
Expand Down

0 comments on commit 8429d64

Please sign in to comment.