Download the PHP package spykapps/passwordless-login without Composer
On this page you can find all versions of the php package spykapps/passwordless-login. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download spykapps/passwordless-login
More information about spykapps/passwordless-login
Files in spykapps/passwordless-login
Package passwordless-login
Short Description A highly customizable, multilingual magic link (passwordless) authentication package for Laravel with bot detection, rate limiting, and comprehensive event system.
License MIT
Homepage https://github.com/spykapps/passwordless-login
Informations about the package passwordless-login
Passwordless Login for Laravel
A highly customizable, multilingual magic link authentication package for Laravel with bot/prefetch detection, rate limiting, conditional auth, and a comprehensive event system.
Features
- ๐ Magic Link Authentication : Secure, token-based passwordless login
- ๐ค Bot/Prefetch Detection : Detects Outlook, Apple Mail, SafeLinks and other prefetch scanners that consume one-time links
- ๐ Multilingual : Full i18n support with publishable language files
- ๐ Configurable Token Security : Token length, hashing algorithm (SHA-256, bcrypt, argon2), IP/UA binding
- ๐ Usage Control : One-time, multi-use, or unlimited use links
- ๐ฆ Rate Limiting : Built-in throttling per user
- ๐ง Built-in Email Notification : Laravel-style notification (like password reset) with queuing support
- ๐ Conditional Authentication : Allow login only when custom conditions are met (e.g.
is_active,!is_banned) - ๐ฏ After Login Actions : Run custom code after authentication
- ๐ก Comprehensive Events : 8 events covering the full lifecycle
- โ๏ธ Everything Configurable : Guard, model, table, routes, expiry, views, redirect, and more
- ๐งน Auto Cleanup : Scheduled cleanup of expired tokens
Requirements
- PHP 8.1+
- Laravel 10, 11, 12, or 13
Installation
Publish Config
Publish & Run Migrations
Publish Everything (optional)
This publishes config, migrations, views, and language files.
Upgrading from a Previous Version
If you already have the package installed and a passwordless_login_tokens table in your database, run the upgrade command to apply new schema changes introduced in this version (such as the failure_url column):
The command will:
- Ask for your tokens table name (defaults to
passwordless_login_tokens, or whatever is set in your config) - Show a disclaimer listing every column it intends to add
- Ask for confirmation before touching your database
- Add any missing columns โ safely skipping columns that already exist
The upgrade command is non-destructive and idempotent โ it only adds new nullable columns and is safe to run multiple times.
Quick Start
1. Add the Trait to Your User Model
2. Send a Magic Link
3. That's It!
The package automatically:
- Registers the magic login route
- Handles bot/prefetch detection
- Authenticates the user
- Redirects to your configured URL
Usage Examples
Basic Usage
Fluent Builder (Full Customization)
Using the Trait
Get URL Without Sending Email
Possible ways to generate URLs
Configuration
All options in config/passwordless-login.php:
| Option | Default | Description |
|---|---|---|
user_model |
App\Models\User |
The authenticatable model |
email_column |
email |
Column used to find users by email |
guard |
null (default) |
Authentication guard |
remember |
false |
Remember me flag |
token.length |
32 |
Token byte length (16โ128) |
token.hash_algorithm |
sha256 |
sha256, bcrypt, or argon2 |
expiry_minutes |
15 |
Minutes until link expires |
max_uses |
1 |
Max times a link can be used (null = unlimited) |
route.path |
/magic-login/{token} |
The magic link route path |
route.name |
passwordless.login |
Route name |
route.middleware |
['web', 'guest'] |
Route middleware |
route.prefix |
'' |
Route prefix |
redirect.on_success |
/dashboard |
Redirect after login |
redirect.on_failure |
/login |
Redirect on failure |
throttle.enabled |
true |
Rate limiting |
throttle.max_attempts |
5 |
Max links per decay period |
throttle.decay_minutes |
10 |
Rate limit window |
bot_detection.enabled |
true |
Bot/prefetch detection |
bot_detection.strategy |
both |
confirmation_page, javascript, or both |
notification.enabled |
true |
Auto-send email |
notification.queue |
false |
Queue the notification |
notification.class |
built-in | Custom notification class |
notification.mailable |
null |
Use a Mailable instead |
conditions |
[] |
Callables/classes that must return true |
after_login_action |
null |
Action to run after login |
table |
passwordless_login_tokens |
Database table name |
security.invalidate_previous |
true |
Invalidate old tokens on new generate |
security.invalidate_on_login |
true |
Invalidate all tokens after login |
security.ip_binding |
false |
Bind link to requester's IP |
security.user_agent_binding |
false |
Bind link to requester's UA |
security.audit_log |
true |
Log all activity |
Bot/Prefetch Detection
Email clients like Outlook, Apple Mail, and security scanners like SafeLinks and Barracuda often visit links before the user clicks them. This can consume one-time magic links.
How It Works
The package uses a multi-layered detection approach:
- User-Agent Detection โ Matches known bot/scanner patterns
- HTTP Method Detection โ Bots often use HEAD/OPTIONS requests
- Prefetch Header Detection โ Checks
X-Purpose,Sec-Purpose,Sec-Fetch-Destheaders - Suspicious Header Analysis โ Flags requests without browser-typical headers
Strategies
confirmation_pageโ Shows a "Click to continue" button (most compatible)javascriptโ Auto-redirects via JS (bots can't execute JS)bothโ JS auto-redirect with a button fallback (recommended)
Conditional Authentication
Restrict who can log in with custom conditions:
Custom Condition Class
After Login Actions
Run custom code after successful authentication:
Events
| Event | Dispatched When | Payload |
|---|---|---|
MagicLinkGenerated |
Link is created | $user, $token, $url, $ipAddress |
MagicLinkSent |
Notification/email sent | $user, $channel |
MagicLinkClicked |
Link URL is visited | $tokenModel, $request, $isBotDetected |
MagicLinkAuthenticated |
User successfully logged in | $user, $request, $guard |
MagicLinkFailed |
Authentication failed | $reason, $request, $token, $ipAddress |
MagicLinkExpired |
Expired link accessed | $tokenModel, $request |
MagicLinkUsed |
Token use count incremented | $tokenModel, $request |
MagicLinkThrottled |
Rate limit exceeded | $user, $availableInSeconds |
BotDetected |
Bot/prefetch detected | $request, $reason, $token |
Listening to Events
Multilingual Support
Publish the language files:
This creates lang/vendor/passwordless-login/en/messages.php. Add translations by creating new locale folders (e.g. es/messages.php, fr/messages.php, de/messages.php).
Example: Spanish Translation
Custom Notification / Mailable
Custom Notification
Your notification receives: $url, $expiryMinutes, $metadata.
Custom Mailable
Your mailable receives: $url, $expiryMinutes in the constructor.
Custom Views
Publish and customize views:
Published to resources/views/vendor/passwordless-login/:
confirmation.blade.phpโ Bot detection confirmation pageemails/magic-link.blade.phpโ Email template (markdown)
API / JSON Support
The controller automatically returns JSON when Accept: application/json is sent:
Success:
Failure:
Security Best Practices
- Don't reveal user existence โ Use
link_sent_if_existsmessage - Keep expiry short โ 15 minutes is a good default
- Use one-time links โ Set
max_usesto 1 - Enable
invalidate_previousโ Only the latest link works - Enable
invalidate_on_loginโ All links consumed after login - Consider IP binding for high-security applications
Credits
- Sanchit Patil
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of passwordless-login with dependencies
illuminate/contracts Version ^10.0|^11.0|^12.0|^13.0
illuminate/database Version ^10.0|^11.0|^12.0|^13.0
illuminate/http Version ^10.0|^11.0|^12.0|^13.0
illuminate/mail Version ^10.0|^11.0|^12.0|^13.0
illuminate/notifications Version ^10.0|^11.0|^12.0|^13.0
illuminate/routing Version ^10.0|^11.0|^12.0|^13.0
illuminate/support Version ^10.0|^11.0|^12.0|^13.0