modified: web/app.py

modified:   web/config.py
	modified:   web/templates/privacy_policy.html
This commit is contained in:
simon
2026-04-15 12:09:11 +02:00
parent e4727ba561
commit 52674fee29
3 changed files with 29 additions and 4 deletions

View File

@@ -3,6 +3,7 @@ MCLogger Flask Web-Panel
Multi-Tenant mit Gruppen, Rollen & verschlüsselten DB-Zugangsdaten.
Coolify-kompatibel: alle Einstellungen via ENV.
"""
import os
import secrets
from datetime import datetime
from flask import Flask, abort, render_template, request, session, url_for
@@ -20,6 +21,21 @@ from blueprints.panel import panel
def create_app() -> Flask:
app = Flask(__name__)
# ── Datenschutz-Version automatisch aus Template-Hash berechnen ──────────
# Wenn PRIVACY_POLICY_VERSION nicht per ENV gesetzt ist, wird der SHA-256
# des Template-Inhalts berechnet und die ersten 6 Zeichen als Version
# verwendet. Ändert sich der Seiteninhalt, ändert sich der Hash →
# alle Nutzer müssen beim nächsten Login erneut zustimmen.
if not os.getenv("PRIVACY_POLICY_VERSION"):
import hashlib
_policy_path = os.path.join(app.root_path, "templates", "privacy_policy.html")
try:
with open(_policy_path, "rb") as _f:
Config.PRIVACY_POLICY_VERSION = hashlib.sha256(_f.read()).hexdigest()[:6].upper()
except OSError:
pass # Fallback auf den Config-Default
app.secret_key = Config.SECRET_KEY
app.config.update(
SESSION_COOKIE_HTTPONLY=Config.SESSION_COOKIE_HTTPONLY,
@@ -129,6 +145,7 @@ def create_app() -> Flask:
last_updated="April 15, 2026",
invite_expiry_hours=Config.INVITE_EXPIRY_HOURS,
audit_retention_days=Config.AUDIT_LOG_RETENTION_DAYS,
policy_version=Config.PRIVACY_POLICY_VERSION,
)
@app.errorhandler(400)