"""Keycloak authentication models.""" from dataclasses import dataclass, field from typing import Any @dataclass(frozen=True) class TokenInfo: """Information about validated token from Keycloak.""" active: bool user_id: str = "" username: str = "" email: str = "" roles: list[str] = field(default_factory=list) raw_claims: dict[str, Any] = field(default_factory=dict, repr=False) @property def is_valid(self) -> bool: """Check if token is valid and active.""" return self.active and bool(self.user_id) @dataclass(frozen=True) class KeycloakUser: """User information from Keycloak.""" id: str username: str email: str first_name: str = "" last_name: str = "" roles: list[str] = field(default_factory=list) is_active: bool = True