v0.8.0
Account security: two-factor authentication with an authenticator app, security emails (including sign-ins from new devices), sessions in Settings, asking again before the email changes or the account is deleted, and an optional check for breached passwords. Also a product news opt-in.
Changes to know about
- Logging in can return a 403 with
reason: "TwoFactorRequired"and atwoFactorTicket, for accounts with two-factor authentication on. Clients other than the bundled one send the ticket and a code to the newPOST /api/auth/two-factorfor tokens. Google and GitHub sign-in sends the browser to/external-login#twoFactorTicket=...in that case. AdminUserhasTwoFactorEnabled, andManageUserEndpointshasPOST /api/admin/users/{id}/turn-off-two-factor.- Marten's
ApplicationUserhasAuthenticatorKeyandRecoveryCodes, andApplicationUserStoreimplements Identity's two-factor stores. With EF Core, Identity keeps them inAspNetUserTokens, which already exists: no migration. TokenIssuercan leave the Admin role out of an access token, whenAccounts:RequireTwoFactorForAdminsis on and the admin isn't protected by two-factor authentication (or signs in only with passkeys). The setting is off by default.- Endpoints that change sign-in details return messages too: change and reset password, confirm email change, add or remove a passkey, remove a Google/GitHub sign-in, the two-factor endpoints, the admin's turn-off and the Google/GitHub callback now return
(result, OutgoingMessages)with aSendSecurityNotice. Code that calls them directly reads the result from the tuple. - Two EF Core migrations:
AddSessions(session ID, start and User-Agent onRefreshTokens) and, with organisations,AddOrganisationTwoFactor(Organisations.RequireTwoFactor). They're applied at startup like the others. With Marten there's nothing to do. - Access tokens carry a
sidclaim (the session), and with organisations atfaclaim (the account has two-factor).JwtTokenService.CreateAccessTokentakes them. IRefreshTokenStorehas two more methods (ListActiveForUserAsync,RevokeSessionsAsync), andIOrganisationStore.CanWorkInAsynctakes whether the user has two-factor. Custom implementations add them.OrganisationMember,UserOrganisationandCurrentOrganisationhave a two-factor field each.- Changing the email needs the password, and deleting the account a code too, with two-factor on:
UpdateProfileRequesthasCurrentPasswordandTwoFactorCode(used only when the email changes), andDeleteAccountRequesthasTwoFactorCode; itsPasswordis now optional, for accounts without one. Wrong answers count towards the lockout. Clients other than the bundled one send them;GET /api/auth/mehashasPasswordandtwoFactorEnabledto say what to ask. - Login, the two-factor step and passkey login return messages too (the new-device email), as
(result, OutgoingMessages). Registration, accepting an invitation and the Google/GitHub callback set aknown_devicecookie (HttpOnly, path/api/auth). RegisterRequesthasProductNews, andAuthOptionsResponsehasProductNews(whether to ask).Accounts:AskForProductNewsis on by default: turn it off if the app doesn't send product news.UserManager<ApplicationUser>is nowApplicationUserManager(Identity/ApplicationUserManager.cs), which emails when an account is locked or a recovery code is used. Code that asks forUserManager<ApplicationUser>gets it without changes; an app with its own user manager derives from it instead.- A new client dependency,
uqr(MIT, no dependencies), draws the QR code.
New
- Settings → Two-factor authentication: scan a QR code (or type the key), confirm with a code, and save ten recovery codes (Copy, Download). Turning it off and getting new recovery codes need a current code. A warning shows when three or fewer recovery codes are left.
- A code step at sign-in after the password or Google/GitHub, which also takes a recovery code. Passkeys don't ask for one: they're already two factors. Wrong codes count towards the lockout, like wrong passwords.
- The back office shows a 2FA badge on users who have it on, and Turn off two-factor for someone who lost their phone and their recovery codes (in the audit log).
Accounts:RequireTwoFactorForAdmins: the back office only for admins with two-factor authentication on;/adminsends the others to Settings to set it up.Accounts:TwoFactorIssuer: the name authenticator apps show (the app's name by default).- Security emails: people are emailed when their password is changed or reset, their email changes (to the old address), two-factor authentication is turned on or off (also by an admin), their recovery codes are replaced or one is used (with how many are left), a passkey or Google/GitHub sign-in is added or removed, or the account is locked after too many wrong passwords or codes (
Identity/Email/SecurityNotices.cs). - Settings → Sessions: where you're signed in (browser and system, when it started, when it was last active, and "This device"), with Sign out for one session and Sign out everywhere else.
- Organisations can require two-factor authentication (organisations mode): an owner's setting on the organisation page. Members without it lose access straight away and are asked to turn it on; the switcher marks the organisation, and the members list shows who has it.
docs/extending.md, "Where to add things": where an app or a library plugs in (endpoints, messages, data, settings, preferences, emails, Settings sections, back office tabs, pages), so its code survives updates from the template.- Logos in the back office: the organisations list, a user's organisations and the organisation page show each organisation's logo; the page also shows "Requires 2FA".
- "A new sign-in to your account": an email when someone signs in on a device that hasn't signed in to the account before (
Identity/KnownDevices.cs). - Confirming it's you: Settings asks for the password (and a code, with two-factor on) before changing the email or deleting the account. Accounts that sign in only with Google, GitHub or passkeys can now delete themselves, by typing their email address.
Accounts:RejectBreachedPasswords(off by default): new passwords known from data breaches are refused, checked with Have I Been Pwned's Pwned Passwords without sending the password (only five characters of its SHA-1 hash).- Product news opt-in: an unticked "Send me product news" box at sign-up, and a box in Settings → Preferences, kept with when it was chosen in
UserPreferences.ProductNews. - "Download your data" says whether two-factor authentication is on, never the key or codes.
- See the generated app's
docs/accounts.md#two-factor-authentication.