PHPackages                             dragonzap/2fa - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. dragonzap/2fa

ActiveLaravel-package[Authentication &amp; Authorization](/categories/authentication)

dragonzap/2fa
=============

Used for building two factor authentication in laravel

v2.0.0(2y ago)077GPL-2.0-or-laterPHP

Since Apr 12Pushed 2y ago1 watchersCompare

[ Source](https://github.com/dragonzapeducation/DragonZap2FA)[ Packagist](https://packagist.org/packages/dragonzap/2fa)[ RSS](/packages/dragonzap-2fa/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (2)Versions (5)Used By (0)

DragonZap2FA
============

[](#dragonzap2fa)

This is a Laravel two factor authentication package which is defaulted to provide two factor authentication through email but also supports TOTP(Time based one time password) for use in authenticator applications such as microsoft authenticator and google authenticator. The classes can be overrided and the functionality is fully customizeable allowing you to provide 2FA to your users. Adding 2FA is as easy as assigning the route middlewear "twofactor" as seen in the below example

```
  Route::group(['middleware' => ['auth','twofactor:always']], function () {
        // Sales Routes
        Route::get('user/orders', 'Backend\IncomeController@index')->name('user.orders');
  });

```

You can provide the "always" tag to always require two factor authentication even if the user has not enabled two factor authentication. You can provide the tag "if-enabled" for situations where you will only two factor if the user has enabled two factor authentication. Upon a user completing two factor authentication it will be enabled on his account

Installing the DragonZAP2FA package
-----------------------------------

[](#installing-the-dragonzap2fa-package)

Now that you have seen how easy it is to use this package lets begin with the installation. First install [Composer](https://getcomposer.org) which will allow you to install our package. Once composer is installed you must run the following command in your laravel directory:

```
composer install dragonzap/2fa ^2.0

```

Publishing the vendor files
---------------------------

[](#publishing-the-vendor-files)

Next you need to publish the vendor files

```
php artisan vendor:publish --provider="Dragonzap\TwoFactorAuthentication\TwoFactorAuthenticationProvider"

```

Migrating the database
----------------------

[](#migrating-the-database)

With these changes completed you now need to migrate the Laravel database

```
php artisan migrate

```

This will ensure that the changes to the user table take place to allow 2FA to be enabled or disabled for them

Changing the configuration
--------------------------

[](#changing-the-configuration)

Upon completing all these steps the package is installed, you can customize the configuration file found at ./config/dragonzap\_2fa.php

```
