Wire production domain, CORS for tenant subdomains, celery volume mounts, and nginx reverse proxy configs for apex, API, identity, auth, and wildcard tenants. Co-authored-by: Cursor <cursoragent@cursor.com>
25 lines
734 B
Python
25 lines
734 B
Python
"""نقشهای استاندارد پلتفرم (هماهنگ با Keycloak realm)."""
|
|
from __future__ import annotations
|
|
|
|
import enum
|
|
|
|
from shared.security import CurrentUser
|
|
|
|
|
|
class PlatformRole(str, enum.Enum):
|
|
PLATFORM_ADMIN = "platform_admin"
|
|
TENANT_ADMIN = "tenant_admin"
|
|
TENANT_MEMBER = "tenant_member"
|
|
PENDING_TENANT_ADMIN = "pending_tenant_admin"
|
|
USER = "user"
|
|
SERVICE_ACCOUNT = "service_account"
|
|
|
|
|
|
def has_role(user: CurrentUser, role: str | PlatformRole) -> bool:
|
|
role_value = role.value if isinstance(role, PlatformRole) else role
|
|
return role_value in user.roles
|
|
|
|
|
|
def has_any_role(user: CurrentUser, *roles: str | PlatformRole) -> bool:
|
|
return any(has_role(user, r) for r in roles)
|