fix(auth): PUT /api/user/rename auch für naturalcrit-Sitzungen absichern (F14)
Die Upstream-Route prüft nur, ob newUsername der eigenen Sitzung gehört, nicht den alten Namen. Der Fork-Router beantwortet die Route jetzt vorher: - OIDC-Sitzung: 403 A01 (unverändert) - ohne Anmeldung: 403 - naturalcrit, HB_NATURALCRIT_RENAME=off (Standard): 403 A02 - naturalcrit, HB_NATURALCRIT_RENAME=signed: nur mit Nachweis oldSession (nc_session-Token des alten Namens, HS256 mit SECRET), sonst 403 A03 Mit signed startet die App außerhalb lokaler Umgebungen nicht, solange SECRET der Standardwert ist. server/app.js bleibt unverändert. ADR 0001: neuer Abschnitt 7, Konfiguration, Tests, Folgen, F14. Closes #21 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bbf838c5d6
commit
03455c5bf5
9 files changed
+251
-43
No files matched your search
@@ -1,5 +1,7 @@
|
||||
// Auth-Konfiguration ausschließlich aus Umgebungsvariablen (ADR 0001, "Konfiguration").
|
||||
const VALID_PROVIDERS = ['oidc', 'naturalcrit'];
|
||||
// PUT /api/user/rename für naturalcrit-Sitzungen (ADR 0001, Abschnitt 7)
|
||||
const VALID_NC_RENAME = ['off', 'signed'];
|
||||
const MIN_SECRET_BYTES = 32;
|
||||
|
||||
const bool = (v, def = false)=>{
|
||||
@@ -46,9 +48,23 @@ export const readAuthConfig = (env = process.env, { upstreamSecret, isLocal = fa
|
||||
linkByEmail : bool(env.HB_OIDC_LINK_BY_EMAIL),
|
||||
endSession : bool(env.HB_OIDC_END_SESSION),
|
||||
label : env.HB_OIDC_LABEL || 'Anmelden'
|
||||
},
|
||||
// PUT /api/user/rename für naturalcrit-Sitzungen; secret = Schlüssel der Upstream-nc_session (ADR 0001, Abschnitt 7)
|
||||
naturalcrit : {
|
||||
rename : (env.HB_NATURALCRIT_RENAME || 'off').trim().toLowerCase(),
|
||||
secret : upstreamSecret
|
||||
}
|
||||
};
|
||||
|
||||
if(!VALID_NC_RENAME.includes(config.naturalcrit.rename)) {
|
||||
throw new Error(`HB_NATURALCRIT_RENAME ungültig: "${env.HB_NATURALCRIT_RENAME}" (erlaubt: ${VALID_NC_RENAME.join(', ')})`);
|
||||
}
|
||||
// Mit dem Standard-"secret" ließe sich der Nachweis (ein signiertes nc_session-Token des alten Namens) fälschen
|
||||
if(config.naturalcrit.rename === 'signed' && providers.includes('naturalcrit') && !isLocal
|
||||
&& (!upstreamSecret || upstreamSecret === 'secret')) {
|
||||
throw new Error('HB_NATURALCRIT_RENAME=signed braucht ein eigenes Upstream-"secret" (Env SECRET), der Standardwert ist unsicher.');
|
||||
}
|
||||
|
||||
if(providers.includes('oidc')) {
|
||||
const required = {
|
||||
HB_OIDC_ISSUER : config.oidc.issuer,
|
||||
|
||||
Reference in new issue
Block a user