raisulhridoy/laravel-2fa

Laravel 2FA is a PHP implementation of the Google Two-Factor Authentication Module, supporting the HMAC-Based One-time Password (HOTP) algorithm specified in RFC 4226 and the Time-based One-time Password (TOTP) algorithm specified in RFC 6238.

v0.0.1 2023-06-18 09:50 UTC

This package is auto-updated.

Last update: 2025-05-18 15:53:53 UTC


README

This package provides a simple and intuitive way of adding two-factor authentication to your Laravel application. It's perfect for developers who want a lightweight package that gets the job done without any unnecessary complexity.

Installation

Use the package manager composer to install this package.

composer require raisulhridoy/laravel-2fa

Add the service provider in config/app.php file in the providers array as below:

RaisulHridoy\Laravel2FA\TwoFactorAuthServiceProvider::class,

Publish the package configuration

php artisan vendor:publish --provider="RaisulHridoy\Laravel2FA\TwoFactorAuthServiceProvider"

Specify table name corresponding to the 2FA functionality in ".env" file. By default, it will be 'users' respectively and "google2fa_secret", "google2fa_enabled" & "google2fa_verify_status" column will be added in this table.

TFA_WITH_TABLE=

For example, if you want to use "users" table for the 2FA functionality, then you have to specify like this in ".env" file.

TFA_WITH_TABLE=users

Run these commands to clear the cache and migrate the database.

php artisan config:clear
php artisan cache:clear
php artisan migrate

Basic Usage

# Initialize the namespace
use RaisulHridoy\Laravel2FA\Http\App\TFA;

Full instruction coming soon ...............