You should only consider customizing Adaptive MFA if your users are enrolled in MFA and are required to use an email as an identifier.
If your users are not enrolled in , you should use the default policy for Adaptive MFA. If a user is not enrolled in MFA and your Action assesses a high risk, you have limited options to stop a .Before you begin to customize Adaptive MFA, ask yourself a few questions:
At what confidence level do you want to trigger MFA?
How do you want to measure risk?
Do you want Auth0 to measure confidence or do you want a custom measurement?
How will you handle users who are not enrolled in MFA?
Adaptive MFA calculates an overall confidence score based on the analysis of three assessments. Each assessment has its own confidence score. To learn more, read Adaptive MFA.
If you want to implement your own method for evaluating the overall confidence score of different scenarios, you can use the data available in the riskAssessment object.Read the examples below to learn how Adaptive MFA would score the confidence of different use cases.
Each assessment includes a confidence score, a code that describes the evaluation result, and additional contextual information.
In the unlikely case of an assessment back-end system failure, the assessment code will be assessment_not_available and the associated confidence will be low because Auth0 defaults to a secure behavior. You can override this scoring using Actions. To learn more, read Safely handle when Auth0 fails to execute assessors.
The NewDevice assessment code property equals one of the following values:
Value
Description
match
The property values of the details object are equivalent.
partial_match
The property values of the details object are similar.
no_match
The property values of the details object are different.
initial_login
The user logged in for the first time on the device.
unknown_device
Auth0 was unable to attain metadata for the device.
no_device_history
There is no login history associated with the device.
assessment_not_available
Auth0 could not perform an assessment of the device.
NewDevice assessment details object
If the code property value equals match, partial_match, or no_match, the NewDevice assessment contains the details object with the following properties:
The ImpossibleTravel assessment determines if the user is logging in from a location that would indicate impossible travel and contains the following properties:
The UntrustedIP assessment determines if the user’s IP address is present in Auth0’s repository of low-reputation IP addresses (“deny list”) and contains the following properties:
The UntrustedIP assessment details object category property describes the general reason why Adaptive MFA considers a given IP address untrusted and equals one of the following values:
Value
Description
abuse
IP address exhibited abusive behaviors or was found to be member of bot nets.
anonymizer
IP address belongs to anonymizing services such as VPN providers, open proxies, and TOR exit nodes.
datacenter
IP address belongs to cloud hosting providers and colocation datacenters.
reputation
IP address has a poor reputation score based on activity.
unroutable
IP address is not in any range allocated or delegated by any authorized Internet registry or allowed for public use.
Actions that trigger MFA take precedence over default Adaptive MFA behavior.
If any of your Actions trigger MFA based on confidence score, the default Adaptive MFA policy triggers MFA when the confidence score is low.The following table shows the possible outcomes based on the combination of Actions and default Adaptive MFA policy actions.
This template provides an example and starting point for how to build a custom business flow using individual risk assessments.
Copy
Ask AI
/*** Handler that will be called during the execution of a PostLogin flow.** @param {Event} event - Details about the user and the context in which they are logging in.* @param {PostLoginAPI} api - Interface whose methods can be used to change the behavior of the login.*/exports.onExecutePostLogin = async (event, api) => { if (event.authentication && event.authentication.riskAssessment && event.authentication.riskAssessment.assessments.NewDevice) { // Example condition: prompt MFA only based on the NewDevice // confidence level, this will prompt for MFA when a user is logging in // from an unknown device. let shouldPromptMfa; switch (event.authentication.riskAssessment.assessments.NewDevice.confidence) { case 'low': case 'medium': shouldPromptMfa = true; break; case 'high': shouldPromptMfa = false; break; case 'neutral': // When this assessor has no useful information about the confidence, // do not prompt MFA. shouldPromptMfa = false; break; } // It only makes sense to prompt for MFA when the user has at least one // enrolled MFA factor. const canPromptMfa = event.user.multifactor && event.user.multifactor.length > 0; if (shouldPromptMfa && canPromptMfa) { api.multifactor.enable('any', { allowRememberBrowser: true }); } }};
This template demonstrates how you could enforce MFA enrollment when using a standard or Adaptive MFA policy. It uses event.user.multifactor to check if the user is enrolled in MFA, and if they’re not, prompts for enrollment.
Copy
Ask AI
/*** Handler that will be called during the execution of a PostLogin flow.** @param {Event} event - Details about the user and the context in which they are logging in.* @param {PostLoginAPI} api - Interface whose methods can be used to change the behavior of the login.*/exports.onExecutePostLogin = async (event, api) => { if (!event.user.multifactor || event.user.multifactor.length == 0) { api.multifactor.enable('any', { allowRememberBrowser: true }); }};
Perform an action if confidence score is above or below X
Confidence scores are discrete values—not in a range—so you cannot use comparison operators (such as < or >) to evaluate multiple values in a single condition.Use multiple conditions to logically combine all the confidence scores you want to handle. For example, if you want to know when the confidence score is greater than low, check if it’s equal to medium or high:
Get additional details if overall confidence score is X
The riskAssessment object is saved in your tenant logs. You can view log entries to see the risk assessment score and the determining factors (reasons).You can view the riskAssessment object and report the results elsewhere. For example, you can send an email or save a record in an external database.
Aggregate assessments for a custom overall confidence score.
Use the assessments object to access the details for individual assessments, and then use the confidence property, the code property, or both.To learn more about custom confidence scoring, read Custom confidence scoring.
Block current transaction and return error and message if a specific assessment has a specific result
Use the assessments object to access the details for individual assessments, including the code property.Block the login transaction from completing by returning the callback function with an UnauthorizedError object as the error parameter. The UnauthorizedError object always sets error to unauthorized, but you can customize the error_message:
Safely handle when Auth0 fails to execute assessments
Auth0 automatically assigns a low confidence score if there is any sort of failure performing the risk assessment.To mitigate this scenario, use the assessments object to inspect the code property for each individual assessment and check if the value is set to assessment_not_available.