alish/laravel-otp is a Laravel package for my awesome package.
It currently has 0 GitHub stars and 205 downloads on Packagist (latest version v0.2.5).
Install it with composer require alish/laravel-otp.
Discover more Laravel packages by alish
or browse all Laravel packages to compare alternatives.
Last updated
One-Time Password Authentication has gained noticeable popularity amongst software developers, due to its reliablity and ease of use. Using this module, you are able to embedd OTP to your Laravel project in a considerably straightforward manner. This Package is equipped with both Cache and Database drivers to provide developers with the freedom of choice, regarding the unit supposed to hold the OTP and other related information.
You can install the package via composer:
composer require alish/laravel-otp
for issuing new token for specific key:
$token = Otp::issue($key = "string");
to revoke token for specific key you can use:
$bool = Otp::revoke($key = 'string'); // return true if a valid provided key revoked
to check token against key:
$bool = Otp::check($key = 'string', $token = 'already issued token'); // if key and token match return true
if you want to use otp generated token (it means check provided key, token then revoke if it matches) you can:
$bool = Otp::use($key = 'string', $token = 'already issued token'); // return true if provided key, token match
Keep in mind that if database driver is your preferred choice, you are supposed to publish migrations file first:
php artisan vendor:publish --provider="Alish\LaravelOtp\OtpServiceProvider" --tag=migrations
then run your migrations with
php artisan migrate
In order to be able to adjust the configuration of this package, you are supposed to publish your configurations using the following command:
php artisan vendor:publish --provider="Alish\LaravelOtp\OtpServiceProvider" --tag=config
default: Using this value, you are able to modify the default method to store the OTP and other related information.
type: This variable determines the type of the characters included in the OTP. Choices are alpha, alphanumeric, numeric and strong (include special characters).
length: By changing this variable, you are able to determine the number of the characters that OTP has.
case-sensitive: Using this variable, you are able to control the sensitivity of the package to case sensitivity.
custom': Pass the set of the characters you want to create your custom OTPs from as a simple string (eg: "1234") to this variable.
timeout: This variable determines the time (in seconds), which the token is active to use. To set a token active permenantly, set timeout to null.
hash: Using this variable, you are able to determine if the token should be hashed or not.
unique: Using this variable, you are able to revoke all generated tokens after creating a new one, for a specific key. This functionality is only available for Database Driver.
composer test
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
This package was generated using the Laravel Package Boilerplate.