"""Data models for remem-auth."""

from enum import Enum
from typing import Any

from pydantic import BaseModel, Field


class AuthMethod(str, Enum):
    """How a user was authenticated."""

    JWT = "jwt"
    STATIC = "static"
    NONE = "none"


class ErrorFormat(str, Enum):
    """Response format for authentication errors."""

    DEFAULT = "default"
    OPENAI = "openai"


class IdpConfig(BaseModel):
    """Configuration for a single identity provider."""

    name: str
    issuer: str
    jwks_uri: str
    audience: str | None = None
    algorithms: list[str] = Field(default_factory=lambda: ["RS256"])


class AuthenticatedUser(BaseModel):
    """Represents a successfully authenticated user."""

    subject: str
    email: str | None = None
    name: str | None = None
    auth_method: AuthMethod
    idp_name: str | None = None
    claims: dict[str, Any] = Field(default_factory=dict)
    token: str = Field(default="", exclude=True, repr=False)
