Overview
This article explains how to prevent a select group of users from being required to use Multifactor Authentication (MFA) using Actions.
Applies To
- Multifactor Authentication (MFA)
- Actions
Cause
Solution
The following action can prompt all users without a role to be exempt from MFA.
exports.onExecutePostLogin = async (event, api) => {
if (!event.authorization.roles.includes('bypass_mfa')) {
api.multifactor.enable("any");
} else return
};
Another way to achieve this is to set a flag on the app_metadata of the user and then check if that flag is present or not inside the action that triggers MFA.