0.2.38: optional two-factor authentication (authenticator-app TOTP)

Per-user opt-in 2FA: enroll from the Two-factor option next to Change
password (QR + confirm code + 8 one-time recovery codes), login becomes
two-step for enrolled users, disable requires the account password.
Escape hatch for lost phones: reset-2fa CLI + Reset Two-Factor StartOS
action. Second-factor guesses share the login rate limiter; the pending
login window expires after 5 minutes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Jonathan Kirkwood
2026-07-11 22:08:04 +02:00
co-authored by Claude Fable 5
parent 053bfeab23
commit 0822eca887
20 changed files with 846 additions and 41 deletions
+49
View File
@@ -177,6 +177,54 @@ const resetPasswordAction = Action.withInput(
},
)
// ============================================
// Action: Reset Two-Factor
// ============================================
const resetTwoFactorInputSpec = InputSpec.of({
username: Value.text({
name: 'Username',
description: 'Username of the account whose two-factor should be cleared (lost phone)',
default: '',
required: true,
placeholder: 'admin',
}),
})
const resetTwoFactorAction = Action.withInput(
'reset-2fa',
{
name: 'Reset Two-Factor',
description:
"Clear a user's two-factor enrollment so they can sign in with just their password (e.g. after losing their authenticator)",
warning: null,
allowedStatuses: 'only-running',
group: null,
visibility: 'enabled',
},
resetTwoFactorInputSpec,
async () => ({ username: '' }),
async ({ input, effects }) => {
try {
const result = await runCli(
effects,
['reset-2fa', '--username', input.username],
'reset-2fa-task',
)
if (result.exitCode !== 0) {
return errorResult(result.stderr?.toString() || 'Failed to reset two-factor')
}
return {
version: '1' as const,
title: 'Two-Factor Reset',
message: `Two-factor cleared for ${input.username}. They can sign in with their password and re-enroll from the app.`,
result: null,
}
} catch (e: any) {
return errorResult(`Failed to reset two-factor: ${e.message || e}`)
}
},
)
// ============================================
// Action: List Users
// ============================================
@@ -500,6 +548,7 @@ const enableInvestorLoginsAction = Action.withoutInput(
export const actions = sdk.Actions.of()
.addAction(createUserAction)
.addAction(resetPasswordAction)
.addAction(resetTwoFactorAction)
.addAction(showAdminPasswordAction)
.addAction(listUsersAction)
.addAction(enableInvestorLoginsAction)