comes / simpleauthenticator
A PHP library for implementing Google Authenticator's two-factor authentication (2FA) with Laravel, ensuring enhanced security for user authentication.
Installs: 4 947
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 3
Requires
- php: ^8.1
- illuminate/contracts: ^10.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.9
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^8.0
- pestphp/pest: ^2.0
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
This package is auto-updated.
Last update: 2024-05-09 05:20:05 UTC
README
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.