Multi-factor authentication
Ask for a second factor after the first: a code by e-mail, a code from an authenticator app, an approval in the Authio app or a passkey, and step up when your app needs a stronger sign-in.
In Authio, multi-factor is not a switch on the account: it comes from the sign-in steps each client asks for. Put a second-factor step after the first one and the hosted login asks for it, skipping any factor the sign-in already presented.
This page covers the four second factors, when each one is asked, the authenticator app and its recovery codes, the Authio Authenticator app that answers push approvals, what to do when a phone is lost, and how your app can ask for a stronger sign-in.
The second factors
| Factor | Step | What the person does | Recorded in amr |
|---|---|---|---|
| One-time code by e-mail | mfa | Types the 6-digit code sent to the account’s e-mail address. | otp |
| Authenticator app | totp | Types the 6-digit code from the app, or a recovery code. | otp |
| Push approval | push | Taps, in the Authio app, the number shown on the sign-in screen. | mca, plus user when the phone verified the person |
| Passkey | passkey | Unlocks a passkey with the device’s fingerprint, face or screen lock. | swk, plus user when the device verified the person |
totp step and an app code never answers the mfa step: they are separate factors, and a client can ask for both.When the second factor is asked
The client’s steps decide, in the order they are listed. The first step that can answer the factor still owed is the one shown:
| Step | Asked of |
|---|---|
mfa | Every sign-in that reaches it. The step cannot be Optional, because a code that may be skipped is no factor at all, except beside a push step that is neither Required nor requires registration: there an Optional mfa step is never asked on its own and is offered as the way past the phone. |
totp, Preferred | Accounts that set up an authenticator app. Others with no second factor yet are offered to set one up, unless enrolment is Never. |
totp, Required | Every account. The step cannot be Optional: an app code is never a way in, it only answers a stage after a password. |
push, Preferred | Accounts with a paired phone. Others with no second factor yet are offered to pair one, unless registration is Never. |
push, Required | Every account. One without a phone has to pair before continuing, so registration has to allow it. |
passkey, Preferred | Accounts that already registered a passkey. See Passkeys. |
passkey, Required | Every account. |
| Any step, Optional | Nobody, unless an authorization request asks for a higher level with acr_values (see step-up). |
A sign-in through an identity provider counts as one factor, whatever the provider did on its side, and the client’s second-factor steps apply after it. Single sign-on into another client is only offered when nothing that client requires is missing.
One-time code by e-mail
After the first factor, Authio sends a 6-digit code to the account’s e-mail address and the screen shows six digit boxes, filled by the browser’s one-time-code autofill where it is available. Didn’t get the code? Resend it sends a new one.
- The same code is delivered to every phone paired with the account, where the Authio app shows it as Your sign-in code. The code never travels in the notification itself: the app fetches it over an authenticated connection while it is valid.
- A wrong code counts toward the realm’s lockout and is recorded in the access log.
- After a correct code the account is checked again — status, suspension, access to the client, sign-in address — before the session opens.
Authenticator app
The totp step asks for the 6-digit code an authenticator app shows for the account — standard TOTP, 30 seconds, SHA1 — so Google Authenticator, Microsoft Authenticator, 1Password, Authy and the like all work. The app lists the account under the realm’s name, with the e-mail address as the label. It is not the Authio app, which approves sign-ins by push.
- Instead of the app code, the person can type one of the account’s recovery codes. Setting up the app issues 10, shown once; each one works once.
- A wrong code counts toward the realm’s lockout, as with the e-mail code.
- The session and the access log record the method as
totp. The tokens reportotpinamr, and password plus app counts asacr2.
Setting up the app
Enrolment on the step is Offer, Never or Require. An account without an app sets one up in one of these places:
- During sign-in, before the session exists, when the step is Required or enrolment is Require: the screen shows Set up an authenticator app with a QR code, and Can’t scan it? reveals the key to type by hand. The person types the code the app shows, Save your recovery codes shows them once, and I’ve saved them continues the sign-in.
- With Preferred and enrolment Offer, the setup is offered after signing in, with Continue without an authenticator app, to accounts with no second factor yet. Declining is remembered for 30 days per person and client. With Never, nobody is made to set one up during sign-in.
- From the account pages, on the Authenticator app tab. Next to a factor the account already has, confirming the app asks for proof (see Adding a factor when you already have one). See Account self-service.
- Console operators, in Security under their own settings. The console’s own client has the
totpstep, Preferred with enrolment Never, so an operator who set up an app is asked for its code at every console sign-in. An operator who already has a passkey, a phone or recovery codes also confirms with the password, a recovery code or one of their passkeys to turn the app on.
Resetting someone’s app
In Users, the Account section of a user’s page shows, under Security, whether the app is set up, started but not confirmed, or not set up, and how many recovery codes are left. Reset app, in that same section and saved from the bar, needs user:delete and discards the secret and the recovery codes; the next sign-in that asks for the app has the person set up a new one. The API offers the same at GET and DELETE /api/v1/admin/users/{userId}/mfa/totp, which @hyper.authio/admin calls as admin.userTotp.getStatus and admin.userTotp.reset. On your own page the action is Remove app instead: it acts at once and asks for proof that you hold the factor (see Removing your own factor).
Removing your own factor
Taking one of your own second factors off asks for proof that you hold one, so a session left open, or a stolen one, is not enough. That covers turning the authenticator app off, issuing new recovery codes, removing one of your passkeys and removing one of your phones, wherever you do it: Security in your settings, your own page in Users, the account pages and the API.
- A code from the authenticator app, the 6 digits it shows now.
- A recovery code not used yet. It is spent by the confirmation.
- The account’s password, when it has one.
- One of your passkeys, unlocked on the device with a fingerprint, face, PIN or screen lock: the device has to verify you. An account that signs in only with a passkey confirms with it.
In the console, the Confirm with dialog offers Passkey after the authenticator app, the recovery code and the password. It has no field: the dialog’s button asks the browser for one of your passkeys and sends the proof, and every try asks for a new challenge. Cancelling the browser’s prompt, or letting it lapse, sends nothing and does not count toward the lockout; the dialog says so under the choice. The option shows only when your account has a passkey and the browser can use it from the console (see Passkeys in the console). Without that support, the dialog says that confirming with a passkey is available on your account portal, whose pages offer Confirm with a passkey in any browser that supports passkeys. When the browser refuses the ceremony, for instance because the console’s origin is not configured, the dialog says so under the choice, stays open and suggests another way or the account portal. An account with none of the four, such as one that signs in through a provider and only has a phone, has nothing to confirm with: an administrator removes the factor for it.
The API takes the proof as { "code": "…" }, { "password": "…" } or { "passkey": { "ceremonyId": "…", "assertion": … } } in the body of POST /api/v1/admin/users/me/mfa/totp/disable and POST …/me/mfa/totp/recovery-codes, and of DELETE /api/v1/admin/users/me/passkeys/{passkeyId} and DELETE /api/v1/account/security/devices/{deviceId}. On DELETE /api/v1/admin/users/{userId}/mfa/totp, …/{userId}/passkeys/{passkeyId} and …/{userId}/authenticator-devices/{deviceId} it is asked only when userId is you. Without it the answer is SecondFactorConfirmationRequired, with data.methods listing by name, in this order, what the account can prove with among AuthenticatorApp, RecoveryCode, Password and Passkey; a wrong one is SecondFactorConfirmationInvalid and counts toward the realm’s lockout, which answers LockedOut (423) once reached. Both refusals, and the removal, enter the account’s change trail.
Proving with a passkey takes a challenge first. POST /api/v1/admin/users/me/passkeys/proof/options, with the console’s session and no body, answers { "data": { "ceremonyId": "…", "options": { … } } }, where options are WebAuthn assertion options in their JSON form, with the account’s passkeys in allowCredentials and userVerification set to required. The browser’s answer goes back as assertion, the way PublicKeyCredential.toJSON() writes it, next to the ceremonyId. The account pages ask the same of POST /realms/{realm}/clients/{client}/webauthn/proof/options, with the realm’s session, and a challenge asked on one works on the other.
{
"passkey": {
"ceremonyId": "CEREMONY_ID",
"assertion": {
"id": "CREDENTIAL_ID",
"rawId": "CREDENTIAL_ID",
"type": "public-key",
"response": {
"clientDataJSON": "…",
"authenticatorData": "…",
"signature": "…",
"userHandle": "…"
},
"clientExtensionResults": {}
}
}
}- The challenge works once, for the person who asked for it, and lapses after the ceremony time (
Passkey:ChallengeTimeoutSeconds, 120 seconds by default). Every submission spends it, right or wrong, so each try asks for a new one. - A passkey sent with a
codeor apasswordwins: only the passkey is checked, and no recovery code is spent. - A passkey that does not hold is
SecondFactorConfirmationInvalid, with the notice on thepasskeyfield: a challenge lapsed, used or asked by somebody else, a passkey of another account or removed meanwhile, a device that did not verify the person, or a signature, origin or counter that does not match. It counts toward the lockout like the other proofs. - A refusal for another reason, such as an app not in force or a phone that is not the account’s, comes before the proof and spends neither a recovery code nor the challenge.
- Asking for the options on an account without a passkey answers
NoCredentialsRegistered(400). Without a session the answer is401, and an API key or a personal access token gets403. - Removing your only passkey with that same passkey as proof is accepted when the account has a password, which still signs it in. Without a password it is refused with
LastCredentialForPasswordlessUserbefore the proof is read, and the challenge is not spent.
On Node.js, @hyper.authio/admin sends these proofs with the person’s own access token: totp.disable, totp.regenerateRecoveryCodes and passkey.removeMine take them as body, totp.enable in confirmation, and passkey.beginProof() asks for the challenge; see Prove the second factor. On .NET, IAuthioAdminClient calls none of these routes, since they act on the person signed in and refuse an account credential.
Adding a factor when you already have one
Adding a second factor to your own account next to one you already have asks for the same proof as removing one. Otherwise a stolen session could pair its own phone and approve the pushes, or register its own passkey, beside yours. Having a factor means an authenticator app in force, a recovery code, a passkey or a phone paired with the Authio app; an account with none of them adds its first with the session alone.
- Turning the authenticator app on, in Security in your settings or on the Authenticator app tab of the account pages, asks for the proof beside the code from the new app. With no app in force yet, that is in practice your password, a recovery code if one is left, or one of your passkeys: an account that signs in only with a passkey turns the app on with it. Showing the QR code and the key asks for nothing: the key alone puts nothing in force.
- Pairing a phone: on the Authio app tab of the account pages, Show the pairing code asks for the proof in the same form.
- Registering a passkey: on the Passkeys tab of the account pages, Register this device asks for it in the Confirm it is you band, shown whenever the account already has a factor; a passkey the account already has can be the proof for the new one.
The account pages leave the password field out for an account that has none, and so do the console’s dialogs, for removing as well as adding. For an account with a passkey, the account pages offer Confirm with a passkey and the console’s dialogs the Passkey option (see Removing your own factor). The API takes the proof as { "code": "…" }, { "password": "…" } or { "passkey": { "ceremonyId": "…", "assertion": … } }: under confirmation, beside the new app’s code, in POST /api/v1/admin/users/me/mfa/totp/enable; as the body of POST /api/v1/account/authenticator/enrolments, which issues a pairing code, and of POST /realms/{realm}/clients/{client}/webauthn/register/options with the realm’s session. POST …/me/mfa/totp/enrollment, which issues the key, takes none. GET /api/v1/admin/users/me/mfa/totp says beforehand whether the proof will be asked (holdsSecondFactor), whether the account has a password (hasPassword) and whether it has a passkey (hasPasskey); an administrator reads the same at GET …/{userId}/mfa/totp.
The answers are those of a removal: SecondFactorConfirmationRequired without the proof, with data.methods listing what the account can prove with, and SecondFactorConfirmationInvalid for a wrong one, which counts toward the realm’s lockout and gives way to LockedOut (423) once it is reached. When the app is turned on, the proof is checked before the new app’s code. A refusal for another reason — five phones already paired, an app already in force, a client without passkeys — comes first and spends no proof: no recovery code is used and no passkey challenge is consumed. An account that signs in only with a passkey proves with it, and so can put an authenticator app next to it. One with no password, no app, no recovery codes and no passkey that already has a phone, such as one that signs in only through a provider, has nothing to prove with: data.methods comes back empty and it does not add another factor on its own.
The sign-in asks for no extra proof when it enrols what the client requires, or what an administrator demanded for the next sign-in: that happens right after the first factor of this sign-in, before any session exists. The password was just typed; for someone who came in through a provider, a code by e-mail or a passkey, this sign-in is the proof. What the client only offers after signing in — an authenticator app, a phone or a passkey — is offered only to accounts with no second factor yet; one that already has a factor adds the next from the account pages, with the proof.
Push approval
Push approval uses the Authio Authenticator app for iOS and Android, called “the Authio app” on the sign-in screens. It defends against push fatigue — someone who has the password sending requests until the victim approves one to make the phone stop — with number matching:
The screen shows a number
After the first factor, the sign-in screen shows Tap this number in the Authio app with a two-digit number, and waits.
Every paired phone is asked
Each phone of the account receives a notification. The app shows the application, the IP address and browser of the attempt, and three numbers.
The person taps the matching number
Tapping the number is the approval. The app asks for biometrics or the screen lock when the phone has one, then signs the answer with a key created when it was paired. It wasn’t me denies the request.
The sign-in continues by itself
The screen sees the answer and carries on. Authio re-reads the approved request on the server before completing the sign-in; nothing the browser sends is taken as proof.
| Rule | Value |
|---|---|
| A request is valid for | 2 minutes |
| Numbers offered on the phone | Three distinct numbers from 10 to 99 |
| Tapping the wrong number | Denies the request, with no second try |
| Requests per account | At most 10 in 5 minutes, counted per account rather than per IP |
| Several paired phones | All are asked with the same number; the first answer decides |
| Approval | Accepted only with a valid signature from the phone’s own key |
While waiting, the screen offers Ask my phone again, which sends a new request with a new number. A notification that never arrives does not block the sign-in: the app also finds pending requests when it is opened. An mfa step on the same client that is Preferred or Required is asked on top of the phone, never in its place. One set to Optional, on a client whose push step is neither Required nor requires registration, is the way past the phone: the screen offers Use another way to sign in, which mails the code, and the code answers in place of the phone. Without it, or when the client demands the phone, a sign-in that reached the push step is completed on the phone.
Pairing a phone
Pairing is always started by the account holder. There are two places to do it:
- During sign-in, when the
pushstep offers or requires registration: the screen shows Set up your phone with a QR code to scan in the app, and Can’t scan it? reveals the same content as a line to paste. With registration Offer, the screen comes only to accounts with no second factor yet, and Continue without a phone skips it. - From the account pages, on the Authio app tab, with Show the pairing code, which asks for proof first when the account already has a second factor (see Adding a factor when you already have one). See Account self-service.
A pairing code works once, for 5 minutes, and showing a new one retires the previous one. An account can have up to 5 active phones.
Require a phone on the next sign-in
An administrator cannot pair a phone for somebody else, but can make the person’s next sign-in pair one. In Users, open the person and, in the Authenticator devices band of the Credentials section, switch on Require a phone on next sign-in, then save from the bar (user:update).
- On a client of the person’s realm whose
pushstep has registration Offer, the sign-in shows Set up your phone without Continue without a phone, and goes on only once the phone is paired. - A client without the
pushstep, or whose registration is Never, signs the person in as configured, and the demand waits for a client that offers the step or for the person to pair from the Authio app tab of the account pages. - The demand withdraws itself once a phone is paired, and demanding a phone of somebody who already has one paired is refused.
- The same demand is read and written through the API, together with the passkey one: see Require a passkey on the next sign-in.
Lost phone or no access to the factor
- With an authenticator app, the person types a recovery code on the
totpstep. With none left, an administrator resets the app and the next sign-in has them set up a new one. - When a passkey is owed and is not on the device, the screen offers to send a code by e-mail instead. See Passkeys.
- The person removes a lost phone from the Authio app tab of the account pages, confirming with a code from the authenticator app, a recovery code, the password or one of their passkeys (see Removing your own factor), or from another paired phone. A removed phone stops approving anything at once.
- An administrator revokes it in the Authenticator devices band of the Credentials section of the user’s page in Users, or from Push Authenticator. With no phone left, a
pushstep that is Preferred no longer asks for one and offers to pair a new phone, unless its registration is Never; one that is Required has the person pair a new phone before going on. To make sure the new phone is paired, require it on the next sign-in.
Phones are revoked, never deleted, so the history of what each one approved stays readable. Using a revoked phone again means pairing it again.
Step-up from your app
The ID token says how the person signed in: amr lists the methods, acr sums them up as a level, and auth_time says when. A single sign-on reports the original sign-in, never a fresh one.
acr | Meaning | Example |
|---|---|---|
1 | One factor | A password; a sign-in through Google |
2 | More than one factor | Password and e-mail code; password and authenticator app; Google and a push approval |
3 | Multi-factor where one factor resists phishing | A passkey verified by the device, alone or after a password |
When an action needs more than the current session proves, send the person through the authorization endpoint again with what you need. createAuthorizationUrl in @hyper.authio/client takes it as acrValues, maxAge and prompt, and AuthioAuthorizationRequest in Authio.Client as AcrValues, MaxAge and Prompt:
acr_values=2oracr_values=3asks for a level. When the client’s own steps would not reach it, one Optional second-factor step the account can answer is asked as if it were Preferred.max_age=300asks for a sign-in no older than five minutes.prompt=loginasks for the credentials again whatever the session.
// authio: the createAuthioClient of your sign-in, with checks: ['pkce', 'state']
const { url, transaction } = await authio.createAuthorizationUrl({
redirectUri: 'http://localhost:3000/api/auth/callback/authio',
scopes: ['openid', 'profile', 'email'],
acrValues: '2',
maxAge: 300,
})
// Or straight from an API's 401 with insufficient_user_authentication:
const stepUp = await authio.createStepUpAuthorizationUrl(response.headers.get('www-authenticate')!)acr_values never refuses a sign-in
On an API, requireAuthenticationLevel in @hyper.authio/express and RequireAuthioAuthenticationLevel in Authio.AspNetCore make that check: they read acr and auth_time and answer 401 with insufficient_user_authentication, acr_values and max_age (RFC 9470), the challenge createStepUpAuthorizationUrl and CreateStepUpAuthorizationAsync turn into the next request. In a web app, handleAuthorizationCallback and HandleCallbackAsync already refuse an ID token whose auth_time is older than the maxAge asked for; compare idToken.acr (IdToken.AuthenticationLevel on .NET) with the level the action needs.
import { requireAuthenticationLevel } from '@hyper.authio/express'
// Two factors, and a sign-in at most five minutes old.
app.post('/api/payouts', requireAuthenticationLevel(2, { maxAge: 300 }), payout)Watching push approval
Push Authenticator in the console shows, for a realm or all of them, every request sent to a phone and how it ended — approved, denied, unanswered or never delivered — with response times, the most active applications and the paired phones, including revoked ones and phones that cannot be notified. Requests that never reached a phone are highlighted, because neither the person nor the administrator would notice otherwise.