Laravel two-factor authentication

 Security is recognized as one of the most important factors of Laravel framework. The two-factor authentication makes it even more reliable by providing an additional layer of security. Two-factor authentication is also referred to as Two-Step-Verification. We have come across two factor authentication in our daily activities like signing into your google account, Facebook account, many other websites which have highly sensitive data also use this for providing more security.There are many two-factor authentication packages available on the internet but if you don’t want to install them follow these steps. 

  1. Add a two factor form

  2. create a mail-able

  3. Create database migrations

  4. Then set up controller and routes.

A two factor authentication works like this:

  • A user tries to access a route secured by two factor authentication, he gets a mail notification with an OTP 

  • User opens the mail enters the OTP to the redirected form.

  • Gets verified if correct he can access the resource.

  • If OTP is wrong access will be denied.

  • User session will last as long as the time set in Laravel’s set session lifetime.