# MFA OTP for Specific Applications

**URL:** <https://community.auth0.com/t/mfa-otp-for-specific-applications/146655>\
**Category:** Get Help\
**Tags:** one-time-password-otp-factor, mfa\
**Created:** [September 12, 2024, 9:04pm UTC](https://community.auth0.com/t/mfa-otp-for-specific-applications/146655 "2024-09-12T21:04:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![emurphy](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/emurphy/32/60386_2.png) [@emurphy](https://community.auth0.com/u/emurphy)\
**Post date:** [September 12, 2024, 9:04pm UTC](https://community.auth0.com/t/mfa-otp-for-specific-applications/146655/1 "2024-09-12T21:04:16Z")

</div>

Ready to post? 🔍 First, try searching for your answer.  
I have 2 Applications in my Staging Tenant. I need to enforce MFA for only one of the applications.

In the Panel, I have:  
Require Multi-factor Auth set == Never  
Enable Adaptive MFA Risk Assessment == On  
Show Multi-factor Authentication options == On  
Customize MFA Factors using Actions == On

I receive this error from the non-mfa-app post login:  
_Something Went Wrong_  
_Two-factor authentication is required to access this application. To enable this, please contact your system administrator._

Here is my custom Login Action:

```auto
exports.onExecutePostLogin = async (event, api) => {
  // immediately bust out if non-mfa-app - we do not require MFA for this app
  if (event.client.name == "non-mfa-app"){
    return;
  }

  const promptConfidences = ['low', 'medium'];

  const confidenceDevice =
      event.authentication?.riskAssessment?.assessments?.NewDevice?.confidence;
  const confidenceIP =
      event.authentication?.riskAssessment?.assessments?.UntrustedIP?.confidence;
  const confidenceTravel =
      event.authentication?.riskAssessment?.assessments?.ImpossibleTravel?.confidence;
      
  const shouldPromptMfa =
      confidenceDevice && promptConfidences.includes(confidenceDevice) 
      || confidenceIP && promptConfidences.includes(confidenceIP)
      || confidenceTravel && promptConfidences.includes(confidenceTravel);

  const canPromptMfa =
      event.user.multifactor && event.user.multifactor.length > 0;
  
  if (shouldPromptMfa && canPromptMfa) {
      api.multifactor.enable('any', { allowRememberBrowser: true });
      api.authentication.enrollWith({ type: 'otp'});
  }
};

```

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [September 12, 2024, 11:08pm UTC](https://community.auth0.com/t/mfa-otp-for-specific-applications/146655/3 "2024-09-12T23:08:15Z")

</div>

Hi @emurphy,

Welcome to the Auth0 Community!

I recommend referring to our [Two-factor authentication is required to access this application](https://community.auth0.com/t/two-factor-authentication-is-required-to-access-this-application/107643) knowledge solution to resolve this issue.

Let me know if you have any questions.

Cheers,  
Rueben

---

<div class="post-metadata">

**Author:** ![emurphy](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/emurphy/32/60386_2.png) [@emurphy](https://community.auth0.com/u/emurphy)\
**Post date:** [September 13, 2024, 5:24pm UTC](https://community.auth0.com/t/mfa-otp-for-specific-applications/146655/4 "2024-09-13T17:24:41Z")

</div>

Thanks, that worked. A follow up question.

What are the confidence levels and risk assessments for the Adaptive MFA setting if enabled via the panel? In other words, is my custom Action above a match to what Auth0 has set under the hood for Adaptive MFA Risk Assessment?

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [September 17, 2024, 8:05pm UTC](https://community.auth0.com/t/mfa-otp-for-specific-applications/146655/5 "2024-09-17T20:05:46Z")

</div>

Hi @emurphy,

Thanks for the reply and I’m glad it worked!

As for the confidence scores and risk assessments, I suggest reading the [Adaptive MFA](https://auth0.com/docs/secure/multi-factor-authentication/adaptive-mfa#how-it-works) documentation.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [October 1, 2024, 8:06pm UTC](https://community.auth0.com/t/mfa-otp-for-specific-applications/146655/6 "2024-10-01T20:06:19Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
