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:
@@ -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"]
|
||||
Reference in New Issue
Block a user