Laravel Community Tools by Tighten
Laravel Nova icon Nova Packages

Readme

Latest Version on Packagist Total Downloads

Nova-Two-Factor

Laravel nova in-dashboard 2FA security feature.

Versions

Use v3.* for Laravel Nova 5

Use v2.* for Laravel Nova 4

Use ^v1.* for Laravel Nova 3

\\ Nova 5

composer require visanduma/nova-two-factor:~3

\\ Nova 4

composer require visanduma/nova-two-factor:~2


\\ Nova 3

composer require visanduma/nova-two-factor:~1

What's New

v3.0

  • Nova 5.0 support

v2.2.14

  • Fixed offline QRCode display issue

v2.2.3

  • Fixed foreign key issue (need to run migration)
  • Translation fixes

v2.2.2

  • Clear option for current Two FA settings

v2.2.0

  • Reauthorize any routes using 2FA Prompt dialog.

Interface

Setup 2FA

screenshot

Enable/Disable feature

screenshot

Nova login screen with 2FA security

screenshot

Reauthorize any route using 2FA prompt

screenshot

Install the package

composer require visanduma/nova-two-factor

  1. Pubish config & migration

php artisan vendor:publish --provider="Visanduma\NovaTwoFactor\ToolServiceProvider"

Change configs as your needs


return [
    // defaults to app.name when null
    'display_name' => null,
    
     // enable or disable 2FA feature. default is enabled
    'enabled' => env('NOVA_TWO_FA_ENABLE',true),
    
    // name of authenticatable entity table. usually - users
    'user_table' => 'users',
    
    // Entity primary key
    'user_id_column' => 'id',
    
    // authenticatable model class
    'user_model' => \App\Models\User::class

    /* Change visibility of Nova Two Fa menu in right sidebar */
    'showin_sidebar' => true,

    'menu_text' => 'Two FA',

    'menu_icon' => 'lock-closed',

    /* Exclude any routes from 2fa security */
    'except_routes' => [
        //
    ],

    /**
     * reauthorize these urls before access, withing given timeout
     * you are allowed to use wildcards pattern for url matching
     **/

    'reauthorize_urls' => [
       // 'resources/users/new',
       // 'resources/users/*/edit',
    ],

    /* timeout in minutes */

    'reauthorize_timeout' => 5,


    /* QR code can be generate using  online API or inbuilt 'BaconQrCode' package*/

    'use_offline_qr' => false,

];

  1. Use ProtectWith2FA trait in configured model
<?php

namespace App\Models;

use Visanduma\NovaTwoFactor\ProtectWith2FA;

class User extends Authenticatable{

    use ProtectWith2FA;
}

  1. Add TwoFa middleware to nova config file
/*
    |--------------------------------------------------------------------------
    | Nova Route Middleware
    |--------------------------------------------------------------------------
    |
    | These middleware will be assigned to every Nova route, giving you the
    | chance to add your own middleware to this stack or override any of
    | the existing middleware. Or, you can just stick with this stack.
    |
    */

    'middleware' => [
        ...
        \Visanduma\NovaTwoFactor\Http\Middleware\TwoFa::class
    ],

  1. Register NovaTwoFactor tool in Nova Service Provider
<?php

class NovaServiceProvider extends NovaApplicationServiceProvider{

public function tools()
    {
        return [
            ...
            new \Visanduma\NovaTwoFactor\NovaTwoFactor()

        ];
    }

}


  1. Run php artisan migrate
  2. You are done !

Reviews

By Mounir Azizi on April 26, 2025

Simple, Easy and Reliable ... Many thanks!

By ekazda on March 26, 2024

This package is amazing. Took me 30 minutes to get running, and that is only because I have to figure out how to add it to my custom menu. I guarantee this saves me days worth of work. Also, for anyone that needs it, if you are using a custom menu, you will have to add something like this to your NovaServiceProvider: Nova::mainMenu(function (Request $request) { return [ //Your other menu items... MenuSection::make('Your Settings', [ MenuItem::link('2FA', '/nova-two-factor'), ])->icon('user-circle')->collapsable(), ]; });

Back to Top
Added 3 years ago
Last updated 1 Year Ago
Version 3.0.1
Nova Version ^5.0
Composer
Visanduma/nova-two-factor
GitHub stars 55
Packagist downloads 601,034

Favorites

5 users favorited

Rating

5.00
(out of 5)
★★★★★
★★★★
★★★
★★
2 ratings

Author

Brought to you by Tighten

Issues/Feature Requests Stats Package Ideas