Skip to content

Commit

Permalink
Enforce permission edit_default_branch when loading schema
Browse files Browse the repository at this point in the history
  • Loading branch information
dgarros committed Nov 16, 2024
1 parent 699f998 commit e6286c5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions backend/infrahub/api/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,17 @@ async def load_schema(
):
raise PermissionDeniedError("You are not allowed to manage the schema")

if branch.name in (GLOBAL_BRANCH_NAME, registry.default_branch) and not await permission_backend.has_permission(
db=db,
account_session=account_session,
permission=GlobalPermission(
action=GlobalPermissions.EDIT_DEFAULT_BRANCH.value,
decision=PermissionDecision.ALLOW_DEFAULT.value,
),
branch=branch,
):
raise PermissionDeniedError("You are not allowed to edit the schema in the default branch")

service: InfrahubServices = request.app.state.service
log.info("schema_load_request", branch=branch.name)

Expand Down
1 change: 1 addition & 0 deletions changelog/4958.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Permission edit_default_branch is now enforced properly when loading a schema

0 comments on commit e6286c5

Please sign in to comment.