44 lines
1.3 KiB
Python
44 lines
1.3 KiB
Python
from datetime import datetime
|
|
|
|
from pydantic import BaseModel, ConfigDict, Field
|
|
|
|
|
|
class AuthUserDocument(BaseModel):
|
|
model_config = ConfigDict(extra="forbid")
|
|
|
|
username: str = Field(
|
|
...,
|
|
description="Unique username for the single account",
|
|
)
|
|
password_hash: str = Field(..., description="Hashed password")
|
|
created_at: datetime | None = Field(
|
|
default=None,
|
|
description="Creation timestamp in UTC",
|
|
)
|
|
updated_at: datetime | None = Field(
|
|
default=None,
|
|
description="Last update timestamp in UTC",
|
|
)
|
|
|
|
|
|
class LoginInput(BaseModel):
|
|
model_config = ConfigDict(extra="forbid")
|
|
|
|
username: str = Field(..., description="Username")
|
|
password: str = Field(..., description="Plain text password")
|
|
|
|
|
|
class TokenResponse(BaseModel):
|
|
model_config = ConfigDict(extra="forbid")
|
|
|
|
access_token: str = Field(..., description="JWT access token")
|
|
token_type: str = Field(default="bearer", description="Token type")
|
|
|
|
|
|
class AccessTokenPayload(BaseModel):
|
|
model_config = ConfigDict(extra="forbid")
|
|
|
|
sub: str = Field(..., description="Subject username")
|
|
jti: str = Field(..., description="Unique token identifier")
|
|
exp: int = Field(..., description="Token expiration as unix timestamp")
|