Polyscope - The agent-first dev environment for Laravel

Nova Two Factor

visanduma/nova-two-factor image

Nova Two Factor stats

Downloads
67.4K
Stars
39
Open Issues
0
Forks
23

View on GitHub →

Nova Two Factor Authentication

Nova-Two-Factor

Laravel nova in-dashboard 2FA security feature.

What's New

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

Enable/Disable feature

Nova login screen with 2FA security

Reauthorize any route using 2FA prompt

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 [
 
// 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' => [
// 'nova/resources/users/new',
// 'nova/resources/users/*/edit',
],
 
/* timeout in minutes */
 
'reauthorize_timeout' => 5,
 
];
  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 !
Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.


Visanduma Nova Two Factor Related Articles

Build Custom Middleware for Query Performance Monitoring and Optimization in Laravel with MongoDB image

Build Custom Middleware for Query Performance Monitoring and Optimization in Laravel with MongoDB

Read article
Factory makeMany() Method in Laravel 12.52.0 image

Factory makeMany() Method in Laravel 12.52.0

Read article
Capture Web Page Screenshots in Laravel with Spatie's Laravel Screenshot image

Capture Web Page Screenshots in Laravel with Spatie's Laravel Screenshot

Read article
MongoDB Document Structure & Data Modeling image

MongoDB Document Structure & Data Modeling

Read article
Laravel Boost, your AI coding starter kit image

Laravel Boost, your AI coding starter kit

Read article
Singleton and Scoped Container Attributes in Laravel 12.21 image

Singleton and Scoped Container Attributes in Laravel 12.21

Read article
Lucky Media logo

Lucky Media

Get Lucky Now - the ideal choice for Laravel Development, with over a decade of experience!

Lucky Media
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell
Honeybadger logo

Honeybadger

Simple developer-focused application monitoring for Laravel. Error tracking, log management, uptime monitoring, status pages, and more!

Honeybadger
Tighten logo

Tighten

We help companies turn great ideas into amazing apps, products, and services.

Tighten
Laravel Cloud logo

Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Laravel Cloud