Skip to content

WH-CloudMazing/filament-force-2fa

Repository files navigation

Force 2FA using a middleware

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

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.