Spaces:
Paused
Paused
Download src/core/permissions.py from arimatch1/crewhub-api-2: direct link, hf CLI and curl.
- Browser
- Download file 1.16 kB
-
https://huggingface.co/spaces/arimatch1/crewhub-api-2/resolve/main/src/core/permissions.py
- Command line
-
hf download hf://spaces/arimatch1/crewhub-api-2/src/core/permissions.py
-
curl -L -o permissions.py https://huggingface.co/spaces/arimatch1/crewhub-api-2/resolve/main/src/core/permissions.py
1.16 kB
| # Copyright (c) 2026 CrewHub. All rights reserved. | |
| # Proprietary and confidential. See LICENSE for details. | |
| """Permission checking utilities.""" | |
| from uuid import UUID | |
| from src.core.exceptions import ForbiddenError | |
| def check_agent_owner(agent_owner_id: UUID, current_user_id: UUID) -> None: | |
| """Verify that the current user is the owner of the agent. | |
| Args: | |
| agent_owner_id: The UUID of the agent's owner. | |
| current_user_id: The UUID of the currently authenticated user. | |
| Raises: | |
| ForbiddenError: If the user is not the agent owner. | |
| """ | |
| if agent_owner_id != current_user_id: | |
| raise ForbiddenError(detail="You do not own this agent") | |
| def check_account_owner(account_owner_id: UUID, current_user_id: UUID) -> None: | |
| """Verify that the current user is the owner of the account. | |
| Args: | |
| account_owner_id: The UUID of the account's owner. | |
| current_user_id: The UUID of the currently authenticated user. | |
| Raises: | |
| ForbiddenError: If the user is not the account owner. | |
| """ | |
| if account_owner_id != current_user_id: | |
| raise ForbiddenError(detail="You do not own this account") | |