Google Authenticator extension for laravel-admin
tech-djoin/laravel-admin-ext-google-authenticator is a Laravel package for google authenticator extension for laravel-admin.
It currently has 1 GitHub stars and 14 downloads on Packagist (latest version v1.0.1).
Install it with composer require tech-djoin/laravel-admin-ext-google-authenticator.
Discover more Laravel packages by tech-djoin
or browse all Laravel packages to compare alternatives.
Last updated
Two-Factor Authentication (2FA) extension for Laravel Admin using Google Authenticator.
Install the package via Composer:
composer require tech-djoin/laravel-admin-ext-google-authenticator
Publish assets and configuration:
php artisan vendor:publish --provider="TechDjoin\LaravelAdminGoogleAuthenticator\GoogleAuthenticatorServiceProvider" --tag="config"
Customize the configuration file in config/google2fa.php as needed.
Run migrations:
php artisan migrate
Override the Administrator.php file in the /vendor/encore/laravel-admin/src/Auth/Database directory and update your admin user model (usually in App/Models/AdminUser.php):
<?php
namespace App\Models;
use Encore\Admin\Auth\Database\Administrator;
use Illuminate\Notifications\Notifiable;
use TechDjoin\LaravelAdminGoogleAuthenticator\Traits\Google2FAAuthenticatableTrait;
class AdminUser extends Administrator
{
use Notifiable;
use Google2FAAuthenticatableTrait;
protected $fillable = ['username', 'password', 'name', 'avatar', 'google2fa_secret'];
public function setGoogle2faSecretAttribute($value)
{
$this->attributes['google2fa_secret'] = !is_null($value) ? encrypt($value) : null;
}
public function getGoogle2faSecretAttribute($value)
{
return isset($value) ? decrypt($value) : null;
}
}
Update config/admin.php:
'auth' => [
'model' => App\Models\AdminUser::class,
],
'database' => [
'users_model' => App\Models\AdminUser::class
],
Install PHP Imagick extension for QR code generation.
You can configure the extension by editing config/google2fa.php or setting values in your .env file:
ADMIN_2FA_ENABLED=true
ADMIN_2FA_LIFETIME=0
ADMIN_2FA_KEEP_ALIVE=true
php_imagick.dll to the PHP ext folder..dll files from the bin folder to the main PHP folder.php.ini, add the line extension=imagick.Update repository:
sudo apt update
Install Imagick:
sudo apt install php-imagicksudo apt install php8.x-imagickRestart web server:
sudo systemctl restart apache2sudo systemctl restart nginxVerify the installation by running php -m | grep imagick.