- POST /api/auth/login|logout, GET /api/auth/me - Session-Token nur gehasht gespeichert, Cookie HttpOnly/Secure/SameSite=Lax - Ablauf nach 30 Tagen Inaktivität bzw. spätestens 90 Tagen - Sessions pro Gerät auflisten und widerrufen, Rotation beim Login - Passwortänderung beendet alle anderen Sessions Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
42 lines
893 B
Python
42 lines
893 B
Python
from datetime import datetime
|
|
|
|
from pydantic import BaseModel, ConfigDict, Field
|
|
|
|
from app.models import Role
|
|
|
|
|
|
class LoginRequest(BaseModel):
|
|
username: str = Field(min_length=1, max_length=255)
|
|
password: str = Field(min_length=1, max_length=1024)
|
|
|
|
|
|
class UserOut(BaseModel):
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
id: int
|
|
username: str
|
|
role: Role
|
|
is_active: bool
|
|
created_at: datetime
|
|
|
|
|
|
class PasswordChangeRequest(BaseModel):
|
|
current_password: str = Field(min_length=1, max_length=1024)
|
|
new_password: str = Field(min_length=1, max_length=1024)
|
|
|
|
|
|
class SessionOut(BaseModel):
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
id: int
|
|
created_at: datetime
|
|
last_seen_at: datetime
|
|
expires_at: datetime
|
|
ip: str | None
|
|
user_agent: str | None
|
|
current: bool = False
|
|
|
|
|
|
class RevokedResponse(BaseModel):
|
|
revoked: int
|