Is it possible to bypass rules for certain grant types?

I am using cypress to programmatically login to auth0. It seems to get almost to the end but one of the existing rules for mfa is failing since cypress does not use mfa. I get the error Cannot read property ‘methods’ of undefined.

Is there a way to bypass mfa when using the grant_type http://auth0.com/oauth/grant-type/password-realm?

Hi @dchoi ,

Welcome to the Auth0 Community!

I noticed that you have submitted a Support Ticket and working with a Developer Support Engineer on this query. Once the support ticket is resolved, I will post the summary on this topic as the solution.

1 Like

Below is the solution mentioned in the support ticket.

To allow mfa authentication to take precedence over the email whitelist.

function requireMfaOncePerSession(user, context, callback) {
const emailWhitelist = [ // emails ]
const completedMfa = context.authentication.methods && !!context.authentication.methods.find(
(method) => method.name === 'mfa'
);
if (completedMfa || emailWhitelist.includes(user.email)) {
return callback(null, user, context);
}
// rest of code
2 Likes