Beginning in v7.2.2, Metric Insights supports login with 2FA: an optional, instance-wide, second authentication factor for local-password and LDAP logins. When enabled, a correct password no longer establishes a session on its own. Metric Insights generates a 6-digit code, emails it to the user's registered address, and requires the user to enter the code to complete login. A compromised or shared password is not enough on its own to access the account.
This does not affect Single Sign-on logins, where an external identity provider already controls authentication for those users. A System Admin configures Login with 2FA, and the setting applies to the whole instance.
PREREQUISITES:
- The user configuring 2FA must be a System Admin;
- All Prerequisites are met.
Table of contents :
NOTES:
- Email 2FA requires working email delivery and carries a real lockout risk if misconfigured, see Prerequisites and Verify the Setup before enabling it in production.
- See Troubleshooting if 2FA fails once on, and Recover Instance Where 2FA Locked Out Every User if it locks out every user.
- 2FA applies only to interactive browser logins. REST API and token-based authentication (PAT, Bearer tokens) are not affected.
1. Prerequisites
Because a broken configuration can lock out every password-based user, including the administrator who enables the feature, verify all of the following BEFORE setting ENABLE_EMAIL_2FA to Y:
- The Email Server card shows connected on the Status Monitor page (SMTP or Graph API).
- Metric Insights blocks the save automatically if this check fails.
- Notifications ON/OFF system-wide is ON.
- The setting controls all queued email, including 2FA codes. Treat any environment where it's OFF; e.g., dev or staging, as unsafe for 2FA.
- Every local-password and LDAP user has a current, correct email address. LDAP-synced addresses can go stale, with no bypass if one is missing or wrong.
2. Configure the 2FA System Variables
Access Admin > System > System Variables
- Enter
2FAin the search field. EMAIL_2FA_ALLOWED_ATTEMPTS: Controls how many incorrect code entries are allowed before the challenge is rejected and the user must restart from the password step.- The default is
3. Exceeding this limit also counts toward the existingFAILED_LOGIN_ALLOWED_ATTEMPTSaccount-lockout threshold.
- The default is
EMAIL_2FA_CODE_EXPIRE_SECONDS: Controls how many seconds an emailed code remains valid before it expires.- The default is
600(10 minutes), and the accepted range is 60 to 600 seconds. After a code expires, the user must restart login.
- The default is
-
ENABLE_EMAIL_2FA: Set toYto require an emailed one-time code as a second step for local-password and LDAP logins.- Set to
Nto leave the login flow unchanged for all authentication methods. Allowed values areYandN; the default isN. This is an instance-wide setting.
- Set to
- [Save] and [Commit Changes]
3. Verify the Setup
Before relying on 2FA in production, test the full login flow end-to-end with a real password or LDAP test user:
- Verify that the Prerequisites have been met and 2FA is configured.
- Open the login page and enter the test user's correct credentials.
- Confirm the code-entry step appears and a 6-digit code arrives at the user's email within the expiration window as displayed on the screenshot.
- Enter the code and confirm the start page opens.
- Log out and log back in to confirm the code is required again on every login.
4. Troubleshooting
This section covers the most common scenarios where 2FA can fail once it is already on:
- Issue 1: The mail server was fine at setup, but breaks later.
- Why it may happen: Metric Insights only checks the Email Server at setup and does not keep re-checking once 2FA is on. If the mail server goes down, is misconfigured, or codes start landing in spam, users stop receiving codes even though
ENABLE_EMAIL_2FAis stillY. - Solution: Monitor the Email Server card on the Status Monitor page on an ongoing basis, not just before enabling 2FA.
- Why it may happen: Metric Insights only checks the Email Server at setup and does not keep re-checking once 2FA is on. If the mail server goes down, is misconfigured, or codes start landing in spam, users stop receiving codes even though
- Issue 2: Email configuration changes after setup.
- Why it may happen: If SMTP/Graph API settings, credentials, or the sending domain change after 2FA is enabled, the same silent-failure risk applies. The 2FA code is queued asynchronously, so a broken mail server raises no error at login.
- Solution: Re-check the Email Server card whenever email configuration changes on a 2FA-enabled instance.
- Issue 3: A production backup is restored into a dev or staging environment.
- Why it may happen: Dev/staging instances often have email notifications disabled or an invalid mail server. A restored backup carries over
ENABLE_EMAIL_2FA=Y, so every password-based login is blocked immediately. - Solution: Check
ENABLE_EMAIL_2FAand Email Server connectivity as a standard step after any backup restore.
- Why it may happen: Dev/staging instances often have email notifications disabled or an invalid mail server. A restored backup carries over
Recover Instance Where 2FA Locked Out Every User
If 2FA is enabled and no password-based user can complete login because codes aren't arriving, the variable has to be reset via SSH to the application server:
- Access the
webcontainer:sudo mi-web - Access the
web/backenddirectory and reset the 2FA System Variable:cd web/backend && php artisan system:reset2fa - Restart the Apache service to apply the changes:
service apache2 restart