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>
30 lines
976 B
Python
30 lines
976 B
Python
"""قراردادهای مشترک مربوط به Tenant.
|
|
|
|
هر سرویس برای تشخیص و انتقال tenant از این ثابتها و ساختارها استفاده میکند
|
|
تا نام هدرها و کلیدها در همهجا یکسان باشد.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass
|
|
from uuid import UUID
|
|
|
|
# نام هدرهای استاندارد تشخیص tenant (بین همه سرویسها مشترک)
|
|
HEADER_TENANT_ID = "X-Tenant-ID"
|
|
HEADER_TENANT_SLUG = "X-Tenant-Slug"
|
|
|
|
# کلید ذخیره tenant در request.state
|
|
STATE_TENANT_ID = "tenant_id"
|
|
STATE_TENANT_SLUG = "tenant_slug"
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class TenantContext:
|
|
"""اطلاعات tenant جاری که در طول یک request حمل میشود."""
|
|
|
|
tenant_id: UUID | None
|
|
tenant_slug: str | None
|
|
|
|
@property
|
|
def is_resolved(self) -> bool:
|
|
return self.tenant_id is not None
|