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:
1 parent
04161bcf1d
commit
18f0d04ce9
11 files changed
+556
-3
No files matched your search
+10
-3
@@ -1,11 +1,12 @@
|
||||
from pathlib import Path
|
||||
|
||||
from fastapi import FastAPI, HTTPException
|
||||
from fastapi.responses import FileResponse
|
||||
from fastapi import FastAPI, HTTPException, Request, status
|
||||
from fastapi.responses import FileResponse, JSONResponse
|
||||
|
||||
from app import __version__
|
||||
from app.api import health
|
||||
from app.api import auth, health
|
||||
from app.config import get_settings
|
||||
from app.services.users import UserError
|
||||
|
||||
|
||||
def _register_frontend(app: FastAPI, static_dir: Path) -> None:
|
||||
@@ -33,6 +34,12 @@ def create_app() -> FastAPI:
|
||||
redoc_url=None,
|
||||
)
|
||||
app.include_router(health.router, prefix="/api")
|
||||
app.include_router(auth.router, prefix="/api")
|
||||
|
||||
@app.exception_handler(UserError)
|
||||
def user_error_handler(_request: Request, exc: UserError) -> JSONResponse:
|
||||
return JSONResponse({"detail": str(exc)}, status_code=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
_register_frontend(app, settings.static_dir)
|
||||
return app
|
||||
|
||||
|
||||
Reference in new issue
Block a user