feat(auth): implement authentication endpoints and JWT handling

This commit is contained in:
gabdevele
2026-04-12 20:18:33 +02:00 Unverified
parent f3979c56ef
commit cc8ae34838
18 changed files with 640 additions and 33 deletions
+43
View File
@@ -0,0 +1,43 @@
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")