For AI agents: the complete documentation index is available at https://dotpress.dev/llms.txt, the full documentation bundle is available at https://dotpress.dev/llms-full.txt, and this page is available as Markdown at https://dotpress.dev/auth/step-up.md.

Step-up

A sensitive action asks a recent authentication (requireRecentAuth(), 403 REAUTHENTICATION_REQUIRED) or a recent second factor (requireMfa({ maxAge }), 403 MFA_REQUIRED). The step-up authenticates the current session again, without a new login. It needs the sessions store and mfa.

RouteBodyAnswer
POST /auth/step-up/send{ factorId? }{ challengeToken, factorId, expiresAt }: a code sent by email or SMS. 5 per 15 minutes per user (rateLimits.mfa.sendCode), and a code by SMS 3 per hour per phone number (rateLimits.mfa.phoneNumber).
POST /auth/step-up/passkey/options—{ challengeToken, expiresAt, options }: a challenge for a passkey of the user, with passkeys
POST /auth/step-up{ method, password?, code?, response?, factorId?, challengeToken?, mode? }A new token pair, reauthenticatedAt, mfaVerifiedAt?

method is password, totp, email, sms, recovery_code or passkey. A code by email or SMS comes with the challengeToken of /auth/step-up/send, sent back with the code: see Codes by email or SMS. A passkey comes with the challengeToken of POST /auth/step-up/passkey/options and the response of the browser: see Passkeys. A wrong password answers 401 INVALID_PASSWORD, a wrong code 400 INVALID_CODE: 10 failures per 15 minutes per user (rateLimits.stepUp.user, and rateLimits.mfa.verify for the second factors), then 429 TOO_MANY_REQUESTS. Both also count 30 attempts per 15 minutes, atomically: a TOTP or recovery code has no challenge of its own, and the failures are written after the check, so of parallel guesses 30 at most are checked.

The step-up routes refuse impersonation sessions (403 IMPERSONATION_FORBIDDEN): the staff member does not hold the credentials of the user. With mode: 'cookie', POST /auth/step-up from an untrusted origin answers 403 CROSS_ORIGIN_REQUEST.

The session records reauthenticatedAt, and mfaVerifiedAt for a second factor. The answer holds a new token pair of the same session, whose amr adds the method (pwd, otp, email, sms, hwk or swk for a passkey) and mfa for a second factor: an API that checks the tokens without the sessions store sees it. A passkey adds mfa when the authenticator verified the user, or in a session not opened by a passkey. auth_time stays the start of the session. In cookie mode (mode: 'cookie'), the pair replaces the cookies. The previous refresh token keeps working, with its amr.

// A route that needs a second factor of less than 5 minutes.
app.defineRoute({
  method: 'delete',
  path: '/account',
  middlewares: [requireAuth, requireMfa({ maxAge: '5m' })],
  handler: async ({ auth }) => { /* … */ },
})

The app answers 403 MFA_REQUIRED by a step-up, then retries with the new access token.

auth.stepUp.send({ session }) and auth.stepUp.verify({ session, method, … }) do the same outside the routes; session is ctx.auth.