feat: login mit serverseitigen sessions

- 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>
This commit is contained in:
dbildhauerandClaude Opus 5.5 committed 2026-10-25 11:04:33 +01:00
1 parent 04161bcf1d
commit 18f0d04ce9
11 files changed
+556 -3

No files matched your search

+41
View File
@@ -0,0 +1,41 @@
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