Buckets:

download
raw
1.13 kB
from fastapi import status
from labelu.internal.common.error_code import ErrorCode, LabelUException
def assert_task_access(task, current_user) -> None:
"""Ensure current_user may access the given task's data.
Access is granted to the task owner or any of its collaborators. Any other
authenticated user is rejected with 403, closing IDOR/BOLA on task-scoped
resources (samples, pre-annotations, exports, ...).
"""
collaborator_ids = {c.id for c in task.collaborators}
if task.created_by != current_user.id and current_user.id not in collaborator_ids:
raise LabelUException(
code=ErrorCode.CODE_30001_NO_PERMISSION,
status_code=status.HTTP_403_FORBIDDEN,
)
def assert_owner(resource, current_user) -> None:
"""Ensure current_user owns the resource (created_by).
Used for user-private resources without a collaborator concept
(e.g. data sources).
"""
if resource.created_by != current_user.id:
raise LabelUException(
code=ErrorCode.CODE_30001_NO_PERMISSION,
status_code=status.HTTP_403_FORBIDDEN,
)

Xet Storage Details

Size:
1.13 kB
·
Xet hash:
587591d9664c1c06acc0914c0d70ba3191ce37965ed64bbea733a273b9abc4cc

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.