Sicherheit: Live-Aktionen nur mit aktivem Login; Seitenleiste warnt rot bei ausgeschaltetem Login
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -23,7 +23,8 @@ PORT = "8276"
|
||||
|
||||
|
||||
def live_enabled() -> bool:
|
||||
return os.getenv("DEPLOY_LIVE", "false").lower() == "true"
|
||||
"""DEPLOY_LIVE=true UND aktiver Login (guard.auth_ok) – ohne Login bleibt alles im Dry-Run."""
|
||||
return os.getenv("DEPLOY_LIVE", "false").lower() == "true" and guard.auth_ok()
|
||||
|
||||
|
||||
def token_present() -> bool:
|
||||
|
||||
@@ -33,3 +33,10 @@ def describe() -> str:
|
||||
def denial(tenant_id: str) -> str:
|
||||
return (f"Tenant „{tenant_id}“ ist für Live-Schreibzugriffe nicht freigegeben (Env DEPLOY_ALLOWED_TENANTS = {describe()}). "
|
||||
"Dry-Runs sind weiterhin möglich.")
|
||||
|
||||
|
||||
def auth_ok() -> bool:
|
||||
"""Live-Schreibzugriffe nur mit aktivem Login der Admin-Plattform (sonst wäre sie – mit Mittwald-Token im Container – für jeden offen).
|
||||
Nur für lokale Experimente übersteuerbar: ALLOW_NO_AUTH_LIVE=true."""
|
||||
from app.settings import AUTH_ENABLED
|
||||
return AUTH_ENABLED or os.getenv("ALLOW_NO_AUTH_LIVE", "false").lower() == "true"
|
||||
|
||||
@@ -43,7 +43,7 @@ def key_present() -> bool:
|
||||
|
||||
|
||||
def writes_allowed() -> bool:
|
||||
return os.getenv("OIDC_SYNC_LIVE", "false").lower() == "true" or os.getenv("DEPLOY_LIVE", "false").lower() == "true"
|
||||
return (os.getenv("OIDC_SYNC_LIVE", "false").lower() == "true" or os.getenv("DEPLOY_LIVE", "false").lower() == "true") and guard.auth_ok()
|
||||
|
||||
|
||||
def base_url(db) -> str:
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<div class="side-foot">
|
||||
<span class="pill {{ 'live' if deploy_live() else 'lock' }}" title="Env DEPLOY_LIVE der Admin-Plattform">Deploy: {{ 'live' if deploy_live() else 'gesperrt · Dry-Run' }}</span>
|
||||
{% set u = request.state.user if request is defined else None %}
|
||||
{% if u and u.email and u.email != 'dev@local' %}<span>{{ u.email }}<br><a href="/auth/logout">Abmelden</a></span>{% else %}<span class="pill dev">Login: aus</span>{% endif %}
|
||||
{% if u and u.email and u.email != 'dev@local' %}<span>{{ u.email }}<br><a href="/auth/logout">Abmelden</a></span>{% else %}<span class="pill live" title="AUTH_ENABLED ist nicht true: jeder mit der URL hat vollen Zugriff. Live-Aktionen sind gesperrt.">Login aus – offen!</span>{% endif %}
|
||||
</div>
|
||||
</aside>
|
||||
<div class="main">{% block body %}{% endblock %}</div>
|
||||
|
||||
Reference in New Issue
Block a user