No description
- PHP 98.9%
- JavaScript 0.8%
- CSS 0.3%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| assets | ||
| includes | ||
| vendor | ||
| changelog.txt | ||
| LICENSE | ||
| readme.txt | ||
| robotstxt-2fa.php | ||
| robotstxt-updater.php | ||
| uninstall.php | ||
| update.json | ||
=== 2FA (by ROBOTSTXT) === Contributors: robotstxt Tags: security, two-factor authentication, login, otp Requires at least: 6.4 Tested up to: 7.0 Requires PHP: 8.0 Stable tag: 1.6.1 License: GPLv3 or later License URI: https://www.gnu.org/licenses/gpl-3.0.html Security plugin that adds per-role two-factor authentication to the WordPress login flow. == Description == 2FA (by ROBOTSTXT) enforces two-factor authentication on the WordPress login screen. Administrators configure a per-role matrix that specifies exactly which verification methods are required for each role: email codes, authenticator apps (TOTP), or recovery codes. After the username and password are validated, the login screen redirects to a dedicated verification step. The screen hides the username and password controls, prioritises authenticator apps when enabled, and offers links to switch between methods without restarting the login. Email users can request a fresh code from the same screen. Users manage their preferences from their profile page. Every method starts unchecked until explicitly confirmed. Activating the authenticator app requires scanning the QR code and entering a valid six-digit code. Recovery codes must be saved and confirmed with one code before activation. Codes are shown in a two-column grid and automatically refresh when the batch is exhausted. Administrators can remember successful verifications for a configurable duration — per login, daily, weekly, or every 28 days — and lock the schedule so all users follow the global setting. Device and IP fingerprints are stored securely to decide when a fresh challenge is needed. Multisite is fully supported: network administrators can set and lock enforcement settings across all sites. == Installation == 1. Upload the `robotstxt-2fa` directory to `/wp-content/plugins/`. 2. Activate the plugin through the "Plugins" menu in WordPress (or network-activate it for multisite). 3. Open the **2FA** top-level menu in the dashboard and configure which methods are required per role. 4. Users can set up their preferred methods from their profile page. == Frequently Asked Questions == = Is this plugin production ready? = Yes. Email codes, authenticator apps with on-site QR codes, and recovery codes are all available and tested. = How do I enable the authenticator QR code? = Install the optional QR library inside this plugin directory with `composer require bacon/bacon-qr-code:^3.0`. The plugin loads the Composer autoloader automatically when present. = Can I enforce 2FA for specific roles only? = Yes. The admin settings page shows a matrix of roles × methods. Check the methods you want to require for each role. Roles with no methods checked leave the choice to the user. = What happens if a user loses all their verification methods? = An administrator can edit the user's profile and generate a fresh batch of recovery codes, or disable the role enforcement temporarily while the user regains access. = Is multisite supported? = Yes. Activate the plugin at the network level. Network administrators can set and lock enforcement settings; per-site settings are overridden when network settings exist. == Compatibility == * WordPress: 6.4 – 7.0 * PHP: 8.0 – 8.5 * MariaDB: 11.4 or newer == Changelog == = 1.6.1 = _Release date: 2026-08-14_ **Fixed** * Fatal error during editor autosaves: the `[robotstxt_2fa_profile]` shortcode expanded when WordPress applied content filters to a post revision via REST (for example, an article that merely mentions the shortcode in its text). In that context the wp-admin render helpers are not loaded, causing a fatal error. The shortcode now bails out early on REST requests and loads the required wp-admin includes on demand elsewhere. = 1.6.0 = _Release date: 2026-08-07_ **Added** * REST API for administrators (namespace `robotstxt-2fa/v1`, all endpoints require `manage_options`): * `GET /wp-json/robotstxt-2fa/v1/settings` — read the full 2FA configuration. * `PUT /wp-json/robotstxt-2fa/v1/settings` — update the configuration (reuses the same validation as the admin settings form). * `GET /wp-json/robotstxt-2fa/v1/users?role=<slug>&status=<enabled|required|disabled>` — list every user with their 2FA status: enabled, configured methods, role-required methods, forced flag, frequency, preferred method, whether OTP is set up, and unused recovery code count. No secrets are exposed. **Changed** * `wp 2fa list` now shows separate **Enabled**, **Methods** (configured), and **Required** (role-enforced) columns, plus a new `--required` filter to list only users whose role enforces 2FA. = 1.5.3 = _Release date: 2026-08-07_ **Added** * Per-user preferred sign-in method — a new "Preferred method" dropdown on the user profile (visible when two or more methods are enabled) lets each user choose which verification method is requested first at the login screen. Users can still switch methods on the login screen via the existing alternate-method links. **Changed** * Role enforcement is now a floor, not a ceiling. When a role requires specific methods, those methods are still forced on the user's profile (enforced setup), but at login users may authenticate with any method they have configured — not only the role-required ones. Previously, users who configured extra methods (e.g. an authenticator app) only saw the role-required method at login. **Fixed** * Security: the "Require 2FA to create Application Passwords" check could be bypassed via the `/wp/v2/users/me/application-passwords` REST route. The route matcher now accepts the `me` alias. = Previous versions = For the full changelog see the [changelog.txt](https://git.robotstxt.es/ROBOTSTXT/robotstxt-2fa/raw/branch/main/changelog.txt) file. == Compliance == This plugin adheres to the following security measures and review protocols for each version: * [WordPress Plugin Handbook](https://developer.wordpress.org/plugins/) * [WordPress Plugin Security](https://developer.wordpress.org/plugins/wordpress-org/plugin-security/) * [WordPress APIs Security](https://developer.wordpress.org/apis/security/) * [WordPress Coding Standards](https://github.com/WordPress/WordPress-Coding-Standards) * [Plugin Check (PCP)](https://wordpress.org/plugins/plugin-check/)