Two Factor
·
這個外掛提供的兩步驟驗證功能可以使用以時間為基礎的單次密碼 (TOTP)、通用第二因素 (U2F)、電子郵件及備份驗證碼。
評價
版本
0.15.0
活躍安裝總數
100K
最近更新:
Feb 17, 2026
The Two-Factor plugin adds an extra layer of security to your WordPress login by requiring users to provide a second form of authentication in addition to their password. This helps protect against unauthorized access even if passwords are compromised.
設定說明
Important: Each user must individually configure their two-factor authentication settings. There are no site-wide settings for this plugin.
個人使用者
- Navigate to your profile: Go to “Users” → “Your Profile” in the WordPress admin
- Find Two-Factor Options: Scroll down to the “Two-Factor Options” section
- Choose your methods: Enable one or more authentication providers (noting a site admin may have hidden one or more so what is available could vary):
- Authenticator App (TOTP) – Use apps like Google Authenticator, Authy, or 1Password
- 透過電子郵件傳送驗證碼 – Receive one-time codes via email
- FIDO U2F Security Keys – Use physical security keys (requires HTTPS)
- Backup Codes – Generate one-time backup codes for emergencies
- Dummy Method – For testing purposes only (requires WP_DEBUG)
- Configure each method: Follow the setup instructions for each enabled provider
- Set primary method: Choose which method to use as your default authentication
- Save changes: Click “Update Profile” to save your settings
網站管理員
- No global settings: This plugin operates on a per-user basis only. For more, see GH#249.
- User management: Administrators can configure 2FA for other users by editing their profiles
- Security recommendations: Encourage users to enable backup methods to prevent account lockouts
Available Authentication Methods
驗證碼產生器 App (TOTP) – 建議使用
- Security: High – Time-based one-time passwords
- Setup: Scan QR code with authenticator app
- Compatibility: Works with Google Authenticator, Authy, 1Password, and other TOTP apps
- Best for: Most users, provides excellent security with good usability
備用驗證碼 – 建議使用
- Security: Medium – One-time use codes
- Setup: Generate 10 backup codes for emergency access
- Compatibility: Works everywhere, no special hardware needed
- Best for: Emergency access when other methods are unavailable
透過電子郵件傳送驗證碼
- Security: Medium – One-time codes sent via email
- Setup: Automatic – uses your WordPress email address
- Compatibility: Works with any email-capable device
- Best for: Users who prefer email-based authentication
FIDO U2F Security Keys
- Security: High – Hardware-based authentication
- Setup: Register physical security keys (USB, NFC, or Bluetooth)
- Requirements: HTTPS connection required, compatible browser needed
- Browser Support: Chrome, Firefox, Edge (varies by key type)
- Best for: Users with security keys who want maximum security
Dummy Method
- Security: None – Always succeeds
- Setup: Only available when WP_DEBUG is enabled
- Purpose: Testing and development only
- Best for: Developers testing the plugin
Important Notes
HTTPS Requirement
- FIDO U2F Security Keys require an HTTPS connection to function
- Other methods work on both HTTP and HTTPS sites
Browser Compatibility
- FIDO U2F requires a compatible browser and may not work on all devices
- TOTP and email methods work on all devices and browsers
Account Recovery
- Always enable backup codes to prevent being locked out of your account
- If you lose access to all authentication methods, contact your site administrator
Security Best Practices
- Use multiple authentication methods when possible
- Keep backup codes in a secure location
- Regularly review and update your authentication settings
For more information about two-factor authentication in WordPress, see the WordPress Advanced Administration Security Guide.
如需進一步了解這個外掛的開發沿革,請參閱這篇文章。
動作及篩選器
以下所列為這個外掛提供的動作及篩選器勾點:
two_factor_providers篩選器:這個篩選器會覆寫如電子郵件及 TOTP 等兩步驟驗證方式。陣列值為兩步驟驗證方式的 PHP 類別名稱。two_factor_providers_for_user篩選器:這個篩選器會覆寫已為特定使用者啟用的兩步驟驗證方式。陣列值的第一個引數是驗證方式類別的執行個體,第二個引數為使用者物件WP_User。two_factor_enabled_providers_for_user篩選器:這個篩選器會覆寫已為使用者啟用的兩步驟驗證方式清單。第一個引數是已啟用的功能提供程式類別名稱值陣列,第二個引數為使用者 ID。two_factor_user_authenticated動作:這個動作會接收已登入的WP_User物件作為第一個引數,用於完成驗證工作流程後立即確定已登入的使用者。two_factor_user_api_login_enable篩選器:這個篩選器會限制 REST API 及 XML-RPC 僅能使用應用程式密碼,第二個引數為使用者 ID。two_factor_email_token_ttl篩選器:這個篩選器會覆寫電子郵件權杖產生後的使用期限 (以秒為單位)。接受第一個引數為以秒為單位的時間間隔設定後,才能驗證WP_User物件的 ID。two_factor_email_token_length篩選器:這個篩選器會覆寫電子郵件權杖預設為 8 個字元的設定。two_factor_backup_code_length篩選器:這個篩選器會覆寫備用代碼預設為 8 個字元的設定,提供與WP_User關聯的使用者作為第二個引數。two_factor_rest_api_can_edit_user篩選器:這個篩選器會使用 REST API 覆寫使用者的 Two-Factor 外掛設定。第一個引數是目前的$can_edit布林值,第二個引數為使用者 ID。two_factor_before_authentication_prompt動作:這個動作會接收提供者物件及並在驗證輸入表單顯示提示前觸發。two_factor_after_authentication_prompt動作:這個動作會接收提供者物件及並在驗證輸入表單顯示提示後觸發。two_factor_after_authentication_inputaction which receives the provider object and fires after the input shown on the authentication input form (if form contains no input, action fires immediately aftertwo_factor_after_authentication_prompt).
