2FA: the first set-up is confirmed by e-mail (twoFactor.confirmByEmail, 1.18.0)

Security audit 2026-12, F0: inside an account's setup window its password alone
enrolled an authenticator of the caller's choosing; the owner was locked out.

- /setup-totp for an account without a factor: IAPL checks the code, keeps the
  secret pending (payload-kv), mails a single-use 30-min link to the account and
  ties it to the enrolling browser; the package's handler (and its -totp cookie)
  is never used for a first enrolment
- GET /api/iapl/two-factor/confirm = a page with one button; POST confirms
  (own origin, same browser), ends the account's sessions, signs nobody in
- notice mails on every enrolment, change, removal / reset (any path)
- mail not working: link to the server log, admin confirms on the account page
  (POST /api/iapl/two-factor/confirm-pending), doctor rule 2fa-enrolment-mail
- options and opt-out (confirmByEmail: false), building blocks exported
- tests: HTTP suite on SQLite, MongoDB, Postgres; built-site spec in e2e:built;
  closed doors and judged routes; docs, AGENT.md, skills, changelog

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-12-01 13:37:39 +01:00
co-authored by Claude Opus 5.5
parent 84717804ae
commit c9d1f4b340
41 changed files with 1513 additions and 42 deletions
+2 -1
View File
@@ -107,7 +107,8 @@ const makeConfig = () =>
forms: {},
i18n: { defaultLocale: 'pl', locales: [{ code: 'pl', label: 'Polski' }] },
stats: true,
twoFactor: { issuer: 'Example', plugin: payloadTotp },
// the e-mail step of a first enrolment has its own suite (enrolmentConfirmHttp.test.ts); here the code alone turns it on
twoFactor: { confirmByEmail: false, issuer: 'Example', plugin: payloadTotp },
}),
latePlugin,
],