post-login
Actions, you can customize your flows to challenge users with a specific factor or sequence of factors. You can also use contextual information about users and their organizations to create more individualized experiences. For example, you can customize your flows to challenge users with specific factors based on their membership in certain Organizations or their assigned user roles.
post-login
trigger of the Login Flow with the following Authentication API methods:
challengeWith
: Specifies the factor or factors users must use to authenticate, such as a one-time password (OTP). This method presents a default challenge to users and can optionally provide access to a factor picker that allows them to choose a different authentication method.
challengeWithAny
: Sets a group of factors users can choose from when authenticating, such as email and OTP. By default, this method presents a factor picker to users rather than a specific challenge, in accordance with the following conditions:
enrolledFactors
value. enrolledFactors
represents the list of active factors associated with a user’s account.
otp
email
push-notification
otpFallback
phone
preferredMethod: voice
preferredMethod: sms
preferredMethod: both
webauthn-platform
webauthn-roaming
event.authentication.methods
includes a type
field when the name of the method is set to mfa
. type is a string that contains factor values matching those used by the type
field from enrolledFactors
(listed above). When an MFA challenge is performed, methods
contains an object of name:mfa
with type
set to the factor used for that challenge. methods
is only updated when an Action begins. To see the results of a challenge, methods
must be accessed in the next Action in the flow.
To learn more, review the following resources:
challengeWith
or challengeWithAny
commands, you can use contextual information to determine the best challenge or series of challenges to present to users. Specifically, you can leverage the following:
challengeWithAny
command in Action 1. Then, Action 2 challenges the user with a push notification because they have the Admin user role and also completed the SMS challenge.
In this flow, you can make decisions about which factor to challenge the user with due to the following:
event.authentication.methods.type
in Action 2 populates with information from the previous MFA challenge.challengeWith
and challengeWithAny
offer the following unique benefits:
challengeWith
or challengeWithAny
commands is executed. With redirects, MFA runs as the final Action in the pipeline.challengeWith
or challengeWithAny
commands. Actions serving other purposes are not affected.
challengeWith
and challengeWithAny
commands override any challenges enabled viaapi.multifactor.enable. They also take precedence over the MFA settings available under Define Policies.post-login
Actions code.post-login
Action commands.
After a user signs up or is created in your tenant, you can create enrollments with the authentication-methods endpoint, or you can manage users’ enrollments directly through their profile pages in the Auth0 Dashboard.
post-login
Actions to customize your MFA flows. Steps and example use cases are provided below.
enrollWith
enrollWithAny
challengeWith
challengeWithAny
onPostExecute
command. Add your custom code or code sample to the command.
sendUserTo
) command must be in a separate Action from your MFA commands.additionalFactors
parameter in your Actions code. You can set this parameter to a specific factor for all users or use enrolledFactors
to let users choose their preferred factor.
Specific Factor
The following sample challenges users with OTP by default. If desired, users can access the Try Another Method link to authenticate with email instead.
post-login
trigger of theLogin Flow. This example uses the phone
method of authentication and preferredMethod: 'both'
, referring to the active MFA factors associated with a user’s account. For more information, refer to Actions Triggers: post-login - Event Object.
Scenario | Event Code | Descriptive Error |
---|---|---|
A user is prompted with multi-factor authentication, but none of the requested factors can be used as a challenge. In this case, the user cannot complete MFA. | mfar | This scenario results in the following error message: An MFA challenge is used in a PostLogin action but the requested factors are not properly set up. To perform MFA, enable the requested factors and ensure the user is enrolled with them. |
A user is prompted with multi-factor authentication, but one of the requested factors cannot be used as a challenge. In this case, the user can complete MFA using a different requested factor. | w | This scenario results in the following warning message: An MFA challenge is used in a PostLogin action, but the requested factor {factor name} is not properly set up. Enable the requested factor and ensure the user is enrolled with it. |
post-login
Actions.
post-login
Actions for deployment when using the Deploy CLI. For more information, review Configure the Deploy CLI.