Skip to content

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:

bash
./upgrade-patch.sh 0.7.0 0.8.0 MyApp --Auth saas     # your name and options
git apply -3 upgrade.patch

How big the patch is depends on the options:

--AuthFiles changed
saasabout 112 (115 with EF Core)
identityabout 90
none6: docs and package versions

Before you deploy ​

Decide on the new settings ​

SettingDefaultWhat to do
Accounts:AskForProductNewstrueSign-up shows an unticked "Send me product news" box. Turn it off if the app won't send product news.
Accounts:RequireTwoFactorForAdminsfalseTurn on to keep the back office for admins with two-factor authentication. Admins without it are sent to Settings to set it up.
Accounts:RejectBreachedPasswordsfalseTurn 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:TwoFactorIssuerthe app's nameThe 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 a SendSecurityNotice: 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 a twoFactorTicket. Clients other than the bundled one then send the ticket and a code to POST /api/auth/two-factor for the tokens. See Sign in from a mobile or desktop app.
  • Changing the email needs the current password (UpdateProfileRequest.CurrentPassword, and TwoFactorCode with two-factor on), and deleting the account needs a code with two-factor on (DeleteAccountRequest.TwoFactorCode; Password is now optional, for accounts without one). GET /api/auth/me has hasPassword and twoFactorEnabled, so a client knows what to ask for.
  • UserManager<ApplicationUser> is now ApplicationUserManager, registered in its place. Code that asks for UserManager<ApplicationUser> gets it unchanged. If your app has its own user manager, derive it from ApplicationUserManager instead.
  • IRefreshTokenStore has ListActiveForUserAsync and RevokeSessionsAsync, and with organisations IOrganisationStore.CanWorkInAsync takes whether the user has two-factor. Add them to your own implementations.
  • Access tokens carry a sid claim (the session) and, with organisations, a tfa claim. JwtTokenService.CreateAccessToken takes them.
  • TokenIssuer can leave the Admin role out of a token when Accounts:RequireTwoFactorForAdmins is on.
  • RegisterRequest has ProductNews, and AuthOptionsResponse says whether to ask.
  • A new client dependency, uqr, draws the QR code: run npm install in src/Client.

Check it works ​

After the checks in How to upgrade:

  1. Sign in, open Settings → Two-factor authentication, set it up with an authenticator app, and save the recovery codes.
  2. Sign out and in again: you're asked for a code.
  3. Open Settings → Sessions: this device is listed.
  4. Check Mailpit (http://localhost:8025) for the "Two-factor authentication is on" email.

The full release notes list everything new.

Documentation for v0.9.0. Released under the MIT licence.