From 8b57f6c2ffb0e61f926e2724d6230cabef64de32 Mon Sep 17 00:00:00 2001 From: Stephan Rehfeld Date: Sun, 22 Nov 2026 20:16:00 +0100 Subject: [PATCH] =?UTF-8?q?Test-Passwort=20abschaltbar:=20ohne=20ui.passwo?= =?UTF-8?q?rd=5Flogin=20weder=20in=20der=20Oberfl=C3=A4che=20noch=20=C3=BC?= =?UTF-8?q?ber=20die=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- proxy/src/api.rs | 4 ++++ proxy/ui/app.js | 6 +++--- tests/multispark/proxy.toml | 2 ++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/proxy/src/api.rs b/proxy/src/api.rs index 1276426..e2abade 100644 --- a/proxy/src/api.rs +++ b/proxy/src/api.rs @@ -535,6 +535,7 @@ async fn me(State(st): State, Extension(actor): Extension, Exte let mut me = serde_json::to_value(Service::new(&st.db, &actor).personal_dashboard()?).map_err(anyhow::Error::from)?; me["directory"] = json!(st.directory.is_some()); me["enrolling"] = json!(st.db.session_enrolling(&token.0)?); + me["password_login"] = json!(st.ui.password_login); ok(me) } @@ -582,6 +583,9 @@ async fn set_password( Path(username): Path, Json(input): Json, ) -> ApiResult { + if !st.ui.password_login { + return Err(crate::service::forbidden("Die Anmeldung mit Passwort ist ausgeschaltet (ui.password_login)").into()); + } Service::new(&st.db, &actor).set_password(&username, &input.password)?; done() } diff --git a/proxy/ui/app.js b/proxy/ui/app.js index 04d1642..fc4bee3 100644 --- a/proxy/ui/app.js +++ b/proxy/ui/app.js @@ -1025,8 +1025,8 @@ async function accountPage() { h('tr', {}, h('td', { class: 'muted' }, 'Rolle'), h('td', {}, ROLE[u.role])), h('tr', {}, h('td', { class: 'muted' }, 'E-Mail'), h('td', {}, u.email || '–')), h('tr', {}, h('td', { class: 'muted' }, 'Gruppen'), h('td', { class: 'wrap' }, state.me.groups.join(', ') || '–'))))), - h('section', { class: 'card grow' }, h('h2', {}, 'Passwort (Testbetrieb)'), - h('p', { class: 'hint' }, 'Nur für die Anmeldung mit Passwort im Testbetrieb. Das Passwort der Hochschule änderst du dort.'), pw)), + state.me.password_login ? h('section', { class: 'card grow' }, h('h2', {}, 'Passwort (Testbetrieb)'), + h('p', { class: 'hint' }, 'Nur für die Anmeldung mit Passwort im Testbetrieb. Das Passwort der Hochschule änderst du dort.'), pw) : null), signInCards(methods), recoveryCard(methods), h('section', { class: 'card' }, h('h2', {}, 'Meine Daten (DSGVO-Auskunft)'), @@ -1907,7 +1907,7 @@ async function usersPage() { h('div', { class: 'field-group' }, h('label', { for: 'u-mail' }, 'E-Mail'), userMail), h('div', { class: 'field-group' }, h('label', { for: 'u-role' }, 'Rolle'), h('select', { id: 'u-role', name: 'role', class: 'field' }, Object.entries(ROLE).map(([v, l]) => h('option', { value: v }, l)))), - h('div', { class: 'field-group' }, h('label', { for: 'u-pw' }, 'Passwort (Testbetrieb)'), h('input', { id: 'u-pw', name: 'password', type: 'password', class: 'field', autocomplete: 'new-password' }))), + state.me.password_login ? h('div', { class: 'field-group' }, h('label', { for: 'u-pw' }, 'Passwort (Testbetrieb)'), h('input', { id: 'u-pw', name: 'password', type: 'password', class: 'field', autocomplete: 'new-password' })) : null), h('span', { class: 'hint' }, state.me.directory ? 'Personen registrieren sich selbst bei der ersten Anmeldung mit dem Login der Hochschule. Hier angelegte Konten müssen im Verzeichnis stehen; die E-Mail-Adresse kommt von dort.' : 'Im Betrieb registrieren sich Personen selbst mit dem Login der Hochschule (LDAP).'), h('div', { class: 'actions' }, h('button', { class: 'btn primary', type: 'submit' }, 'Benutzer anlegen'))); diff --git a/tests/multispark/proxy.toml b/tests/multispark/proxy.toml index 68b87ef..ce9c1e1 100644 --- a/tests/multispark/proxy.toml +++ b/tests/multispark/proxy.toml @@ -3,6 +3,8 @@ database = "run/test.db" first_admin = "admin" [ui] +# Anmeldung mit Passwort aus der Datenbank, nur für Tests; die Testskripte brauchen sie. +# Mit false verschwindet sie aus der Oberfläche und die API nimmt sie nicht mehr an. password_login = true # Verzeichnis der Hochschule: Anmeldung mit dem Login der Hochschule und Personensuche