reyesoft / filament-2fa
A 2FA plugin for filament.
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-11-25 13:32:59 UTC
README
A Two Factor Authentication plugin for Filament
Installation
- Install the package via composer (requires filament >= 2.10.40)
composer require webbingbrasil/filament-2fa
- Publish assets and run migrations
php artisan vendor:publish --tag="filament-2fa-migrations"
php artisan migrate
Optionally, you can publish config or views:
php artisan vendor:publish --tag="filament-2fa-config" php artisan vendor:publish --tag="filament-2fa-views"
-
Add
\Webbingbrasil\FilamentTwoFactor\TwoFactorAuthenticatable
trait to your user model. -
Update the
config/filament.php
to point to the Two Factor Login::class.
"auth" => [ "guard" => env("FILAMENT_AUTH_GUARD", "web"), "pages" => [ "login" => \Webbingbrasil\FilamentTwoFactor\Http\Livewire\Auth\Login::class, ], ],
Integrate With Custom Profile Page
This package has a component for two-factor setup that can be easily added to a profile page, like the one for filament-jetstream-theme.
Create a view with the <livewire:filament-two-factor-form>
component like the example below:
// 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>
Then add the view to your profile page using render hook:
## in Service Provider file public function boot() { Filament::registerRenderHook( 'filament-jetstream.profile-page.end', fn (): View => view('partials.2fa-section'), ); }
Screenshots
Credits
License
The MIT License (MIT). Please see License File for more information.