tfsthiagobr98/filament-2fa

filament 的双因素认证插件。

2.0.0 2024-03-30 00:05 UTC

This package is auto-updated.

Last update: 2024-09-30 01:12:21 UTC


README

Filament 的双因素认证插件

安装

  1. 通过 composer 安装此包(需要 filament >= 2.10.40)
composer require tfsthiagobr98/filament-2fa
  1. 发布资源和运行迁移
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"
  1. \TFSThiagoBR98\FilamentTwoFactor\TwoFactorAuthenticatable 特性添加到您的用户模型中。

  2. 更新 config/filament.php 以指向 TwoFactorLogin::class。

"auth" => [
    "guard" => env("FILAMENT_AUTH_GUARD", "web"),
    "pages" => [
        "login" =>
            \TFSThiagoBR98\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'),
    );
}

截图

Two Factor Page Confirm Password Finishing enable Recovery codes Enabled Challenge Breezy

致谢

许可协议

MIT 许可协议 (MIT)。有关更多信息,请参阅 许可文件