elsayed85/nova-two-factor

Nova Two Factor Authentication

dev-main 2022-10-08 18:49 UTC

This package is not auto-updated.

Last update: 2024-11-04 02:37:14 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require

Nova-Two-Factor

Laravel nova in-dashboard 2FA security feature

Versions

Use v2.0.0 for Laravel Nova 4

Use ^v1.0.0 for Laravel Nova 3

\\ Nova 4

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


\\ Nova 3

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

Look

Setup 2FA

screenshot

Enable/Disable feature

screenshot

Nova login screen with 2FA security

screenshot

  1. Pubish config & migration

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

Change configs as your needs


return [
    // enable or disale 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

];

  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 !