Home

Awesome

Laravel 2 Step Verification

Laravel 2 Step Verification

Laravel 2-Step Verification is a package to add 2-Step user authentication to any Laravel project easily. It is configurable and customizable. It uses notifications to send the user an email with a 4-digit verification code. Can be used in out the box with Laravel's authentication scaffolding or integrated into other projects.

Travis-CI Build Latest Stable Version Total Downloads StyleCI Build Status Scrutinizer Code Quality Code Intelligence Status MadeWithLaravel.com shield License: MIT

Table of contents:

Features

Laravel 2 Step Verification Features
Uses Notification Class to send user code to users email
Can publish customizable views and assets
Lots of configuration options
Uses Language localization files
Verificaton Page
Locked Page

Requirements

Installation Instructions

  1. From your projects root folder in terminal run:

    Laravel 6+ use:

        composer require jeremykenedy/laravel2step
    

    Laravel 5.8 use:

        composer require jeremykenedy/laravel2step:v1.4.0
    

    Laravel 5.7 and below use:

        composer require jeremykenedy/laravel2step:v1.0.2
    
  2. Register the package

    'providers' => [
        jeremykenedy\laravel2step\laravel2stepServiceProvider::class,
    ];
  1. Publish the packages views, config file, assets, and language files by running the following from your projects root folder:
    php artisan vendor:publish --tag=laravel2step
  1. Optionally Update your .env file and associated settings (see Environment File section)

  2. Run the migration to add the verifications codes table:

    php artisan migrate
  1. Make sure your apps email is configured - this is usually done by configuring the Laravel out the box settings in the .env file.

Configuration

Laravel 2-Step Verification can be configured in directly in /config/laravel2step.php or in the variables in your .env file.

Environment File

Here are the .env file variables available:

LARAVEL_2STEP_ENABLED=true
LARAVEL_2STEP_DATABASE_CONNECTION=mysql
LARAVEL_2STEP_DATABASE_TABLE=laravel2step
LARAVEL_2STEP_USER_MODEL=App\User
LARAVEL_2STEP_EMAIL_FROM="anEmailIsrequired@email.com"
LARAVEL_2STEP_EMAIL_FROM_NAME="Laravel 2 Step Verification"
LARAVEL_2STEP_EMAIL_SUBJECT='Laravel 2 Step Verification'
LARAVEL_2STEP_EXCEEDED_COUNT=3
LARAVEL_2STEP_EXCEEDED_COUNTDOWN_MINUTES=1440
LARAVEL_2STEP_VERIFIED_LIFETIME_MINUTES=360
LARAVEL_2STEP_RESET_BUFFER_IN_SECONDS=300
LARAVEL_2STEP_CSS_FILE="css/laravel2step/app.css"
LARAVEL_2STEP_APP_CSS_ENABLED=false
LARAVEL_2STEP_APP_CSS="css/app.css"
LARAVEL_2STEP_BOOTSTRAP_CSS_CDN_ENABLED=true
LARAVEL_2STEP_BOOTSTRAP_CSS_CDN="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"

Usage

Laravel 2-Step Verification is enabled via middleware. You can enable 2-Step Verification in your routes and controllers via the following middleware:

twostep

Example to start recording page views using middlware in web.php:

Route::group(['middleware' => ['twostep']], function () {
    Route::get('/home', 'HomeController@index')->name('home');
});

Routes

Screenshots

Verification Page Resent Email Modal Lock Warning Modal Locked Page Verification Email

File Tree

└── laravel2step
    ├── .gitignore
    ├── LICENSE
    ├── README.md
    ├── composer.json
    └── src
        ├── .env.example
        ├── Laravel2stepServiceProvider.php
        ├── app
        │   ├── Http
        │   │   ├── Controllers
        │   │   │   └── TwoStepController.php
        │   │   └── Middleware
        │   │       └── Laravel2step.php
        │   ├── Models
        │   │   └── TwoStepAuth.php
        │   ├── Notifications
        │   │   └── SendVerificationCodeEmail.php
        │   └── Traits
        │       └── Laravel2StepTrait.php
        ├── config
        │   └── laravel2step.php
        ├── database
        │   └── migrations
        │       └── 2017_12_09_070937_create_two_step_auth_table.php
        ├── public
        │   └── css
        │       ├── app.css
        │       └── app.min.css
        ├── resources
        │   ├── assets
        │   │   └── scss
        │   │       ├── _animations.scss
        │   │       ├── _mixins.scss
        │   │       ├── _modals.scss
        │   │       ├── _variables.scss
        │   │       ├── _verification.scss
        │   │       └── app.scss
        │   ├── lang
        │   │   └── en
        │   │       └── laravel-verification.php
        │   └── views
        │       ├── layouts
        │       │   └── app.blade.php
        │       ├── partials
        │       ├── scripts
        │       │   └── input-parsing-auto-stepper.blade.php
        │       └── twostep
        │           ├── exceeded.blade.php
        │           └── verification.blade.php
        └── routes
            └── web.php

Future

Opening an Issue

Before opening an issue there are a couple of considerations:

Open source projects are a the community’s responsibility to use, contribute, and debug.

License

Laravel 2-Step Verification is licensed under the MIT license. Enjoy!