ipunkt / laravel-two-factor-authentication
此软件包已被废弃,不再维护。没有建议的替代软件包。
使用TOTP令牌进行双因素认证(2FA)。(RFC 6238)
1.0.0
2017-11-01 12:26 UTC
Requires
- php: >=5.6.4
- bacon/bacon-qr-code: ~1.0
- illuminate/database: ^5.3
- illuminate/http: ^5.3
- ipunkt/laravel-package-manager: ^0.2.0
- paragonie/constant_time_encoding: ~2.0
- pragmarx/google2fa: ~1.0
Requires (Dev)
- mockery/mockery: ~0.9
- phpunit/phpunit: ~5.0
This package is auto-updated.
Last update: 2023-06-23 04:01:10 UTC
README
简介
此软件包为您的laravel应用程序添加了2FA(双因素认证)。
安装
只需通过添加到composer要求来安装软件包
composer require ipunkt/laravel-two-factor-authentication
并在您的 config/app.php
中添加服务提供者
\Ipunkt\Laravel\TwoFactorAuthentication\TwoFactorAuthenticationServiceProvider::class,
添加提供者后,应运行数据库迁移
php artisan migrate
设置
用户模型特质
该软件包将一个 google2fa_secret
列添加到您的用户表中。这可能为空,但应保存由特质生成的密钥:Ipunkt\Laravel\TwoFactorAuthentication\TwoFactorSupport
必须将此特质添加到基于授权的用户模型类中。
认证控制器
Ipunkt\Laravel\TwoFactorAuthentication\AuthenticatesWith2FA
特质覆盖了 LoginController
中的 authenticated
方法。因此,请更新您的 LoginController
use App\Http\Controllers\Controller;
use Ipunkt\Laravel\TwoFactorAuthentication\AuthenticatesWith2FA;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
class LoginController extends Controller
{
use AuthenticatesUsers,
AuthenticatesWith2FA {
AuthenticatesWith2FA::authenticated insteadof AuthenticatesUsers;
}
//...
}
这样我们就可以在通过用户凭证认证后与用户交互,并显示一个TOTP字段以获取Authenticator App显示的一次性令牌。
自定义软件包内容
配置
您可以通过发布配置文件来更改配置设置
$> php artisan vendor:publish --provider="Ipunkt\Laravel\TwoFactorAuthentication\ServiceProvider" --tag=config
并编辑 /config/2fa.php
以满足您的需求。
视图
您可以通过发布视图文件来更改提供的视图
$> php artisan vendor:publish --provider="Ipunkt\Laravel\TwoFactorAuthentication\ServiceProvider" --tag=view
并在 /resources/views/vendor/2fa
中编辑视图。
迁移
您可以通过发布迁移来更改软件包中的迁移
$> php artisan vendor:publish --provider="Ipunkt\Laravel\TwoFactorAuthentication\ServiceProvider" --tag=migrations
并在 /database/migrations
中编辑迁移。
许可
双因素认证是开源软件,根据 MIT 许可证 许可。