comes/simpleauthenticator

A PHP library for implementing Google Authenticator's two-factor authentication (2FA) with Laravel, ensuring enhanced security for user authentication.
10,194
Install
composer require comes/simpleauthenticator
Latest Version:v2.1
PHP:^8.3
Laravel:12
Older releases:10 · 11
License:MIT
Last Updated:Jan 12, 2026
Links: GitHub  ·  Packagist
Maintainer: comes

This is a simple implementation of the google authenticator algorithm

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.

Related Packages

sicaboy/laravel-mfa

A Laravel package of Multi-factor Authentication (MFA/2FA) with a middleware.

1,321 11
artisanpack-ui/security-auth

Authentication security for Laravel — two-factor authentication (email/TOTP), pa...

3,301 0
salehye/laravel-security

🔥 Advanced Security Package for Laravel 12 - The most comprehensive security so...

5 0
restricted/authchain

Laravel 4 chain authentication (LDAP, IMAP, IP, Eloquent)

101 5
pragmarx/google2fa

A One Time Password Authentication package, compatible with Google Authenticator...

125,040,435 2,011

Version History

Version Released PHP Laravel License
v2.1 ^8.3 ^12.0 MIT
v2.0.1 ^8.3 ^11.0 MIT
v2.0.0 ^8.1 ^10.0 MIT
v1.0.0 ^8.1 ^10.0 MIT