Upgrading to v0.8.0
v0.8.0 is the account security release: two-factor authentication, security emails, sessions in Settings, asking for the password again before risky changes, and an optional breached-password check. Apps without accounts (--Auth none) change very little.
Start from v0.7.0. Make and apply the patch as How to upgrade describes:
./upgrade-patch.sh 0.7.0 0.8.0 MyApp --Auth saas # your name and options
git apply -3 upgrade.patchHow big the patch is depends on the options:
--Auth | Files changed |
|---|---|
saas | about 112 (115 with EF Core) |
identity | about 90 |
none | 6: docs and package versions |
Before you deploy
Decide on the new settings
| Setting | Default | What to do |
|---|---|---|
Accounts:AskForProductNews | true | Sign-up shows an unticked "Send me product news" box. Turn it off if the app won't send product news. |
Accounts:RequireTwoFactorForAdmins | false | Turn on to keep the back office for admins with two-factor authentication. Admins without it are sent to Settings to set it up. |
Accounts:RejectBreachedPasswords | false | Turn on to refuse new passwords known from data breaches. It calls Have I Been Pwned's range API, sending five characters of the password's SHA-1 hash. |
Accounts:TwoFactorIssuer | the app's name | The name authenticator apps show next to the code. |
Expect more email
People are now emailed when:
- their password is changed or reset, or their email changes (at the old address);
- two-factor authentication is turned on or off, or recovery codes are replaced or used;
- a passkey or a Google or GitHub sign-in is added or removed;
- the account is locked after too many wrong passwords or codes;
- someone signs in from a device that hasn't signed in before.
These are always sent. Check that your email provider's sending limits allow for them. The text is in Identity/Email/SecurityNotices.cs.
EF Core: two migrations
AddSessions (sessions on refresh tokens) and, with organisations, AddOrganisationTwoFactor. They're applied at startup. If you added migrations of your own, see the EF Core note on the model snapshot.
With Marten, the user document gains AuthenticatorKey and RecoveryCodes, and organisation members a two-factor field: nothing to migrate.
If you changed the template's code
The compiler finds most of these. They matter if your code calls the account endpoints directly, replaces the template's stores, or has another client (a mobile app, say) signing in.
- Endpoints that change sign-in details return
(result, OutgoingMessages)with aSendSecurityNotice: changing and resetting the password, confirming an email change, adding or removing a passkey, removing a Google or GitHub sign-in, the two-factor endpoints, and the Google/GitHub callback. Login, the two-factor step and passkey login do too, for the new-device email. Read the result from the tuple's first item. - Logging in can answer 403 with
"reason": "TwoFactorRequired"and atwoFactorTicket. Clients other than the bundled one then send the ticket and a code toPOST /api/auth/two-factorfor the tokens. See Sign in from a mobile or desktop app. - Changing the email needs the current password (
UpdateProfileRequest.CurrentPassword, andTwoFactorCodewith two-factor on), and deleting the account needs a code with two-factor on (DeleteAccountRequest.TwoFactorCode;Passwordis now optional, for accounts without one).GET /api/auth/mehashasPasswordandtwoFactorEnabled, so a client knows what to ask for. UserManager<ApplicationUser>is nowApplicationUserManager, registered in its place. Code that asks forUserManager<ApplicationUser>gets it unchanged. If your app has its own user manager, derive it fromApplicationUserManagerinstead.IRefreshTokenStorehasListActiveForUserAsyncandRevokeSessionsAsync, and with organisationsIOrganisationStore.CanWorkInAsynctakes whether the user has two-factor. Add them to your own implementations.- Access tokens carry a
sidclaim (the session) and, with organisations, atfaclaim.JwtTokenService.CreateAccessTokentakes them. TokenIssuercan leave the Admin role out of a token whenAccounts:RequireTwoFactorForAdminsis on.RegisterRequesthasProductNews, andAuthOptionsResponsesays whether to ask.- A new client dependency,
uqr, draws the QR code: runnpm installinsrc/Client.
Check it works
After the checks in How to upgrade:
- Sign in, open Settings → Two-factor authentication, set it up with an authenticator app, and save the recovery codes.
- Sign out and in again: you're asked for a code.
- Open Settings → Sessions: this device is listed.
- Check Mailpit (http://localhost:8025) for the "Two-factor authentication is on" email.
The full release notes list everything new.