feat(auth): add API-key authentication and tenant resolution

This commit is contained in:
2026-08-19 15:00:13 +03:30
parent 3803d9c79a
commit e97ce6e5f3
7 changed files with 191 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
"""The trusted request-scoped auth/tenant context (ADR-0008)."""
import uuid
from dataclasses import dataclass
@dataclass(frozen=True)
class AuthContext:
tenant_id: uuid.UUID
tenant_slug: str
api_key_id: uuid.UUID
scopes: frozenset[str]
actor_type: str
def has_scope(self, scope: str) -> bool:
return scope in self.scopes or "admin" in self.scopes