PHPackages                             visualbuilder/filament-2fa - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. visualbuilder/filament-2fa

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

visualbuilder/filament-2fa
==========================

Two Factor Auth for filament

4.0.32(2mo ago)14.0k—9.1%[1 PRs](https://github.com/visualbuilder/filament-2fa/pulls)MITPHPPHP ^8.2CI passing

Since Oct 24Pushed 2mo ago2 watchersCompare

[ Source](https://github.com/visualbuilder/filament-2fa)[ Packagist](https://packagist.org/packages/visualbuilder/filament-2fa)[ Docs](https://github.com/visualbuilder/filament-2fa)[ GitHub Sponsors](https://github.com/Visualbuilder)[ RSS](/packages/visualbuilder-filament-2fa/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (24)Versions (66)Used By (0)

Two Factor Auth for filament
============================

[](#two-factor-auth-for-filament)

[![Latest Version on Packagist](https://camo.githubusercontent.com/7d98fb52e7972a87bfafba2417fb224add8d11a5d35fad29bf854460952aee11/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f76697375616c6275696c6465722f66696c616d656e742d3266612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/visualbuilder/filament-2fa)[![GitHub Tests Action Status](https://camo.githubusercontent.com/b1e1c7a65b764a89e406dfa793734381bc3b3ed4b11465a3385785fc62b47f9d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f76697375616c6275696c6465722f66696c616d656e742d3266612f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/visualbuilder/filament-2fa/actions?query=workflow%3Arun-tests+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/db91d3a9b409a430d35c8a36f14d04dea5314650cb70309077cd6259ba08a064/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f76697375616c6275696c6465722f66696c616d656e742d3266612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/visualbuilder/filament-2fa)

Adds Two Factor authentication to Filament Panels. Requires an app like Authy or Google Authenticator to generate Time-based One Time Pins every 60 seconds.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require visualbuilder/filament-2fa
```

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="filament-2fa-migrations"
php artisan migrate
```

A Banner Seeder adds a configurable Setup 2FA banner shown to users who are not setup yet

```
php artisan vendor:publish --tag="filament-2fa-seeders"
php artisan db:seed --class=TwoFactorBannerSeeder
```

Publish the config files

```
php artisan vendor:publish --tag="filament-2fa-config"
```

This package extends the

so you will see two new config files:-

```
config/two-factor.php
config/filament-2fa.php
```

Review the config files
-----------------------

[](#review-the-config-files)

Set preferences for safe devices and recovery codes.

```
    'safe_devices' => [
        'enabled' => true,
        'cookie' => '_2fa_remember',
        'max_devices' => 3,
        'expiration_days' => 14,
    ],
```

Note the Two-Factor Login Helper is not used, there is a custom login form which you can extend

Optionally, you can publish the views using

```
php artisan vendor:publish --tag="filament-2fa-views"
```

Usage
-----

[](#usage)

Minimal configuration required to enable 2FA on a panel.

### Step 1:

[](#step-1)

Implement TwoFactorAuthenticatables on the authenticatable model

```
use Visualbuilder\Filament2fa\Contracts\TwoFactorAuthenticatable;
use Visualbuilder\Filament2fa\Traits\TwoFactorAuthentication;

class Admin extends Authenticatable implements FilamentUser, TwoFactorAuthenticatable
{
    use HasFactory, TwoFactorAuthentication;
}
```

### Step 2:

[](#step-2)

Add TwoFactor Plugin on PanelServiceProvider

```
public function panel(Panel $panel): Panel
{
    return $panel
        ->default()
        ->id('admin')
        ->plugins([
            TwoFactorPlugin::make()
        ])
}
```

### Step 3:

[](#step-3)

Add menu items where required. For all users *Setup Two Factor Authentication* link For Admins only *Banner Manager pages*

```
use Visualbuilder\Filament2fa\Filament\Pages\Login;

public function panel(Panel $panel): Panel
{
    return $panel
        ->default()
        ->id('admin')
        ->plugins([
            TwoFactorPlugin::make()
        ])
        ->login(Login::class)
        ->userMenuItems([
        /**
        * 2FA setup and manage link
        */
        MenuItem::make('two-factor')
                    ->url('/two-factor-authentication')
                    ->label('Two Factor Auth')
                    ->icon('heroicon-o-key')
                    ->sort(1),

         /**
         * Banner manager
         * Ensure you limit access to who can change banners
         */
        MenuItem::make('two-factor-banner')
            ->url(config('filament-2fa.banner.navigation.url'))
            ->label(config('filament-2fa.banner.navigation.label'))
            ->icon(config('filament-2fa.banner.navigation.icon'))
            ->sort(2)
            ->visible(fn() => Filament::auth()->user()->hasRole(['Developer', 'Super Admin'],'web'))
```

### Step 4:

[](#step-4)

Can enable or disable TwoFactor in filament-2fa.php config file

```
use Filament\Pages\SubNavigationPosition;
return [
    'defaultDateTimeDisplayFormat'  => 'd M Y H:i',

    'excluded_routes' => [
        'two-factor-authentication',
        'confirm-2fa',
        'logout',
    ],

    'login' => [
        'flashLoginCredentials' => false,
        'credential_key' => '_2fa_login',
        'confirm_totp_page_url' => 'confirm-2fa'
    ],

    'navigation' => [
        'visible_on_navbar' => true,
        'icon' => 'heroicon-o-key',
        'group' => 'Auth Security',
        'label' => 'Two Factor Auth',
        'cluster' => null,
        'sort_no' => 10,
        'subnav_position' => SubNavigationPosition::Top
    ],

    'auth_guards' => [
        'web' => [
            'enabled' => 'true',
            'mandatory' => false
        ]
    ],

    'banner' => [
        'auth_guards' => [
            'web' => [
                'can_manage' => true,
                'can_see_banner' => true,
            ]
        ],
        'navigation' => [
            'icon' => 'heroicon-m-megaphone',
            'label' => '2FA Banners',
            'url' => 'banner-manager'
        ],
        'excluded_routes' => [
            'two-factor-authentication',
            'confirm-2fa',
        ]
    ]
];
```

### Middleware

[](#middleware)

```
1. RedirectIfTwoFactorNotActivated.php
2. SetRenderLocation.php

```

If the mandatory authentication guard user has not set up 2FA, they will be redirected to the two-factor authentication setup page by the **RedirectIfTwoFactorNotActivated** middleware.

The **SetRenderLocation** middleware will display a notification banner on a page to remind to enable 2FAThe SetRenderLocationmiddleware will display a notification banner on a page to remind users to enable 2FA.

### 2FA Notification Banner

[](#2fa-notification-banner)

In the configuration, if the auth guard is enabled to manage the banner, the user can create, edit, delete, and enable/disable the banner.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Lee Evans](https://github.com/lee)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

50

—

FairBetter than 96% of packages

Maintenance86

Actively maintained with recent releases

Popularity23

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~9 days

Recently: every ~45 days

Total

56

Last Release

70d ago

Major Versions

1.0.22 → 4.0.12025-08-19

### Community

Maintainers

![](https://www.gravatar.com/avatar/133e7275d57b3053e870a66332b987ae0be489e1c61938f22196d42cf19d2be9?d=identicon)[ekoukltd](/maintainers/ekoukltd)

---

Top Contributors

[![cannycookie](https://avatars.githubusercontent.com/u/500822?v=4)](https://github.com/cannycookie "cannycookie (51 commits)")[![AravindRam-Ranium](https://avatars.githubusercontent.com/u/120371206?v=4)](https://github.com/AravindRam-Ranium "AravindRam-Ranium (47 commits)")[![codelikesuraj](https://avatars.githubusercontent.com/u/70463535?v=4)](https://github.com/codelikesuraj "codelikesuraj (5 commits)")

---

Tags

laravelfilament-2favisual builder

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/visualbuilder-filament-2fa/health.svg)

```
[![Health](https://phpackages.com/badges/visualbuilder-filament-2fa/health.svg)](https://phpackages.com/packages/visualbuilder-filament-2fa)
```

###  Alternatives

[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[jeffgreco13/filament-breezy

A custom package for Filament with login flow, profile and teams support.

1.0k1.7M41](/packages/jeffgreco13-filament-breezy)[dutchcodingcompany/filament-socialite

Social login for Filament through Laravel Socialite

213914.9k9](/packages/dutchcodingcompany-filament-socialite)[stephenjude/filament-two-factor-authentication

Filament Two Factor Authentication: Google 2FA + Passkey Authentication

81158.7k4](/packages/stephenjude-filament-two-factor-authentication)[marcelweidum/filament-passkeys

Use passkeys in your filamentphp app

5925.8k](/packages/marcelweidum-filament-passkeys)[tapp/filament-invite

invite users from filament panel

3145.8k](/packages/tapp-filament-invite)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
