Laravel nova in-dashboard 2FA security feature including email OPT and Google App codes. Fork of visanduma/nova-two-factor package.
composer install elbytes/nova-two-factor
Select type (email/Google app) and setup 2FA
Enable/Disable feature
Nova login screen with 2FA security
- Pubish config & migration
php artisan vendor:publish --provider="Elbytes\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
];
- Use ProtectWith2FA trait in configured model
<?php
namespace App\Models;
use Elbytes\NovaTwoFactor\ProtectWith2FA;
class User extends Authenticatable{
use ProtectWith2FA;
}
- 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' => [
...
\Elbytes\NovaTwoFactor\Http\Middleware\TwoFa::class
],
- Register NovaTwoFactor tool in Nova Service Provider
<?php
class NovaServiceProvider extends NovaApplicationServiceProvider{
public function tools()
{
return [
...
new \Elbytes\NovaTwoFactor\NovaTwoFactor()
];
}
}
- Run
php artisan migrate
- You are done !