webbingbrasil/filament-2fa

filament的2FA插件

v1.0.0 2023-03-20 18:11 UTC

This package is auto-updated.

Last update: 2024-09-20 21:30:08 UTC


README

为Filament提供双因素认证插件

安装

  1. 通过composer安装此包(需要filament >= 2.10.40)
composer require webbingbrasil/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. 将`\Webbingbrasil\FilamentTwoFactor\TwoFactorAuthenticatable`特质添加到您的用户模型中。

  2. 更新`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'),
    );
}

截图

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

致谢

许可

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