Overview

Last updated on
25 November 2026

Two-factor login

  • TOTP (RFC 6238) second factor on the standard Drupal login form. Works with any authenticator app, such as Google Authenticator, Microsoft Authenticator, Authy or 1Password.
  • Secure login flow: after the correct password, the Drupal session is not created until a valid code is entered. The pending login is tracked on the server, not in a cookie.
  • REST / JSON login support: /user/login?_format=json requires an mfa_token for accounts with 2FA enabled. Core's credential checks and flood control still apply unchanged.
  • Limit on wrong codes: 10 failed codes per account within 15 minutes blocks further attempts and shows a "try again in N minutes" message. REST login returns HTTP 429 with a Retry-After header.

API authentication (Basic Auth, OAuth, JSON:API)

  • Password-only providers are blocked for 2FA accounts: providers that check only a password on each request, such as core's HTTP Basic Authentication, never show the code step. For an account with 2FA enabled, or one that must still set it up while 2FA is required, any request not made with the account's own session is refused with HTTP 403. This includes every JSON:API route.

  • Trusted token providers: a token-based provider whose tokens are only issued after a full login can be allowed in settings.php:

    $settings['auth_login_plus_allowed_auth_providers'] = ['oauth2'];

    cookie and basic_auth are ignored in this list. Do not allow a provider that issues tokens for a password alone, such as an OAuth "password" grant.

Setting up 2FA

  • QR code setup: the QR code is generated on your own server as an inline SVG, so no third-party API is called.
  • Manual entry fallback: shows the issuer, account name and secret key, with a copy-to-clipboard button.
  • Confirmation step: the user enters a code from their app to confirm setup before 2FA is turned on.
  • Other sessions are ended: when 2FA is turned on for an account (first setup or re-enabling), the account's other sessions are logged out, because they were opened without a second factor. The current session stays logged in.
  • Move to a new phone: Set up a new authenticator keeps the old authenticator working until the new one is confirmed.

Recovery

  • One-time backup codes (1–20, configurable): shown only once at setup. Only a hash of each code is stored.
  • Self-service reset by email: a Lost access to your authenticator? link sends a single-use, time-limited reset link to the user's email address.
  • Drush command: drush auth-login-plus:reset <uid> resets a user from the command line.

Making 2FA required

  • Optional enforcement: logged-in users without 2FA are redirected to the setup page until they set it up.
  • Configurable redirect message and message type (status, warning or error).
  • Bypass permission for accounts that should not be forced to set up 2FA, such as service accounts.
  • While 2FA is required, users cannot turn it off themselves.
  • Administrators are not forced: admin roles, and user 1 while security.enable_super_user is on, automatically have the bypass permission. They are still asked for a code once they have enabled 2FA, so make sure every administrator sets it up.

Administration

  • Admin overview page (People » Two-factor authentication): shows every user's 2FA status and when it last changed, with a username filter.
  • Reset, Disable and Enable actions for each user, each with a confirmation step.
  • Separate support permission: Manage user 2FA lets helpdesk staff manage users' 2FA without being given Administer site configuration or Administer users.

Configuration

  • Global on/off switch.
  • Code length (6–8 digits), validity period (15–120 seconds) and clock drift tolerance.
  • Safe to change later: code length and validity period are stored with each enrollment. Changing them only affects new enrollments; users who already set up 2FA keep the values their app was set up with.
  • Custom issuer name, or the site name by default.
  • Users can be allowed to turn 2FA on or off themselves. Changing it requires a current code.
  • Where to send the user after a correct code.
  • Settings are translatable through Configuration Translation.

Security

  • Secrets encrypted at rest with AES-256-GCM, using a key from settings.php. If no key is set, an auto-generated key is used and the Status report shows a warning.
  • Reset links are single-use, time-limited and stored hashed.
  • Pages that send email or use up a token are never cached.

Theming

  • Card-style design for the setup, login challenge and status pages, which can be turned off to use your theme's plain form styling.
  • Twig templates you can override: auth-login-plus-setup-page.html.twig and auth-login-plus-reset-email.html.twig.
  • The auth_login_plus/setup-page library can be replaced with your own CSS.

Compatibility

  • Drupal 10, 11 and 12, on PHP 8.3 or later.
  • No other contributed modules needed. The PHP libraries it needs are installed by Composer.
  • Replaces the alogin module, and can be installed alongside them while you migrate.

Help improve this page

Page status: No known problems

You can: