How to setup Role based 2FA for Drupal

How to setup Role based 2FA for Drupal

Configure Two factor authentication for only a specific set of Roles. With the Role Based 2FA feature, you can enable 2FA for only a select few roles, and allow the rest to login using just their credentials. This can come in handy when you have to force authenticate the site admin accounts - who have complete access of the website - while logging in to prevent unwanted access in case of leaked credentials. And should you face any issues with the module or need any assistance in configuring the module, just drop us an email at, and we'll help you out.

Features and Pricing

Know more about Drupal 2FA module from here.

Pre-requisites: Download

You can download the Drupal Two-Factor Authentication ( 2FA ) module from here.

1. Install miniOrange 2FA module

    1.1. Using Composer:

    • For Windows:
      composer require drupal/miniorange_2fa
    • For Linux:
      composer require 'drupal/miniorange_2fa'
    • Go to Drupal site and run the update script using this URL
    • Navigate to the Extend -> Search for miniOrange Second Factor Authentication -> Select the module -> Click on the Install button.
    • You can configure the module at

    1.2. Using Drush:

    • Download the module:
      drush dl miniorange_2fa
    • Install the module:
      drush en miniorange_2fa
    • Clear the cache:
       drush cr
    • Configure the module at

    1.3. Manual installation:

    • Navigate to Extend menu on your Drupal admin console and click on Install new module.
    • Install the Drupal Two Factor Authentication - 2FA / Passwordless Login module either by downloading the zip or from the URL of the package (tar/zip).
    • Click on Enable newly added modules.
    • Enable this module by checking the checkbox and click on Install button.
    • Configure the module at

2. Setup Role based 2FA

  • Register/Login with miniOrange.
  • Drupal 2FA registration
  • Navigate to Login Settings tab.
  • Under the 2FA MODULE SETTINGS make sure you have enabled the Enable Two-Factor module and Invoke Inline Registration to setup 2nd factor for users checkbox.
  • Drupal 2FA login settings
  • Under the same tab (Login Settings) Scroll down to the ROLE BASED 2FA section and enable the role based 2FA option then you can choose a specific roles for which you want to enable two factor authentication.
  • Click on the Save Settings button.
  • Drupal 2FA enable Rolebased 2fa
  • Now, open a new browser/private window and go to your Drupal site login page.
  • Login as the User, who has the particular Role assigned to him, for which you have enabled Role Based 2FA.
  • Drupal 2FA login
  • Enter the OTP and click on the Verify button.
  • Drupal 2FA enter OTP
  • You have successfully logged in to your Drupal site using the Role based 2FA feature.

24*7 Active Support

If you face any issues or if you have any questions, please feel free to reach out to us at In case you want some additional features to be included in the module, please get in touch with us, and we can get that custom-made for you. Also, If you want, we can also schedule an online meeting to help you configure the Drupal Two Factor Authentication - 2FA / Passwordless Login module.

Free Trial

If you would like to test out the module to ensure your business use case is fulfilled, we do provide a 7-day trial. Please drop us an email at requesting a trial. You can create an account with us using this link.

Our Other modules

Hello there!

Need Help? We are right here!

Contact miniOrange Support

Thanks for your inquiry.

If you dont hear from us within 24 hours, please feel free to send a follow up email to