承接 gabrielesbaiz/nova-two-factor 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

gabrielesbaiz/nova-two-factor

最新稳定版本:1.0.0

Composer 安装命令:

composer require gabrielesbaiz/nova-two-factor

包简介

Laravel nova in-dashboard 2FA feature.

README 文档

README

Latest Version on Packagist Total Downloads

Laravel nova in-dashboard 2FA feature.

Original code from Visanduma/nova-two-factor

Features

  • ✅ Global enable / disable
  • ✅ Mandatory / Not mandatory
  • ✅ Google 2FA encrypted
  • ✅ BancodeQrCode / Google API

Installation

You can install the package via composer:

composer require gabrielesbaiz/nova-two-factor

You can publish and run the migrations with:

php artisan vendor:publish --tag="nova-two-factor-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --tag="nova-two-factor-config"

This is the contents of the published config file:

return [
    'enabled' => env('NOVA_TWO_FA_ENABLE', true),

    'mandatory' => env('NOVA_TWO_FA_MANDATORY', false),

    'user_table' => 'users',

    'user_id_column' => 'id',

    'connection_name' => env('DB_CONNECTION'),

    /* Encrypt the google secret values saved in database */
    'encrypt_google2fa_secrets' => false,

    /* QR code can be generate using  Google API or inbuilt 'BaconQrCode' package */
    'use_google_qr_code_api' => true,

    '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, within 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,
];

Usage

  1. Pubish config & migration

  2. Use ProtectWith2FA trait in configured model

namespace App\Models;

use Gabrielesbaiz\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' => [
        ...
        \Gabrielesbaiz\NovaTwoFactor\Http\Middleware\TwoFa::class
    ],
  1. Register NovaTwoFactor tool in Nova Service Provider
<?php

class NovaServiceProvider extends NovaApplicationServiceProvider{

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

        ];
    }

}

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 934
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-04