fix(webui): rotate stale bootstrap password and highlight credentials log
If the operator never completed the forced-change flow, the plaintext bootstrap password was unrecoverable on the next start (only the hash remained on disk, and the prior log line was likely gone). Now we detect a persisted state with mustChangePassword=true at load time and generate a fresh CSPRNG password so the operator can actually log in. The initial-credentials log block is also wrapped with separators and a bilingual notice so it stands out at boot. The 'initial credentials: user=admin password=%s' line is preserved verbatim because third-party launchers parse it.
This commit is contained in:
2 files changed
+18
-1
No files matched your search
@@ -151,6 +151,17 @@ export class WebuiAuth {
|
||||
const raw = fs.readFileSync(WEBUI_CONFIG_PATH, 'utf8');
|
||||
const parsed = JSON.parse(raw) as unknown;
|
||||
if (isValidState(parsed)) {
|
||||
if (parsed.mustChangePassword) {
|
||||
// Previous start generated a bootstrap password but the operator
|
||||
// never completed the forced-change flow. The plaintext is gone
|
||||
// (only the hash is on disk, and the log line from last run may
|
||||
// be lost), so rotate to a fresh CSPRNG password they can see.
|
||||
const initialPassword = randomBytes(8).toString('hex');
|
||||
const state = generateInitialState(initialPassword);
|
||||
atomicWrite(state);
|
||||
log.warn('previous bootstrap password was never rotated; regenerated a new one');
|
||||
return new WebuiAuth(state, initialPassword, false);
|
||||
}
|
||||
return new WebuiAuth(parsed, null, false);
|
||||
}
|
||||
log.error('webui.json schema invalid; backing up and regenerating credentials');
|
||||
|
||||
Reference in new issue
Block a user