reyesoft / filament-2fa
filament的2FA插件。
1.0.0
2024-07-29 14:32 UTC
Requires
- php: ^8.0
- ext-json: *
- bacon/bacon-qr-code: ^2.0
- filament/filament: ^3.2.0
- pragmarx/google2fa: ^7.0|^8.0
- spatie/laravel-package-tools: ^1.9.2
Requires (Dev)
- filament/upgrade: ^3.2.0
This package is auto-updated.
Last update: 2024-09-25 13:13:28 UTC
README
Filament的二次验证插件
安装
- 通过composer安装此包(需要filament >= 2.10.40)
composer require webbingbrasil/filament-2fa
- 发布资源并运行迁移
php artisan vendor:publish --tag="filament-2fa-migrations"
php artisan migrate
可选,您还可以发布配置或视图
php artisan vendor:publish --tag="filament-2fa-config" php artisan vendor:publish --tag="filament-2fa-views"
-
将
\Webbingbrasil\FilamentTwoFactor\TwoFactorAuthenticatable
特质添加到您的用户模型中。 -
更新
config/filament.php
以指向TwoFactorLogin::class。
"auth" => [ "guard" => env("FILAMENT_AUTH_GUARD", "web"), "pages" => [ "login" => \Webbingbrasil\FilamentTwoFactor\Http\Livewire\Auth\Login::class, ], ],
与自定义个人资料页面集成
此包包含一个用于设置两步验证的组件,可以轻松添加到个人资料页面,如filament-jetstream-theme中的页面。
创建一个带有<livewire:filament-two-factor-form>
组件的视图,如下例所示
// resources/views/partials/2fa-section.blade.php <hr /> <x-filament-jetstream::grid-section class="mt-8"> <x-slot name="title"> {{ __('filament-2fa::two-factor.title') }} </x-slot> <x-slot name="description"> {{ __('filament-2fa::two-factor.description') }} </x-slot> <div class="space-y-3"> <x-filament::card> <livewire:filament-two-factor-form> </x-filament::card> </div> </x-filament-jetstream::grid-section>
然后使用渲染钩子将视图添加到您的个人资料页面
## in Service Provider file public function boot() { Filament::registerRenderHook( 'filament-jetstream.profile-page.end', fn (): View => view('partials.2fa-section'), ); }
截图
致谢
许可协议
MIT许可(MIT)。请参阅许可文件获取更多信息。