requirements.txt changed, auth.py file added for user management, announcement_service_spec.yaml changed since api definition did not load, main.py changes to access new mongoDB collection, patchnotes_controller.py expendet so save user last login

This commit is contained in:
2025-05-21 17:02:09 +02:00
parent bdf0466d79
commit 7f8d7cbc86
5 changed files with 78 additions and 41 deletions
+15
View File
@@ -0,0 +1,15 @@
import jwt
from connexion import ProblemException
from flask import request
def current_user_id() -> str:
"""Liest die User-UUID (sub) aus dem Bearer-JWT im Authorization-Header."""
auth = request.headers.get("Authorization", "")
if not auth.startswith("Bearer "):
raise ProblemException(status=401, detail="Missing Bearer token")
token = auth.split()[1]
# ↓ Für Demo ohne Signaturprüfung – produktiv natürlich verifizieren!
payload = jwt.decode(token, options={"verify_signature": False})
return payload["sub"]