comes/simpleauthenticator

A PHP library for implementing Google Authenticator's two-factor authentication (2FA) with Laravel, ensuring enhanced security for user authentication.

v2.0.0 2023-05-19 06:46 UTC

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

The SimpleAuthenticator package provides a straightforward implementation of the Google Authenticator algorithm for Laravel applications. It enables easy generation of one-time passwords (OTPs) based on a provided secret key.

Read more about the Google Authenticator algorithm in the RFC 6238 or check wikipedia TOTP

Usage

To use the SimpleAuthenticator, create an instance of the SimpleAuthenticator class by providing the secret key. Then, you can call the generate() method to generate the one-time password.

use Comes\SimpleAuthenticator\SimpleAuthenticator;

$secret = 'YOUR_SECRET_KEY';
$authenticator = new SimpleAuthenticator;
$oneTimePassword = $authenticator->generate($secret);

Laravel Integration

The SimpleAuthenticator package provides a Laravel command to generate OTPs. To use it, you need to publish the package configuration and add the secret keys to the configuration file.

php artisan vendor:publish --provider="Comes\SimpleAuthenticator\SimpleAuthenticatorServiceProvider" --tag="config"

After publishing the configuration, you can add your secret keys to the config/simpleauthenticator.php file. Then, you can use the otp command to generate an OTP for a specific app:

php artisan otp app-name

Testing

Testing

You can run the tests using Pest:

composer test
composer test-coverage

Changelog

Please see the Latest Release for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Credits

License

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