gusmanwidodo / auth-kit-otp
One-time password (OTP) plugin for Auth-Kit. Adds /auth-kit/otp/* endpoints and a code store.
Requires
- php: ^8.3
- gusmanwidodo/auth-kit: ^0.1
- illuminate/contracts: ^12.0
- illuminate/support: ^12.0
Requires (Dev)
- orchestra/testbench: ^10.0
- pestphp/pest: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
README
One-time password (OTP) plugin for Auth-Kit. A standalone Composer package that plugs into the Auth-Kit core to add OTP issue/verify endpoints, a code store, and expiry enforcement via the core hook pipeline.
What it demonstrates
This package is the reference example of the Auth-Kit plugin model. It uses the full plugin surface as an independent package that only depends on the core:
HasSchema— ships theauth_kit_otp_codesmigrationHasRoutes— addsPOST /auth-kit/otp/issueandPOST /auth-kit/otp/verifyHasHooks— abefore:otp.verifyhook that rejects expired codes
Requirements
- PHP
^8.3 gusmanwidodo/auth-kit^0.1- Laravel 12
Installation
composer require gusmanwidodo/auth-kit-otp
Both the core and this plugin are auto-discovered. Run migrations to create the OTP table:
php artisan migrate
Optionally publish the config:
php artisan vendor:publish --tag=auth-kit-otp-config
Endpoints
| Method | URI | Body | Purpose |
|---|---|---|---|
| POST | /auth-kit/otp/issue |
{ identifier } |
Generate + store a hashed code |
| POST | /auth-kit/otp/verify |
{ identifier, code } |
Verify, running the hook pipeline |
In production, deliver the code via mail/SMS. The
codeis only returned in theissueresponse while running tests.
Config
config/auth-kit-otp.php:
'ttl' => 300, // seconds a code stays valid 'length' => 6, // number of digits
Developing against a local core
When both repos are checked out side by side, point Composer at the local core before installing:
composer config repositories.auth-kit path ../auth-kit
composer require gusmanwidodo/auth-kit:@dev
composer install
composer test
License
MIT © Gusman Widodo. See LICENSE.