Sample Use Cases - Rules with Passwordless Authentication

With rules, you can handle more complicated cases than is possible with passwordless connections alone. For instance, you can add extra precautions to further ensure possession of an email address or device.

Require Multi-factor Authentication for users who are outside the corporate network

Let's say you want to require multi-factor authentication (MFA) for any users who are accessing the application using a passwordless connection from outside your corporate network.

Using a rule, you can check whether a user is authenticating using a passwordless method (sms, email) and if their session IP falls outside of the designated corporate network, prompt them for a second authentication factor.

To do this, you would create the following rule:

function(user, context, callback) {
  const ipaddr = require('ipaddr.js');
  const corp_network = "";
  const current_ip = ipaddr.parse(context.request.ip);
  // is auth method passwordless and IP outside corp network?
  const passwordlessOutside = context.authentication.methods.find(
    (method) => (
      (( === 'sms') || ( === 'email')) && 

  // if yes, then require MFA
  if (passwordlessOutside) {
    context.multifactor = {
      provider: 'any',
      allowRememberBrowser: false
  callback(null, user, context);

Was this helpful?