2017 © Pedro Peláez
 

package two-factor-authentication

Two Factor Authentication (2FA) for Laravel

image

thecodework/two-factor-authentication

Two Factor Authentication (2FA) for Laravel

  • Wednesday, May 9, 2018
  • by imrealashu
  • Repository
  • 5 Watchers
  • 11 Stars
  • 503 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 2 Open issues
  • 10 Versions
  • 4 % Grown

The README.md

Build Status Scrutinizer Code Quality StyleCI License, (*1)

Laravel Two Factor Authentication (2FA)

Two, (*2)

Two Factor Authentication or 2-Step Verification provides stronger security for your Account by requiring a second step of verification when you sign in. In addition to your password, you’ll also need a code generated by the Google Authenticator app on your phone. This package implements TOTP defined in RFC 6238, (*3)

Requirements

  • PHP >= 7.1
  • Laravel >= 5.3
  • Google Authenticator Android - iOS (Recommended) or Authy mobile app

Installation

1. Composer Install, (*4)

$ composer require thecodework/two-factor-authentication

Note - If your're using Laravel 5.5 or newer version then auto-discovery-pacakge would automatically update the providers and you could skip to Step 3, (*5)

2. Add Service Provider, (*6)

After requiring the package add TwoFactorAuthenticationServiceProvider::class into providors array in app.php confi file, (*7)

[
 'providers' => [
    //...
    Thecodework\TwoFactorAuthentication\TwoFactorAuthenticationServiceProvider::class
  ]
]

3. Publish the ConfigFile, (*8)

Publish config file, (*9)

$ php artisan vendor:publish --provider="Thecodework\TwoFactorAuthentication\TwoFactorAuthenticationServiceProvider" --tag=config

Once the config file is published you can navigate to config directory of your application and look for 2fa-config.php file and change configuration as you want., (*10)

4. Run Migrations, (*11)

Now run the migration, (*12)

$ php artisan migrate

It will use the default User model and adds two columns is_2fa_enabled and secret_key., (*13)

5. Add AuthenticatesUserWith2FA trait in the LoginController, (*14)

Now the config file is placed. The last thing to do is addding AuthenticatesUsersWith2FA trait in the Http/Controllers/Auth/LoginController.php file which helps to stop user at verify-2fa page to enter TOTP token after each login., (*15)

The final snippet will look like this., (*16)

use AuthenticatesUsers, AuthenticatesUsersWith2FA {
    AuthenticatesUsersWith2FA::authenticated insteadof AuthenticatesUsers;
}

Note: Don't forget to include use statement use Thecodework\TwoFactorAuthentication\AuthenticatesUsersWith2FA in the header., (*17)

6. Setup 2FA for user, (*18)

• Enable 2FA, (*19)

Now login to the application and visit /setup-2fa/ route, which will show a barcode which can be scanned either using Google Authenticator or Authy mobile application as described above. Scan that code and click Enable Two Factor Authentication., (*20)

• Disable 2FA, (*21)

To disable Two Factor, visit /setup-2fa route, which will now show a Disable Two Factor Authentication button. Click to disable 2FA for your account., (*22)

7. Testing 2FA, (*23)

Now to test 2FA, perform logout and log back in again, it will ask you to enter Token which can be obtain from the authenticator mobile application. Enter the token and you're logged in., (*24)

Additionally

If you want to publish views, and migration as well along with config file then run, (*25)

$ php artisan vendor:publish --provider="Thecodework\TwoFactorAuthentication\TwoFactorAuthenticationServiceProvider"

Contribution

Feel free to create issues, submit PRs and talk about features and enhancement through proposing issue. If you find any security consideration, instead of creating an issue send an email to imrealashu@gmail.com., (*26)

The Versions

09/05 2018

dev-master

9999999-dev

Two Factor Authentication (2FA) for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel authentication 2fa laravel 5 two-factor rfc-6238

24/02 2018

0.1.7.1

0.1.7.1

Two Factor Authentication (2FA) for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel authentication 2fa laravel 5 two-factor rfc-6238

24/12 2017

0.1.7

0.1.7.0

Two Factor Authentication (2FA) for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel authentication 2fa laravel 5 two-factor rfc-6238

24/12 2017

dev-analysis-qvRe4l

dev-analysis-qvRe4l

Two Factor Authentication (2FA) for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel authentication 2fa laravel 5 two-factor rfc-6238

06/04 2017

0.1.6

0.1.6.0

Two Factor Authentication (2FA) for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel authentication 2fa laravel 5 two-factor rfc-6238

03/04 2017

0.1.5

0.1.5.0

Two Factor Authentication (2FA) for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel authentication 2fa laravel 5 two-factor rfc-6238

02/04 2017

0.1.4

0.1.4.0

Two Factor Authentication (2FA) for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel authentication 2fa laravel 5 two-factor rfc-6238

31/03 2017

0.1.3

0.1.3.0

Two Factor Authentication (2FA) for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel authentication 2fa laravel 5 two-factor rfc-6238

24/03 2017

0.1.2

0.1.2.0

Two Factor Authentication (2FA) for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel authentication 2fa laravel 5 two-factor rfc-6238

23/03 2017

0.1.1

0.1.1.0

Two Factor Authentication (2FA) for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel authentication 2fa laravel 5 two-factor rfc-6238