feat: Addition of authentication and user management systems

This commit is contained in:
Lino Mallevaey
2025-08-19 23:17:06 +02:00
parent 954f73a0f5
commit 70ae9654e0
9 changed files with 340 additions and 21 deletions

View File

@@ -0,0 +1,21 @@
from pydantic import BaseModel, Field, field_validator
# ----------------------------------------------------------------------
# Token
# ----------------------------------------------------------------------
class TokenRequest(BaseModel):
username: str = Field(..., min_length=3, max_length=30)
password: str
@field_validator("username")
def all_allowed_chars(cls, v):
for v_char in v:
if not v_char in "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_":
raise ValueError("username can only contain a-z, A-Z, 0-9 and _")
return v
class TokenResponse(BaseModel):
access_token: str
token_type: str = "bearer"