hxm/2fa
Composer 安装命令:
composer require hxm/2fa
包简介
A One Time Password Authentication package.
README 文档
README
A One Time Password Authentication package.
Installation
-
This package publishes a config/hxm2fa.php file. If you already have a file by that name, you must rename or remove it.
-
You can install the package via composer:
composer require hxm/2fa
-
Run the migrations:
php artisan migrate
-
You should publish the template views and the config/hxm2fa.php config file with:
php artisan vendor:publish --provider=HXM2FA\ServiceProvider
-
Default config file contents
// ... return [ 'enabled' => true, 'show_secret' => false, 'route' => [ 'prefix' => 'user' ], 'extend_layout' => 'layouts.app', 'encrypt_secret' => true, /*customer QR style*/ 'qr_code' => [ 'size' => 192, 'margin' => 0, 'background' => [ 'red' => 255, //red the red amount of the color, 0 to 255 'green' => 255, //green the green amount of the color, 0 to 255 'blue' => 255 //blue the blue amount of the color, 0 to 255 ], 'fill' => [ 'red' => 45, //red the red amount of the color, 0 to 255 'green' => 55, //green the green amount of the color, 0 to 255 'blue' => 72 //blue the blue amount of the color, 0 to 255 ], ] ];
Basic Usage
-
First, add the HXM2FA\TwoFactorAuthenticatable trait to your User model(s):
use Illuminate\Foundation\Auth\User as Authenticatable; use HXM2FA\TwoFactorAuthenticatable; class User extends Authenticatable { use TwoFactorAuthenticatable; // ... }
-
We provide a Facede with static functions that perform useful functions:
use HXM2FA\Facades\HXM2FA; // ... /*to generate Secret*/ $secret = HXM2FA::generate2FASecret(); /*to generate QrCode html*/ HXM2FA::getQrCode(string $company, string $holder, string $secret) /*to verify code*/ HXM2FA::verifyCode(string $secret, string $code) /*To get instance of \PragmaRX\Google2FA\Google2FA */ HXM2FA::getGoogle2FA(); // ...
Author
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-10-26