Skip to content

Commit

Permalink
fix: (Super)admins should be able to get-id and delete other users' v…
Browse files Browse the repository at this point in the history
…folders
  • Loading branch information
achimnol committed Jan 15, 2025
1 parent 9f9275b commit eaa4773
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/ai/backend/manager/api/vfolder.py
Original file line number Diff line number Diff line change
Expand Up @@ -2291,6 +2291,7 @@ async def delete_by_id(request: web.Request, params: DeleteRequestModel) -> web.
request,
VFolderPermissionSetAlias.READABLE,
folder_id,
allow_privileged_access=True,
)
assert len(rows) == 1
row = rows[0]
Expand Down Expand Up @@ -2326,6 +2327,7 @@ async def delete_by_name(request: web.Request) -> web.Response:
request,
VFolderPermissionSetAlias.READABLE,
folder_name,
allow_privileged_access=True,
)
if len(rows) > 1:
raise TooManyVFoldersFound(
Expand Down Expand Up @@ -2372,6 +2374,7 @@ async def get_vfolder_id(request: web.Request, params: IDRequestModel) -> Compac
request,
VFolderPermissionSetAlias.READABLE,
folder_name,
allow_privileged_access=True,
)
if len(rows) > 1:
raise TooManyVFoldersFound(
Expand Down
4 changes: 1 addition & 3 deletions src/ai/backend/manager/models/vfolder.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,9 +616,7 @@ async def _append_entries(_query, _is_owner=True):
query = query.where(
vfolders.c.status.not_in(vfolder_status_map[VFolderStatusSet.INACCESSIBLE])
)
if not allow_privileged_access or (
user_role != UserRole.ADMIN and user_role != UserRole.SUPERADMIN
):
if not allow_privileged_access or user_role not in (UserRole.ADMIN, UserRole.SUPERADMIN):
query = query.where(vfolders.c.user == user_uuid)
await _append_entries(query)

Expand Down

0 comments on commit eaa4773

Please sign in to comment.