elsayed85 / nova-two-factor
Nova 双因素认证
dev-main
2022-10-08 18:49 UTC
Requires
- php: >=7.1.0
- bacon/bacon-qr-code: ^2.0
- pragmarx/google2fa-laravel: ^2.0
This package is not auto-updated.
Last update: 2024-09-23 02:12:06 UTC
README
Nova-Two-Factor
Laravel Nova 控制台 2FA 安全功能
版本
使用 v2.0.0 用于 Laravel Nova 4
使用 ^v1.0.0 用于 Laravel Nova 3
\\ Nova 4
composer require visanduma/nova-two-factor:~2
\\ Nova 3
composer require visanduma/nova-two-factor:~1
查看
设置 2FA
启用/禁用功能
带有 2FA 安全性的 Nova 登录屏幕
- 发布配置 & 迁移
php artisan vendor:publish --provider="Visanduma\NovaTwoFactor\ToolServiceProvider"
根据您的需求更改配置
return [
// enable or disale 2FA feature. default is enabled
'enabled' => env('NOVA_TWO_FA_ENABLE',true),
// name of authenticatable entity table. usually - users
'user_table' => 'users',
// Entity primary key
'user_id_column' => 'id',
// authenticatable model class
'user_model' => \App\Models\User::class
];
- 在配置的模型中使用 ProtectWith2FA 特性
<?php
namespace App\Models;
use Visanduma\NovaTwoFactor\ProtectWith2FA;
class User extends Authenticatable{
use ProtectWith2FA;
}
- 将 TwoFa 中间件添加到 nova 配置文件
/*
|--------------------------------------------------------------------------
| Nova Route Middleware
|--------------------------------------------------------------------------
|
| These middleware will be assigned to every Nova route, giving you the
| chance to add your own middleware to this stack or override any of
| the existing middleware. Or, you can just stick with this stack.
|
*/
'middleware' => [
...
\Visanduma\NovaTwoFactor\Http\Middleware\TwoFa::class
],
- 在 Nova 服务提供者中注册 NovaTwoFactor 工具
<?php
class NovaServiceProvider extends NovaApplicationServiceProvider{
public function tools()
{
return [
...
new \Visanduma\NovaTwoFactor\NovaTwoFactor()
];
}
}
- 运行
php artisan migrate
- 完成!