danielgelling / twofactor
此插件为wp-admin登录提供双因素认证接口
Requires
- php: 5.5.*
- illuminate/database: 5.2.7
- messagebird/php-rest-api: 1.4.x
- nesbot/carbon: ~1.14
This package is not auto-updated.
Last update: 2021-02-05 22:53:18 UTC
README
TwoFactorAuth 是一个Wordpress插件,将为您的Wordpress安装添加额外的安全层。当有人尝试登录Wordpress Admin时,它将通过MessageBird API发送短信。
安装
通过composer
使用 composer 安装 TwoFactorAuth 插件非常简单。您可以在 https://getcomposer.org.cn/ 获取composer。
composer require danielgelling/twofactor:^1.0
通过Github
通过Github安装TwoFactorAuth插件可以通过将仓库克隆到 wp-content/plugins
目录或从仓库页面下载zip文件来完成。
$ cd /path/to/project/wp-content/plugins
$ git clone https://github.com/danielgelling/twofactorauth.git --branch noob --single-branch twofactorauth
或者将zip格式的插件文件解压缩到插件目录中。
配置
开启功能
首先,我们需要将插件配置文件添加到wp-config.php中。我们可以通过添加以下内容来实现
/*
|--------------------------------------------------------------------------
| Two Factor Authentication Configuration
|--------------------------------------------------------------------------
|
| Here we require the configuration file for the twofactorauth plugin.
|
*/
require_once dirname(__FILE__) . '/wp-content/plugins/twofactorauth/config.php';
然后,我们需要通过在shell中执行以下命令来复制示例配置文件(假设我们在wp-content/plugins/twofactorauth目录中)
$ cp config.example.php config.php
完成此操作后,我们可以添加我们的MessageBird API密钥,我们希望用户通过短信进行身份验证的天数(即auth_code的有效期)我们这样做是以天为单位,以及我们想要用于存储我们的auth_codes的数据库表
define('MESSAGEBIRD_API_KEY', 'live_S0m3Rand0MapiKeY');
define('TWO_FACTOR_EXPIRES_IN', 30);
define('TWO_FACTOR_AUTH_TABLE', 'two_factor_logins');
然后,我们需要定义短信发送者和短信内容
define('CODE_TEXT_MESSAGE_SENDER', 'Your company\'s name');
define('CODE_TEXT_MESSAGE_CONTENT', 'Your code is: ');
最后但同样重要的是,我们需要定义我们的无效代码错误消息
define('CODE_INVALID_MESSAGE', 'Invalid code');
define(
'CODE_INVALID_MESSAGE_DESCRIPTION',
'You provided an invalid authentication code.'
);
激活插件
最后一步是在wp-admin中激活插件。这将是我们最后一次在不进行双因素认证的情况下登录,至少在您指定的提示新认证的天数内。
所以,我们现在需要做的就是点击激活,我们的Wordpress Admin就更加安全了。太棒了!