cloudmazing / filament-force-2fa
Force 2FA using a middleware
Requires
- php: ^8.1
- cloudmazing/filament-2fa: ^0.3.0
- illuminate/contracts: ^9.0|^10.0|^11.0
- spatie/laravel-package-tools: ^1.13.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^6.0
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^7.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
README
Usage
The package exposes a middleware that forces the user to have 2FA enabled. If the user don't, they are redirected to the filament 2FA settings page (based on webbingbrasil/filament-2fa).
You can add the middleware to a middleware group (such as filament's auth
group in config/filament.php
which will always affect logged-in users).
/* |-------------------------------------------------------------------------- | Middleware |-------------------------------------------------------------------------- | | You may customise the middleware stack that Filament uses to handle | requests. | */ 'middleware' => [ 'auth' => [ // ... \CloudMazing\FilamentForce2FA\Http\Middleware\Require2FA::class, ], 'base' => [ //... ], ],
Or you can use the middleware on individual endpoints by registering in the Kernel App\Http\Kernel
:
protected $routeMiddleware = [ //... '2fa' => \CloudMazing\FilamentForce2FA\Http\Middleware\Require2FA::class, ];
Then when declaring routes:
Route::middleware('2fa')->get('/hello');
Installation
You can install the package via composer:
composer require cloudmazing/filament-force-2fa
You can publish and run the migrations with:
php artisan vendor:publish --tag="filament-force-2fa-migrations"
php artisan migrate
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.