Skip to content

Hennest/two-factor

Repository files navigation

Two-Factor Authentication

This package provides a robust two-factor authentication (2FA) solution for Laravel applications using Google Authenticator.

Installation

Install the package via Composer:

composer require hennest/two-factor

Configuration

Publish the configuration file:

php artisan vendor:publish --tag=two-factor-config

This will create a config/two-factor.php file. Adjust the settings as needed.

Database Migrations

Publish and run the migrations:

php artisan vendor:publish --tag=two-factor-migrations
php artisan migrate

Usage

Setup

  1. Add the HasTwoFactorAuthentication trait to your User model:
use Hennest\TwoFactor\Traits\HasTwoFactorAuthentication;

class User extends Authenticatable
{
    use HasTwoFactorAuthentication;
    
    // ...
}

Customization

Views

Publish the views to customize them:

php artisan vendor:publish --tag=two-factor-views

Translations

Publish the language files to customize messages:

php artisan vendor:publish --tag=two-factor-lang

Contributing

Please see CONTRIBUTING.md for details.

License

The MIT License (MIT). Please see License File for more information.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This library is open-sourced software licensed under the MIT license.