Auth0’s MFA enrollment doesn’t just add a second factor; it fundamentally changes the trust model of your application by requiring a verified identity before a second factor can even be requested.

Here’s how it looks in practice. Imagine a user trying to log in:

  1. Initial Authentication: The user submits their username and password. Auth0 verifies these credentials against your user database.
  2. MFA Challenge Trigger: If MFA is enforced for this user and they haven’t completed enrollment, Auth0 initiates the enrollment flow instead of a standard login.
  3. Enrollment Prompt: The user is presented with options to set up their second factor (e.g., authenticator app, SMS, push notification).
  4. Factor Verification: The user completes the enrollment process by verifying their chosen factor (e.g., scanning a QR code, entering a code sent via SMS).
  5. Enrollment Completion: Once verified, the user’s second factor is registered with their Auth0 profile.
  6. Post-Enrollment Login: The user is now logged into the application. On their next login, they’ll be prompted for their second factor after their password.

This flow is managed by Auth0’s "Security Policies" and specifically, the "MFA Enrollment" requirement. When you set this up, you’re not just saying "ask for a second factor"; you’re telling Auth0 to gate the entire authentication process until a second factor is successfully registered for the user.

The core problem this solves is weak initial authentication. A stolen password is still a significant risk, but with MFA enrollment enforced, that stolen password only gets the attacker to the enrollment step, not direct access. They can’t use a compromised password to log in unless they also have the user’s second factor device.

Let’s dive into the configuration. You’ll find this under Security > Policies > Create Policy.

  • Name: Give it a descriptive name, like "MFA Enrollment Required".

  • Description: Briefly explain its purpose.

  • Rules: This is where the magic happens. You’ll add a rule that checks for MFA enrollment status.

    A common rule looks something like this (using Node.js syntax within Auth0’s Rules editor):

    function (user, context, callback) {
      // If the user is already verified for MFA, skip this rule.
      if (user.mfa_enrolled) {
        return callback(null, user, context);
      }
    
      // If it's a silent authentication request, don't prompt for MFA enrollment.
      if (context.request.query.prompt === 'none') {
        return callback(null, user, context);
      }
    
      // If the user is trying to log in and MFA is not enrolled,
      // redirect them to the MFA enrollment page.
      context.redirect. MfaEnrollment(context.clientID, context.request.ip);
      callback();
    }
    

    Explanation:

    • user.mfa_enrolled: This is a boolean flag on the user object that Auth0 sets when MFA is successfully enrolled.
    • context.request.query.prompt === 'none': This handles cases like silent authentication where you don’t want to interrupt the user flow with a prompt.
    • context.redirect.MfaEnrollment(): This is the crucial Auth0 function that redirects the user to the built-in MFA enrollment page, passing along necessary context like the clientID and request.ip.
  • Apply to: You can apply this policy to specific applications or all applications.

  • Users: You can also target specific groups of users or all users.

Once the policy is created, you need to associate it with your actions. This is typically done within the Actions tab for your application. You’ll select the "Login" flow and add your newly created policy to the sequence.

The most surprising truth about enforcing MFA enrollment is that it doesn’t just add a step to login; it replaces the standard login flow with an enrollment flow for un-enrolled users. This means a user who has never logged in before, or whose MFA enrollment has been revoked, will always go through the enrollment process first, even if they provide correct credentials. This is a critical security distinction: you’re not just adding a gate, you’re ensuring the user proves they have a second factor before they can ever access your application’s resources.

The next step after enforcing MFA enrollment is to consider the different MFA factors available and how to best guide your users through choosing and enrolling in the most secure one for their needs.

Want structured learning?

Take the full Auth0 course →