Auth014 min readtutorialintermediate
Preventing Destructive Actions with Step-up Authentication
Summary
A step‑by‑step tutorial showing how to protect a high‑impact admin action (resetting all scores) in a Next.js app with Auth0 by combining role checks and a fresh MFA step‑up flow, including helper utilities, session claim preservation, and a hardened API endpoint.
- Roles alone don’t guarantee the user is actively authorising a destructive action; a fresh MFA challenge is required.
- Auth0 step‑up can be triggered via `acr_values` and optionally `max_age=0` to force re‑authentication.
- The Next.js SDK filters out MFA‑related claims by default; a `beforeSessionSaved` hook must re‑inject `amr`, `auth_time`, `iat`, `acr`, and any custom step‑up claim.
- Utility `hasFreshMfaStepUp` checks multiple signals (`amr`, `acr`, custom claim) and validates freshness against a 5‑minute window.
Without step‑up, a stolen or stale admin session could trigger a destructive operation. The pattern demonstrates a practical, reusable way to enforce real‑time identity verification for any high‑risk action.
6/10




