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
@@ -4,6 +4,7 @@ import { readAuthConfig, hasProvider, clientConfig } from './config.js';
|
||||
import { createOidcClient, OidcCallbackError } from './oidc.js';
|
||||
import { issueSession, readSession, clearSession, setTx, takeTx, safeRedirect } from './session.js';
|
||||
import { mapAccount } from './accountMapping.js';
|
||||
import { renameGuard } from './rename.js';
|
||||
|
||||
export { readAuthConfig, clientConfig };
|
||||
|
||||
@@ -43,16 +44,8 @@ export const createAuthRouter = (config, deps = {})=>{
|
||||
const parseCookies = cookieParser();
|
||||
router.use((req, res, next)=>req.cookies ? next() : parseCookies(req, res, next));
|
||||
|
||||
// Upstream-Route sperren/umleiten, bevor sie greift
|
||||
router.put('/api/user/rename', (req, res, next)=>{
|
||||
if(req.account?.provider === 'oidc') {
|
||||
return res.status(403).json({
|
||||
error : 'Benutzernamen von OIDC-Konten sind unveränderlich.',
|
||||
HBErrorCode : 'A01'
|
||||
});
|
||||
}
|
||||
next();
|
||||
});
|
||||
// Upstream-Route absichern, bevor sie greift: OIDC gesperrt (A01), naturalcrit nur mit Nachweis (ADR 0001 §7)
|
||||
router.put('/api/user/rename', renameGuard(config));
|
||||
|
||||
if(!naturalcritEnabled) {
|
||||
router.post('/local/login', (req, res)=>res.status(404).json({ error: 'Not found' }));
|
||||
|
||||
Reference in new issue
Block a user