Download the PHP package benbjurstrom/otpz without Composer
On this page you can find all versions of the php package benbjurstrom/otpz. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download benbjurstrom/otpz
More information about benbjurstrom/otpz
Files in benbjurstrom/otpz
Package otpz
Short Description First Factor One-Time Passwords for Laravel (Passwordless OTP Login)
License MIT
Homepage https://github.com/benbjurstrom/otpz
Informations about the package otpz
First Factor One-Time Passwords for Laravel
This package provides secure first factor one-time passwords (OTPs) for Laravel applications. Users enter their email and receive a one-time code to sign in—no passwords required.
Features
- ✅ Session-locked - OTPs only work in the browser session that requested them
- ✅ Rate-limited - Configurable throttling with multi-tier limits
- ✅ Time-based expiration - Default 5 minutes, fully configurable
- ✅ Invalidated after first use - One-time use only
- ✅ Attempt limiting - Invalidated after 3 failed attempts
- ✅ Signed URLs - Cryptographic signature validation
- ✅ Detailed error messages - Clear feedback for users
- ✅ Customizable templates - Bring your own email design
- ✅ Auditable - Full event logging via Laravel events
Quick Start
Prerequisites
OTPz works best with the official Laravel starter kits:
- React (Inertia.js)
- Vue (Inertia.js)
- Livewire (Volt)
OTPz's frontend components are designed to work out of the box with the Laravel starter kits and make use of their existing UI components (Button, Input, Label, etc.). Because these components are installed into your application you are free to customize them for any Laravel application using React, Vue, or Livewire.
Installation
1. Install the Package
2. Run Migrations
3. Add Interface and Trait to User Model
Framework-Specific Setup
Choose your frontend framework:
React (Inertia.js)
1. Publish Components
This copies the following files to your application:
resources/js/pages/auth/otpz-login.tsx- Email entry pageresources/js/pages/auth/otpz-verify.tsx- OTP code entry pageapp/Http/Controllers/Auth/OtpzController.php- Self-contained controller handling all OTP logic
Note: These components import shadcn/ui components (
Button,Input,Label,Checkbox), layout components (AuthLayout), and use wayfinder for route generation from the Laravel React starter kit. If you're not using the starter kit, you may need to adjust these imports or create these components.
2. Add Routes
Add to routes/web.php:
That's it! The controller handles all the OTP logic for you.
Vue (Inertia.js)
1. Publish Components
This copies the following files to your application:
resources/js/pages/auth/OtpzLogin.vue- Email entry pageresources/js/pages/auth/OtpzVerify.vue- OTP code entry pageapp/Http/Controllers/Auth/OtpzController.php- Self-contained controller handling all OTP logic
Note: These components import layout components (
AuthLayout), and use wayfinder for route generation from the Laravel Vue starter kit. If you're not using the starter kit, you may need to adjust these imports or create these components.
2. Add Routes
Add to routes/web.php:
That's it! The controller handles all the OTP logic for you.
Livewire (Volt)
1. Publish Components
This copies the following files to your application:
resources/views/livewire/auth/otpz-login.blade.php- Email entry pageresources/views/livewire/auth/otpz-verify.blade.php- OTP code entry pageapp/Http/Controllers/Auth/PostOtpController.php- Self-contained controller handling OTP verification
Note: These Volt components use Flux UI components and layout components from the Laravel Livewire starter kit. If you're not using the starter kit, you may need to adjust the component markup and styling.
2. Add Routes
Add to routes/web.php:
Replacing Fortify Login (Optional)
The latest Laravel starter kits use Laravel Fortify for authentication. If you want to replace the default username/password login with OTPz:
For React:
In app/Providers/FortifyServiceProvider.php, update the loginView method:
For Vue:
In app/Providers/FortifyServiceProvider.php, update the loginView method:
For Livewire:
In app/Providers/FortifyServiceProvider.php, comment out the default login view:
Then in routes/web.php, update the OTPz route to use login:
Now when users visit /login or are redirected to the login page, they'll see the OTPz email entry form instead of the traditional username/password form.
Configuration
Publish Configuration File (Optional)
This is the contents of the published config file:
7. (Optional) Publish the translations file
This package publishes the translations file:
Customization
Email Templates
Publish the email templates to customize styling:
This publishes:
Switch between templates in config/otpz.php:
Custom User Resolution
By default, OTPz creates new users when an email doesn't exist. You can customize this behavior by creating your own user resolver and registering it in the config. In this example we throw a validation error if a user with the given email address does not exist.
Update config/otpz.php:
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Ben Bjurstrom
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of otpz with dependencies
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^10.0||^11.0||^12.0||^13.0