Laravel 2-Step Verification is a package to add 2-Step user authentication to any Laravel project easily.

Overview

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

  • Laravel 5.5 and up Uses package auto discovery feature, no need to edit the config/app.php file.

  • Laravel 5.4 and below Register the package with laravel in config/app.php under providers with the following:

    '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
  • Note: If you want to specify a different table or connection make sure you update your .env file with the needed configuration variables.
  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="[email protected]"
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

  • /verification/needed
  • /verification/verify
  • /verification/resend

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

  • Tree command can be installed using brew: brew install tree
  • File tree generated using command tree -a -I '.git|node_modules|vendor|storage|tests

Future

  • Unit Tests
  • Travis-CI Integration.
  • Its own HTML email template.
  • Add in additional notifications for SMS or ???.
  • Add in capture IP Address.
  • Change to incremental tables and logic accordingly
    • Create Artisan command and job to prune said entries.

Opening an Issue

Before opening an issue there are a couple of considerations:

  • You are all awesome!
  • Read the instructions and make sure all steps were followed correctly.
  • Check that the issue is not specific to your development environment setup.
  • Provide duplication steps.
  • Attempt to look into the issue, and if you have a solution, make a pull request.
  • Show that you have made an attempt to look into the issue.
  • Check to see if the issue you are reporting is a duplicate of a previous reported issue.
  • Following these instructions show me that you have tried.
  • If you have a questions send me an email to [email protected]
  • Need some help, I can do my best on Slack: https://opensourcehelpgroup.slack.com
  • Please be considerate that this is an open source project that I provide to the community for FREE when openeing an issue.

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!

Comments
  • I may have missed it but

    I may have missed it but

    Hello. This isnt a bug but I may have missed it in the documentation somewhere or a route not specified. I have it all working and its great but when my user logs out the record in the database for 2fa is not removed and if they immediately then log back in there is no request for 2fa. Is there a setting I am missing to force 2fa on every login regardless that they have just logged out. Many thanks Neil

    opened by neilwaringjag 1
  • Target class [App\Http\Controllers\jeremykenedy\laravel2step\App\Http\Controllers\TwoStepController] does not exist.

    Target class [App\Http\Controllers\jeremykenedy\laravel2step\App\Http\Controllers\TwoStepController] does not exist.

    I'd implement this project into https://github.com/jeremykenedy/laravel-auth this project but this 2step project is in vendor folder. and show this error **

    Illuminate\Contracts\Container\BindingResolutionException Target class [App\Http\Controllers\jeremykenedy\laravel2step\App\Http\Controllers\TwoStepController] does not exist. http://localhost/laravelAuth/public/verification/needed

    **

    can you please help me out this.

    opened by ghost 1
  • Configurable

    Configurable "auth" middleware

    Hello there,

    I installed this package in a small backpack project and I had an issue with the middleware. The first error I encountered was Route [login] not defined. when trying to login, after being automatically redirected to /verification/needed

    According to this line of code,, the middleware used by the package is "auth", it should be told in the installation steps to create a middleware group auth in case of need. Or may be let the possibility to configure it ? For example in my project I had to add this in App\Http\Kernel :

        protected $middlewareGroups = [
            // ...
            'admin' => [
                'twostep',
            ],
    
            'auth' => ['admin'],
            //...
        ];
    
    opened by bastos71 1
  • iOS input not solved

    iOS input not solved

    Hi Jeremy, thank you very much for your kind attention to the issue I wrote two month ago. I'm sorry to tell you that the solution you made doesn't solve the problem. However, after many attempts I discovered a behavior that I hope will help you finding a solution:

    • so far, the only way to type in the first character is to copy it from the email and paste it in the first field.

    • To input the second character you must leave the cursor in the first field and type in the second character that automatically will be placed in the second field and so on.

    Please, let me know if there's anything I can help you with this issue.

    opened by Mokei-it 1
  • iOS fix for input changing

    iOS fix for input changing

    Bug in iOS (potentially other mobile OS but not tested) which meant when you selected the first input and entered the first character, the character is entered into the second input.

    fixes #5

    opened by rich1888 1
  • iPhone usage

    iPhone usage

    Hi Jeremy, thanks for the very elegant project you have created. I noticed that I can't use it with iPhone phones. When typing the first character, it is written in the second field and it is impossible to write anything in the first field. I've tested it with different iPhone models, and with Safari, Opera, Firefox and Chrome browsers. Am I wrong in something or is it happening to you too? No problem with Android mobile phones. Thanks in advance

    opened by Mokei-it 1
  • Usage Question

    Usage Question

    This is a really neat package.....but from what Im understanding it replaces the default password login usage? I am thinking it would be neat if there was a added column to the users table called "twostep_auth". True or False / 0 or 1. If false then user logs in as normal with there username and password. If true then they login with username and password but then redirect to enter there twostep_auth code before getting full access and redirected to home page of ones site?

    opened by HDVinnie 1
  • Usage for a particular auth in multi auth package

    Usage for a particular auth in multi auth package

    I'm using laravel 5.6 with hesto multi auth. the default user thats created with make:auth is using bestmomo laravel email confirmation package which works fine.

    Now i have installed hesto multi auth and created a new auth called business. I would like to use your package only for this auth. How to do this?

    opened by imsrikanthgopi 0
  • VERIFIED LIFETIME

    VERIFIED LIFETIME

    Thanks for the wonderful package. Can you make the verified lifetime be reliance to the session lifetime? In this case when a user logs out or session expires, the authStatus changes to false, so that when a user logs in back again he is required again to be verified.

    Thank you in advance.

    opened by davymaish 0
