Question About Implementing Custom MFA Settings Page in Auth0

Hi all,
I’m trying to implement a custom MFA settings page and have encountered some logical challenges that I’d appreciate guidance on.

Background

Our application uses Auth0’s passwordless authentication for user login (via the @auth0/auth0-react library’s loginWithRedirect and Universal Login). Now I want to add a custom page where users can enroll and manage their MFA methods.

The Challenge

According to the Auth0 documentation, enrolling MFA requires first obtaining an MFA token, then using that token to call the /mfa/associate endpoint.

The standard method for obtaining an MFA token is through the Resource Owner Password Flow (ROPG), which involves calling the /oauth/token endpoint with a username and password. However, since we’re using passwordless login, we can’t use this approach to get an MFA token.

Solution I’ve Tried

I’ve attempted to obtain an MFA token using:

loginWithRedirect({
  authorizationParams: {
    audience: "https://AUTH0_DOMAIN/mfa/",
    scope: "read:authenticators remove:authenticators enroll",
  }
})

And then using:

getAccessTokenSilently({
  audience: "https://AUTH0_DOMAIN/mfa/",
  scope: "read:authenticators remove:authenticators enroll",
})

The Issue

When I call the loginWithRedirect method above, Auth0 automatically forces the user to complete the MFA registration flow. This contradicts my intention because:

  • I originally wanted users to select and enroll MFA methods through our custom interface

  • I need to first obtain an MFA token, then call the /mfa/associate endpoint to enroll MFA

  1. But during the process of obtaining the MFA token, the user is already forced to complete MFA enrollment flow

My Questions

  • When using passwordless authentication, is there another way to obtain an MFA token without forcing users to immediately complete MFA setup?

  • Is there a better approach to implement a custom MFA settings page that allows users to choose when and which method to add for MFA?

I look forward to your suggestions and guidance. Thank you!

Hi @kevinzhao,

Thanks for your question.

According to this documentation it mentions that when https://AUTH0_DOMAIN/mfa/ is specified as the audience, MFA is enforced. This means that completing MFA is unavoidable.

I would add that the user can still select and enroll in whichever MFA methods you have configured on the Universal Login by clicking the Try another method option.

As for a custom MFA interface to allow your users to accomplish the same behavior, the user must complete the required MFA prompt to get an MFA access token to call any endpoints in the MFA API.

There is an option to use a post-login action to first redirect your users to a custom page to let them decide whether to skip or proceed with MFA. After the authentication resumes, you can save their preference from their selection and enforce or skip MFA.

There is the api.authentication.challengeWithAny(factors) method in a post-login action to prompt users with an MFA picker to select their preferred MFA method on the Universal Login.

This way, you can continue to leverage the Universal Login UI for the MFA picker.

Let me know if you have any questions about this.

Thanks,
Rueben

Thanks for your response. This is very helpful.

1 Like

Hi @kevinzhao,

Of course! I’m glad that this was helpful.

If you have any questions or need help with its implementation, let us know.

Cheers,
Rueben