Skip to content
Get started
Bastionary › Knowledge base › Identity fundamentals

Step-up authentication with OIDC acr and amr claims

By Bastionary · Identity fundamentals

A user logs into your app in the morning with a password and a one-time code. Seven hours later, from the same session, they click "delete organization" or "add a new payout bank account." Should that single morning login be enough to authorize an irreversible, high-value action at four in the afternoon? For most products the honest answer is no — but the common implementation treats every request from an authenticated session identically, because the session either exists or it does not.

Step-up authentication breaks that binary. It lets a sensitive operation demand a higher assurance level or a fresher authentication than the ambient session provides, and if the session does not meet the bar, the user re-authenticates — stepping up — before the action proceeds. OpenID Connect gives you the vocabulary to do this precisely with three pieces: acr_values on the request, the acr and amr claims on the result, and max_age for freshness.

acr: how strong was this authentication

The Authentication Context Class Reference (acr) claim is a string the identity provider returns describing the assurance level of the authentication that produced the token. A client requests a minimum level with the acr_values parameter, space-separated in order of preference.

GET /authorize?response_type=code
  &client_id=app-7f2
  &redirect_uri=https://app.example.com/callback
  &scope=openid
  &acr_values=urn:example:acr:mfa
  &claims={"id_token":{"acr":{"essential":true,"values":["urn:example:acr:mfa"]}}}
  HTTP/1.1
Host: auth.example.com

The values are opaque identifiers you define — there is no universal registry of levels, which is a feature: you model assurance the way your product needs. A common scheme is a small ladder.

  • urn:example:acr:pwd — a single factor, a password.
  • urn:example:acr:mfa — password plus a second factor.
  • urn:example:acr:phr — phishing-resistant, e.g. a passkey or hardware security key.
Do not invent your own string when a standard one exists for your meaning. NIST-aligned deployments use registered AAL values and phishing-resistant designators rather than ad-hoc URNs. The risk of a private scheme is that two services in your fleet interpret acr:mfa differently and a step-up gate silently accepts the wrong level. Define the ladder once, document exactly what each rung requires, and make every service read from that single definition.

amr: how exactly did they authenticate

Where acr is an assurance level, the Authentication Methods References (amr) claim is an array naming the specific methods used. RFC 8176 registers the common values.

{
  "sub": "user-4821",
  "acr": "urn:example:acr:phr",
  "amr": ["pwd", "hwk", "user"],
  "auth_time": 1776710400,
  "iss": "https://auth.example.com",
  "aud": "app-7f2"
}

Here pwd is a password, hwk a proof-of-possession hardware key, and user a user-presence check. The amr array lets a gate make fine-grained decisions — for instance, "payout changes require a phishing-resistant method" can check for hwk or a passkey designator directly, rather than trusting that your acr ladder mapped it correctly.

max_age and auth_time: how fresh is this login

Assurance level is not the only axis. A login can be strong but stale. The max_age parameter tells the IdP the maximum acceptable age, in seconds, of the user's authentication; if the existing session is older, the IdP must actively re-authenticate the user even if they have a valid session.

GET /authorize?response_type=code
  &client_id=app-7f2
  &scope=openid
  &max_age=300
  &prompt=login
  ... HTTP/1.1

The result carries an auth_time claim — the timestamp of the actual authentication event. Your gate compares now - auth_time against the freshness window the operation requires. A max_age=0 forces re-authentication unconditionally, which is appropriate for the most sensitive confirmations.

Keep assurance and freshness as separate requirements. "This action needs MFA" (level) and "this action needs an authentication within the last five minutes" (freshness) are different questions. A seven-hour-old MFA login satisfies the first and fails the second. Model both explicitly per operation instead of collapsing them, or you will either annoy users with needless re-auth or let a stale strong login authorize a sensitive change.

Implementing the gate

The pattern is: define per-operation requirements, check the token against them at the point of action, and redirect to the authorization endpoint with the right parameters when the bar is not met.

type Requirement = { acr: string; maxAgeSec: number };

const RULES: Record<string, Requirement> = {
  'org:delete':      { acr: 'urn:example:acr:phr', maxAgeSec: 120 },
  'payout:add':      { acr: 'urn:example:acr:mfa', maxAgeSec: 300 },
  'profile:update':  { acr: 'urn:example:acr:pwd', maxAgeSec: 86400 },
};

function needsStepUp(claims: TokenClaims, action: string): boolean {
  const rule = RULES[action];
  if (!rule) return false;
  const levelOk = rankOf(claims.acr) >= rankOf(rule.acr);
  const ageSec = Math.floor(Date.now() / 1000) - claims.auth_time;
  const freshOk = ageSec <= rule.maxAgeSec;
  return !(levelOk && freshOk);
}

// If needsStepUp -> redirect to /authorize with acr_values + max_age,
// then re-check the returned id_token before performing the action.

Verify the result, do not just request it

The subtle bug: a client requests acr_values=urn:example:acr:mfa and then proceeds as if MFA happened. But acr_values is a request, and in OIDC it is voluntary unless marked essential — an IdP may return a lower level. Always read the acr and auth_time on the returned token and confirm they actually satisfy your rule before authorizing the action. Trusting the request parameter instead of the response claim is how step-up gates get quietly bypassed.

Designing the ladder

A few principles keep step-up from becoming either security theater or a usability disaster:

  • Reserve step-up for genuinely sensitive, hard-to-reverse actions — money movement, security settings, destructive operations, granting access to others. Prompting for everything trains users to click through.
  • Prefer freshness over re-collecting factors where you can. Re-proving presence with an already-registered passkey is a one-tap step-up; forcing a full re-login is not.
  • Make the requirement visible in the UI before the action, so the re-auth prompt is expected rather than jarring.
  • Log the acr, amr, and auth_time that authorized each sensitive action. When you later need to prove an action was properly authenticated, that record is the evidence.

The throughline

Step-up authentication is really the recognition that assurance is not a property of a session but of a moment — the moment an action is taken. Modeling it with acr, amr, and max_age turns "are they logged in?" into "is this specific action authorized to this standard right now?", which is the question that actually matters for the operations that can hurt.

Defining the assurance ladder, mapping methods to levels, and enforcing freshness windows are all decisions about how your identity provider behaves — and they are far easier to get consistent across every service when that provider is one you run, with a single ladder definition your whole fleet reads, rather than a hosted set of levels you have to bend your product around.

Run it yourself

Bastionary is free, open-source software. Follow the quick start to have it running on your own server, or browse the releases on Git.

Get started