Skip to content

feat(auth): add two-factor sign-in with authenticator apps - #26

Merged
somaraj merged 2 commits into
developfrom
feature/two-factor
Nov 12, 2026
Merged

somaraj merged 2 commits into
developfrom
feature/two-factor

Conversation

@somaraj

@somaraj somaraj commented Nov 12, 2026

Copy link
Copy Markdown
Member

Closes #12. Builds on #25 (SSO); change the base to develop once #25 is merged.

Two-factor sign-in with any authenticator app (TOTP). Docs: docs/two-factor.md.

  • Setup under My profile → Security: server-side QR code, 10 single-use recovery codes.
  • Codes accepted for ±1 step and only once (no replay); secrets encrypted with Data Protection, recovery codes stored as SHA-256 hashes.
  • Wrong codes count towards the normal lock-out; max 5 codes per sign-in attempt. Fix: the failed-attempt counter is no longer reset by the password step for 2FA users.
  • Optional "don't ask again on this device" (Authentication:TwoFactor:RememberDeviceDays, default 30), invalidated when 2FA is reset or re-enabled.
  • Authentication:TwoFactor:RequireForAdministrators (off by default).
  • Admin reset on the user's page, logged for both accounts. SSO users are not asked.

Upgrade: one additive migration (AddUserTwoFactor, two new tables) and new translations; the Docker migrate container applies both. New NuGet dependency: QRCoder (MIT).

Tests: unit tests incl. RFC 6238 / RFC 4648 vectors, replay, recovery codes, remembered-device tokens and the admin policy; plus 30 end-to-end scenarios against a running instance.

TOTP (RFC 6238) two-factor sign-in, turned on per user under
My profile -> Security: server-side QR setup, ten single-use
recovery codes, optional "remember this device", and admin reset.
Authentication:TwoFactor:RequireForAdministrators (off by default)
makes it mandatory for administrators who sign in with a password.

Codes can't be replayed, wrong codes count towards the normal
lock-out, and the failed-attempt counter is now reset only after
the second step. Secrets are stored encrypted, recovery codes
hashed. Adds migration AddUserTwoFactor, locale keys,
docs/two-factor.md and the QRCoder (MIT) package.

Closes #12
- Always mark the remembered-device cookie Secure (S2092)
- Rename AuthMethod constants away from "Password" (S2068)
- Handle the clipboard promise when copying recovery codes (S9383)
- Make display-only/posted value-type model properties nullable (S6964)
- Focus the code field from script instead of autofocus (S9379)
- Fix the recovery/app toggle after a wrong recovery code
@sonarqubecloud

Copy link
Copy Markdown

@somaraj
somaraj merged commit abc1b3a into develop Nov 12, 2026
4 checks passed
@somaraj somaraj mentioned this pull request Nov 16, 2026
3 of 4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Two-factor sign-in (authenticator app)

2 participants