Uncomplicated 2FA for WordPress with e-mail OTP and authenticator app support.
This plugin provides uncomplicated 2FA functionality for WordPress. It will allow you to require a second, one time password or OTP, code to be entered when certain (or all) users attempt to log in to WordPress.
It supports two factor methods:
- six-digit codes sent by e-mail
- standards-based authenticator apps using TOTP
The e-mail code has a limited lifetime (defaults to 15 minutes). Once a code has been consumed, it is considered invalid.
Authenticator app setup is handled from the user's own profile page. The plugin provides a QR code, a manual setup key, and recovery codes for when the authenticator app is not available.
You may configure that only certain roles are required to use 2FA, and it is recommended that you enable 2FA for those users with privileged access.
You may also configure the plugin to allow certain roles to enable an OTP code bypass, which sets an account-specific cookie in that user's web browser. Several users can share a browser while keeping separate trust settings. Trusted-browser tokens expire on the server and are invalidated when the account password changes.
You can add custom text to the OTP code entry form, and you can add custom text to the OTP code e-mail message. OTP e-mails include HTML and plain-text versions with the same code, verification reference, expiry information, and custom text.
The plugin can be configured to allow it to be handled/managed only by specific users, thus making it harder for someone to accidentally or intentionally deactivate it. The implemented solution for this is by no means waterproof. If someone, for example, has access to your WordPress installation by means of FTP or similar, the plugin files can be physically removed (or moved out of your WordPress installation), which basically deactivates the plugin as well.
E-mail codes use the verification reference shown on the login screen. New messages are limited to one per account per minute until 2FA succeeds. Successful verification clears the mail cooldown. Existing codes keep their original expiry time when switching factors.
Existing settings, enrolled authenticator apps, recovery codes and valid trusted browsers from 2.0.2 carry over. Start sign-in again if a verification form was open during the upgrade. Refresh any open login or settings forms before submitting them.
If you use Cloudbridge Mattermost with required local verification, upgrade Cloudbridge 2FA first, then upgrade Cloudbridge Mattermost to a version that supports API 2. In Cloudbridge Mattermost, select and save the required local verification policy, then test sign-in. If your site uses a custom login policy adapter, review and preserve any restrictions it enforces before removing it.
This section describes how to install the plugin and get it working.
- Install from the WordPress Plugins screen, or extract the
cloudbridge-2fafolder into/wp-content/plugins/. - Activate the plugin through the 'Plugins' menu in WordPress
- Configure the plugin settings
Cloudbridge 2FA uses standard WordPress functionality to handle localization/locale. The native language localization of the plugin is English. It has been translated to Swedish by the author.
Use the WordPress login page or a standard form generated by wp_login_form()
for protected password logins. Custom sign-on handlers and XML-RPC password
logins cannot complete interactive 2FA. WordPress handles REST application
passwords separately. OAuth plugins can integrate by registering an API 2
provider. The capability method cb2fa_external_login_api_version() returns 2.
- Finish WordPress authentication checks before opening a 2FA challenge, and finish the remaining checks before creating a login session.
- Support standard WordPress login forms, including reauthentication and the Customizer, with verification that survives permitted session changes.
- Add external login API 2 so OAuth providers can hand off to the same 2FA and session flow as password logins.
- Stop unavailable, expired or consumed verification requests and offer a link to start sign-in again.
- Preserve the attempt count and original expiry if an e-mail factor switch fails while another verification request is in progress.
- Fixed overlapping login attempts invalidating e-mail codes; each attempt now has a separate browser-bound challenge
- Fixed e-mail cooldown renewal after expiry and cleared the cooldown after successful 2FA
- Added PHP log diagnostics for e-mail cooldown, storage, and sending failures
- Added a plain-text alternative to HTML OTP e-mails
- Fixed large OTP digits overflowing narrow e-mail layouts
- Preserved delivered e-mail codes when switching factors and added matching verification references
- Enforced fixed challenge expiry, resend limits, and server-side trusted-browser expiry
- Prevented concurrent OTP/recovery-code reuse and rejected verification when state cannot be saved
- Ran factor handling after normal WordPress and third-party authentication checks
- Preserved WordPress Remember me, corrected recovery-code case handling, and hardened login input handling
- Fixed uninstall cleanup, restricted-browser storage handling, and Swedish plural translations
- Removed credential and sensitive option-value debug logging
- Handled malformed import entries without PHP warnings and limited configuration import diagnostics
- Made existing verification endpoint access guards detectable by Plugin Check without changing login behavior
- Fixed a settings-page regression where saving one tab could unset values on another tab
- Fixed the Bypass 2FA tab layout after the recent admin UI changes
- Restored returning to the active settings tab after saving
- Sent expired or stale login verification attempts back to the WordPress login screen so the user can start over cleanly
- Verified with PHP 7.4, 8.1, 8.2, 8.3, and 8.4
- Added authenticator app support using standards-based TOTP
- Added recovery codes for authenticator-enabled accounts
- Added QR code and manual setup key support to the user profile
- Reworked the admin settings so authenticator-app and e-mail OTP settings are easier to find
- Hardened redirect handling in login and OTP completion flows
- Added CSRF protection to configuration import
- Verified with WordPress 6.8 and 6.9
- Verified with WordPress 6.7
- Verified with Plugin Check (PCP)
- Corrected some checks for
uninstall.phpand made it more WP-CLI compatible
- Fix some incorrect links in plugin and
README.md
- Fix of minor PHP warning
- Fix of minor PHP warning
- Initial release
Please see LICENSE for a full copy of GPLv2
Copyright (C) 2024-2026 Joaquim Homrighausen.
This file is part of Cloudbridge 2FA (CB2FA). Cloudbridge 2FA is free software.
You may redistribute it and/or modify it under the terms of the GNU General Public License version 2, as published by the Free Software Foundation.
Cloudbridge 2FA is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with the Cloudbridge 2FA package. If not, write to:
The Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor
Boston, MA 02110-1301, USA.
The Cloudbridge 2FA Plugin was written by Joaquim Homrighausen while converting β into code.
Cloudbridge 2FA is sponsored by WebbPlatsen i Sverige AB πΈπͺ
Commercial support and customizations for this plugin is available from WebbPlatsen i Sverige AB in πΈπͺ
If you find this plugin useful, the author is happy to receive a donation, good review, or just a kind word.
If there is something you feel to be missing from this plugin, or if you have found a problem with the code or a feature, please do not hesitate to reach out to support@webbplatsen.se.
This plugin can also be downloaded from code.webbplatsen.net and GitHub
More detailed documentation is available at code.webbplatsen.net/documentation/cloudbridge-2fa
These links are not here for any sort of endorsement or marketing, they're purely for informational purposes.
- me; π code.joho.se
- WebbPlatsen; webbplatsen.se and code.webbplatsen.net
- Kudos to Kev Quirk for Simple CSS
- QR code setup on the authenticated profile page uses QR Code Generator for JavaScript by Kazuhiko Arase (MIT license)
Stay safe!