From 7108d446d8fd08720d996da8808a6b64848866ab Mon Sep 17 00:00:00 2001 From: Midas Wollinger Date: Thu, 20 Aug 2026 09:39:20 +0200 Subject: [PATCH] fix 13 --- static/css/app.css | 6 ++ static/js/login.js | 8 +-- static/js/rdp.js | 4 +- static/js/terminal.js | 4 +- templates/login.html | 6 +- templates/rdp.html | 3 +- templates/terminal.html | 5 +- tests/test_csp_compliance.py | 117 +++++++++++++++++++++++++++++++++++ 8 files changed, 137 insertions(+), 16 deletions(-) create mode 100644 tests/test_csp_compliance.py diff --git a/static/css/app.css b/static/css/app.css index 236e3db..b34cfa9 100644 --- a/static/css/app.css +++ b/static/css/app.css @@ -57,6 +57,12 @@ button:hover { filter: brightness(1.1); } .qr { display: block; margin: 1rem auto; border-radius: 6px; } .recovery-codes { font-family: monospace; background: #0f1218; padding: 0.75rem; border-radius: 6px; } +/* Sichtbarkeits-Toggle ohne Inline-Styles -- CSP (style-src 'self', kein + 'unsafe-inline') blockt sowohl style="..."-Attribute in Markup als auch + per JS gesetzte element.style-Aenderungen. Toggle daher ausschliesslich + ueber diese Klasse (siehe login.js / terminal.js / rdp.js). */ +.hidden { display: none !important; } + .topbar { display: flex; align-items: center; justify-content: space-between; padding: 0.75rem 1.25rem; border-bottom: 1px solid var(--border); background: var(--panel); diff --git a/static/js/login.js b/static/js/login.js index 053d3c0..8bb5853 100644 --- a/static/js/login.js +++ b/static/js/login.js @@ -41,14 +41,14 @@ const result = await postJson("/auth/login", { username, password }); pendingToken = result.pending_token; - passwordFields.style.display = "none"; - totpFields.style.display = "block"; + passwordFields.classList.add("hidden"); + totpFields.classList.remove("hidden"); if (!result.totp_enrolled) { mode = "enroll_start"; const enroll = await postJson("/auth/totp/enroll/start", { pending_token: pendingToken }); document.getElementById("qr-img").src = "data:image/png;base64," + enroll.qr_png_base64; - enrollBox.style.display = "block"; + enrollBox.classList.remove("hidden"); mode = "enroll_confirm"; submitBtn.textContent = "TOTP bestaetigen & einrichten"; } else { @@ -68,7 +68,7 @@ if (mode === "enroll_confirm") { const code = document.getElementById("totp-code").value.trim(); const result = await postJson("/auth/totp/enroll/confirm", { pending_token: pendingToken, code }); - recoveryBox.style.display = "block"; + recoveryBox.classList.remove("hidden"); document.getElementById("recovery-codes").textContent = result.recovery_codes.join("\n"); submitBtn.textContent = "Weiter zum Dashboard"; mode = "done"; diff --git a/static/js/rdp.js b/static/js/rdp.js index ecda490..ed9576e 100644 --- a/static/js/rdp.js +++ b/static/js/rdp.js @@ -11,9 +11,9 @@ (() => { "use strict"; - const hostId = window.JUMPHOST_HOST_ID; - const statusEl = document.getElementById("status"); const shell = document.getElementById("session-shell"); + const hostId = shell.dataset.hostId; + const statusEl = document.getElementById("status"); const displayDiv = document.getElementById("rdp-display"); const proto = window.location.protocol === "https:" ? "wss:" : "ws:"; diff --git a/static/js/terminal.js b/static/js/terminal.js index c580849..7cf0fc4 100644 --- a/static/js/terminal.js +++ b/static/js/terminal.js @@ -9,9 +9,9 @@ (() => { "use strict"; - const hostId = window.JUMPHOST_HOST_ID; - const statusEl = document.getElementById("status"); const shell = document.getElementById("session-shell"); + const hostId = shell.dataset.hostId; + const statusEl = document.getElementById("status"); const term = new Terminal({ cursorBlink: true, diff --git a/templates/login.html b/templates/login.html index 9fd588d..2a9a61a 100644 --- a/templates/login.html +++ b/templates/login.html @@ -19,18 +19,18 @@ -