Releases(v2.2.0)
Owner
Jeremy Kenedy
Love programming everyday. Practice compassion and kindness to all. Striving to be a better person and father. Love giving back and helping others.
Jeremy Kenedy
Laravel Authentication Log is a package Log user authentication details and send new device notifications.

Laravel Authentication Log is a package which tracks your user's authentication information such as login/logout time, IP, Browser, Location, etc. as well as sends out notifications via mail, slack, or sms for new devices and failed logins.

Anthony Rappa 540 Jan 5, 2023
Easily add a full Laravel blog (with built in admin panel and public views) to your laravel project with this simple package.

Webdevetc BlogEtc - Complete Laravel Blog Package Quickly add a blog with admin panel to your existing Laravel project. It has everything included (ro

WebDevEtc. 227 Dec 25, 2022
A Laravel 8 Project Implement with GraphQL With Sanctum APIs Authentications Which utilized in Any Frontend or Any Mobile Application Programs.

A Laravel 8 Project Implement with GraphQL With Sanctum APIs Authentications Which utilized in Any Frontend or Any Mobile Application Programs.

Vikas Ukani 3 Jan 6, 2022
Easily add all the 58 Algerian Wilayas and its Dairas to your cool Laravel project (Migrations, Seeders and Models).

Laravel-Algereography Laravel-Algereography allows you to add Migrations, Seeders and Models of Algerian Wilayas and Dairas to your existing or new co

Hocine Saad 48 Nov 25, 2022
This package provides convenient methods for making token code, sending and verifying mobile phone verification requests.

Laravel Mobile Verification Introduction Many web applications require users to verify their mobile phone numbers before using the application. Rather

M.Fouladgar 347 Dec 25, 2022
Laravel comments - This package enables to easily associate comments to any Eloquent model in your Laravel application

Laravel comments - This package enables to easily associate comments to any Eloquent model in your Laravel application

Rubik 4 May 12, 2022
This package helps you to add user based follow system to your model.

Laravel Follow User follow unfollow system for Laravel. Related projects: Like: overtrue/laravel-like Favorite: overtrue/laravel-favorite Subscribe: o

安正超 1k Dec 31, 2022
Provides email verification on the go.

Email Checker Email Checker was created and maintained by Aman Nurani. It provides a powerful email validating system for both development and product

Aman 137 Dec 23, 2022
🧙‍♀️ Arcanist takes the pain out of building multi-step form wizards in Laravel.

Installation Arcanist requires PHP 8 and Laravel 8. composer require laravel-arcanist/arcanist Documentation You can find the full documentation here

Arcanist 378 Jan 3, 2023
cybercog 996 Dec 28, 2022
Add settings to any Laravel model.

Laravel Property Bag Simple settings for Laravel apps. Easily give multiple resources settings Simple to add additional settings as your app grows Set

Zach Leigh 80 Aug 8, 2022
Easily add Laravel Telescope and Horizon to Filament admin panel.

Filament Debugger This is where your description should go. Limit it to a paragraph or two. Consider adding a small example. Installation You can inst

Stephen Jude 5 Nov 24, 2022
A Laravel Wrapper for the CoinDCX API. Now easily connect and consume the CoinDCX Public API in your Laravel apps without any hassle.

This package provides a Laravel Wrapper for the CoinDCX API and allows you to easily communicate with it. Important Note This package is in early deve

Moinuddin S. Khaja 2 Feb 16, 2022
Easily create a revision history for any laravel model

Wouldn't it be nice to have a revision history for any model in your project, without having to do any work for it. By simply adding the RevisionableT

Venture Craft 2.4k Jan 6, 2023
Laravel Podcast is Laravel 5.5 web app that enables you to manage RSS feeds for your favorite podcasts and listen to the episodes in a seamless UI and User Authentication.

Laravel Podcast is Laravel 5.5 web app that enables you to manage RSS feeds for your favorite podcasts and listen to the episodes in a seamless UI and

Jeremy Kenedy 35 Dec 19, 2022
Log user authentication actions in Laravel.

Laravel Auth Log The laravel-auth-log package will log all the default Laravel authentication events (Login, Attempting, Lockout, etc.) to your databa

Label84 29 Dec 8, 2022
Add a general-purpose tools page to your Filament project. 🛠

Add a general-purpose tools page to your Filament project. Installation You can install the package via Composer: composer require ryangjchandler/fila

Ryan Chandler 24 Dec 6, 2022
A Simple PHP Renderer for Slim 3 (or any other PSR-7 project)

PHP Renderer This is a renderer for rendering PHP view scripts into a PSR-7 Response object. It works well with Slim Framework 4. Cross-site scripting

Slim Framework 235 Jan 5, 2023
GeoLocation-Package - This package helps you to know the current language of the user, the country from which he is browsing, the currency of his country, and also whether he is using it vpn

GeoLocation in PHP (API) ?? ?? ?? This package helps you to know a lot of information about the current user by his ip address ?? ?? ?? This package h

Abdullah Karam 4 Dec 8, 2022