---
url: /saas-starter/v0.10.1/releases/v0.8.0.md
---
# 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 a `twoFactorTicket`,
  for accounts with two-factor authentication on. Clients other than the bundled one send the
  ticket and a code to the new `POST /api/auth/two-factor` for tokens. Google and GitHub sign-in
  sends the browser to `/external-login#twoFactorTicket=...` in that case.
* **`AdminUser` has `TwoFactorEnabled`**, and `ManageUserEndpoints` has
  `POST /api/admin/users/{id}/turn-off-two-factor`.
* **Marten's `ApplicationUser` has `AuthenticatorKey` and `RecoveryCodes`**, and
  `ApplicationUserStore` implements Identity's two-factor stores. With EF Core, Identity keeps
  them in `AspNetUserTokens`, which already exists: no migration.
* **`TokenIssuer` can leave the Admin role out** of an access token, when
  `Accounts:RequireTwoFactorForAdmins` is 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 a `SendSecurityNotice`. Code that calls
  them directly reads the result from the tuple.
* **Two EF Core migrations:** `AddSessions` (session ID, start and User-Agent on `RefreshTokens`)
  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 `sid` claim** (the session), and with organisations a `tfa` claim (the
  account has two-factor). `JwtTokenService.CreateAccessToken` takes them.
* **`IRefreshTokenStore` has two more methods** (`ListActiveForUserAsync`, `RevokeSessionsAsync`),
  and `IOrganisationStore.CanWorkInAsync` takes whether the user has two-factor. Custom
  implementations add them.
* **`OrganisationMember`, `UserOrganisation` and `CurrentOrganisation`** have a two-factor field
  each.
* **Changing the email needs the password, and deleting the account a code too, with two-factor
  on:** `UpdateProfileRequest` has `CurrentPassword` and `TwoFactorCode` (used only when the email
  changes), and `DeleteAccountRequest` has `TwoFactorCode`; its `Password` is now optional, for
  accounts without one. Wrong answers count towards the lockout. Clients other than the bundled
  one send them; `GET /api/auth/me` has `hasPassword` and `twoFactorEnabled` to 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 a `known_device` cookie (HttpOnly, path `/api/auth`).
* **`RegisterRequest` has `ProductNews`,** and `AuthOptionsResponse` has `ProductNews` (whether to
  ask). `Accounts:AskForProductNews` is on by default: turn it off if the app doesn't send product
  news.
* **`UserManager<ApplicationUser>` is now `ApplicationUserManager`** (`Identity/ApplicationUserManager.cs`),
  which emails when an account is locked or a recovery code is used. Code that asks for
  `UserManager<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; `/admin` sends 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`.
