Skip to content

Fresh sessions

For: a developer who decides which changes of an account need a new proof.

What it does: this page explains the fresh rule, the re-authentication, and the changes that core guards.

A session is fresh while its sign-in or its last re-authentication is younger than session.freshMinutes. The default is 1440 minutes, one day, as in Better Auth. A thief who copies a session token gets a stale session after that time. The thief then cannot lock the owner out.

A re-authentication proves the person again with the password, an email code, or a passkey. With the second factor on, the password and the email code need the factor code too. A passkey proves two factors, so it needs no factor code. The re-authentication keeps the session token and the expiry. It does not extend the absolute lifetime of a session.

Change Why
The change of address, a link, an unlink Each changes a way to sign in or to recover the account
A passkey register and delete, a first password Each adds or removes a way in
A password change while the second factor is on The current password alone is one factor
The second factor on and off, and new backup codes ASVS 5.0.0 7.5.1 asks for a full re-authentication
An API token create A token is a credential for its life
The revoke of one session or of the others ASVS 5.0.0 7.5.2
The account delete It cannot be undone

The session list, the identity list, and the profile update need a session only. A password change with no second factor needs no fresh session, because the current password is the proof. POST /totp/setup turns nothing on, so it has no rule. The enable after it applies the rule.

A stale session gets 403 session_not_fresh, and nothing changes. The rule answers before any limit counts a try. The client re-authenticates and sends the change again. client.withFresh does both, and it never loops.

Some in-process calls apply no fresh rule. api.tokens.create and api.passkeyRegistrationOptions take a session. api.deletePasskey, api.totp.disableWithCode, and api.totp.regenerateBackupCodesWithCode take a user. The app’s server code calls api.session.requireFresh(resolved) first. api.totp.enable and api.password.change take a session, and they apply the rule themselves.