feat(auth): add API-key authentication and tenant resolution
This commit is contained in:
16
src/application/auth/context.py
Normal file
16
src/application/auth/context.py
Normal 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
|
||||
Reference in New Issue
Block a user