Skip to content

Commit

Permalink
Sync task permissions with develop
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiltsov-max committed Oct 3, 2024
1 parent eb790c9 commit adcb367
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cvat/apps/engine/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,8 @@ class Scopes(StrEnum):
UPLOAD_DATA = 'upload:data'
IMPORT_BACKUP = 'import:backup'
EXPORT_BACKUP = 'export:backup'
VIEW_VALIDATION_LAYOUT = 'view:validation_layout'
UPDATE_VALIDATION_LAYOUT = 'update:validation_layout'

@classmethod
def create(cls, request, view, obj, iam_context):
Expand Down Expand Up @@ -496,8 +498,8 @@ def get_scopes(request, view, obj) -> List[Scopes]:
('export_backup', 'GET'): Scopes.EXPORT_BACKUP,
('export_backup_v2', 'POST'): Scopes.EXPORT_BACKUP,
('preview', 'GET'): Scopes.VIEW,
('validation_layout', 'GET'): Scopes.VIEW,
('validation_layout', 'PATCH'): Scopes.UPDATE,
('validation_layout', 'GET'): Scopes.VIEW_VALIDATION_LAYOUT,
('validation_layout', 'PATCH'): Scopes.UPDATE_VALIDATION_LAYOUT,
}[(view.action, request.method)]

scopes = []
Expand Down
14 changes: 14 additions & 0 deletions cvat/apps/engine/rules/tasks.rego
Original file line number Diff line number Diff line change
Expand Up @@ -306,3 +306,17 @@ allow if {
is_project_staff
}

allow if {
input.scope in {utils.VIEW_VALIDATION_LAYOUT, utils.UPDATE_VALIDATION_LAYOUT}
utils.has_perm(utils.USER)
utils.is_sandbox
is_task_staff
}

allow if {
input.scope in {utils.VIEW_VALIDATION_LAYOUT, utils.UPDATE_VALIDATION_LAYOUT}
input.auth.organization.id == input.resource.organization.id
organizations.has_perm(organizations.SUPERVISOR)
utils.has_perm(utils.USER)
is_task_staff
}

0 comments on commit adcb367

Please sign in to comment.