PHPackages                             haikallfiqih/laravel-magic-auth - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. haikallfiqih/laravel-magic-auth

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

haikallfiqih/laravel-magic-auth
===============================

A secure passwordless authentication package using magic links

v1.0.0(1y ago)13MITPHPPHP ^8.0

Since Dec 2Pushed 1y ago1 watchersCompare

[ Source](https://github.com/haikallfiqih/laravel-magic-auth)[ Packagist](https://packagist.org/packages/haikallfiqih/laravel-magic-auth)[ RSS](/packages/haikallfiqih-laravel-magic-auth/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

Laravel Magic Auth
==================

[](#laravel-magic-auth)

A secure, flexible passwordless authentication package for Laravel using magic links. Supports multiple notification channels including email, WhatsApp, and SMS.

Features
--------

[](#features)

- 🔐 Secure passwordless authentication
- 📧 Multi-channel notifications (Email, WhatsApp, SMS)
- ⚡ Easy integration with Laravel's authentication system
- 🛡️ Rate limiting and link expiration
- 🔄 Event-driven architecture
- 🎨 Customizable templates and messages
- 🚦 Multiple guard support

Installation
------------

[](#installation)

```
composer require haikallfiqih/laravel-magic-auth
```

### Configuration

[](#configuration)

1. Publish the configuration and migrations:

```
php artisan vendor:publish --provider="LaravelLinkAuth\MagicAuth\MagicAuthServiceProvider"
```

2. Run the migrations:

```
php artisan migrate
```

3. Add these environment variables to your `.env` file:

```
# For Email (default)
MAIL_FROM_ADDRESS=noreply@example.com
MAIL_FROM_NAME="Your App Name"

# For WhatsApp/SMS (optional)
MAGIC_AUTH_WHATSAPP_PROVIDER=twilio
MAGIC_AUTH_WHATSAPP_FROM=+1234567890
MAGIC_AUTH_SMS_FROM=+1234567890
TWILIO_SID=your-twilio-sid
TWILIO_TOKEN=your-twilio-token
```

Basic Usage
-----------

[](#basic-usage)

### Sending Magic Links

[](#sending-magic-links)

```
use LaravelLinkAuth\MagicAuth\Facades\MagicAuth;

// Send via email (default)
MagicAuth::sendMagicLink('user@example.com');

// Send via WhatsApp
MagicAuth::sendMagicLink('+1234567890', 'web', [], ['whatsapp']);

// Send via SMS
MagicAuth::sendMagicLink('+1234567890', 'web', [], ['sms']);

// With custom attributes for new users
MagicAuth::sendMagicLink('user@example.com', 'web', [
    'name' => 'John Doe',
    'company_id' => 1
]);
```

### Route Configuration

[](#route-configuration)

Add these routes to your `web.php`:

```
use LaravelLinkAuth\MagicAuth\Http\Controllers\MagicAuthController;

Route::post('/magic-link', [MagicAuthController::class, 'sendMagicLink'])
    ->name('magic-auth.send');

Route::get('/auth/verify', [MagicAuthController::class, 'verify'])
    ->name('magic-auth.verify')
    ->middleware('signed');
```

### Event Handling

[](#event-handling)

```
use LaravelLinkAuth\MagicAuth\Facades\Events;
use LaravelLinkAuth\MagicAuth\Events\MagicAuthEvents;

// Before generating a magic link
Events::listen(MagicAuthEvents::GENERATING, function ($notifiable, $guard, $attributes) {
    // Validate or modify attributes
});

// After sending a magic link
Events::listen(MagicAuthEvents::SENT, function ($notifiable, $guard, $linkId) {
    // Log or track magic link usage
});

// When verification succeeds
Events::listen(MagicAuthEvents::VERIFICATION_COMPLETED, function ($user, $guard) {
    // Handle successful login
});
```

WhatsApp/SMS Integration
------------------------

[](#whatsappsms-integration)

To use WhatsApp or SMS notifications:

1. Install Twilio SDK:

```
composer require twilio/sdk
```

2. Configure your Twilio credentials in `.env`:

```
TWILIO_SID=your-twilio-sid
TWILIO_TOKEN=your-twilio-token
MAGIC_AUTH_WHATSAPP_FROM=+1234567890
MAGIC_AUTH_SMS_FROM=+1234567890
```

Configuration Options
---------------------

[](#configuration-options)

```
return [
    // Link expiration time in minutes
    'expires' => 15,

    // Authentication guards configuration
    'guards' => [
        'web' => [
            'provider' => 'users',
            'model' => \App\Models\User::class,
            'redirect_on_success' => '/dashboard',
        ],
    ],

    // Rate limiting settings
    'throttle' => [
        'max_attempts' => 5,
        'decay_minutes' => 10,
    ],

    // Available notification channels
    'channels' => [
        'default' => ['mail'],
        'available' => ['mail', 'whatsapp', 'sms'],
    ],
];
```

Security
--------

[](#security)

- Links are single-use and expire after a configurable time
- Rate limiting prevents abuse
- Signed URLs prevent tampering
- Automatic cleanup of expired links

Testing
-------

[](#testing)

```
composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Haikal Fiqih](https://github.com/haikallfiqih)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

527d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/85f7db4f3ea9a07e03cb2443fa3f021853c846cbfcf6cd7cf771cbb29dc092d2?d=identicon)[haikallfiqih](/maintainers/haikallfiqih)

---

Top Contributors

[![haikallfiqih](https://avatars.githubusercontent.com/u/92772661?v=4)](https://github.com/haikallfiqih "haikallfiqih (6 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/haikallfiqih-laravel-magic-auth/health.svg)

```
[![Health](https://phpackages.com/badges/haikallfiqih-laravel-magic-auth/health.svg)](https://phpackages.com/packages/haikallfiqih-laravel-magic-auth)
```

###  Alternatives

[lab404/laravel-impersonate

Laravel Impersonate is a plugin that allows to you to authenticate as your users.

2.3k16.4M48](/packages/lab404-laravel-impersonate)[santigarcor/laratrust

This package provides a flexible way to add Role-based Permissions to Laravel

2.3k5.4M43](/packages/santigarcor-laratrust)[overtrue/laravel-follow

User follow unfollow system for Laravel.

1.2k404.7k5](/packages/overtrue-laravel-follow)[codegreencreative/laravel-samlidp

Make your PHP Laravel application an Identification Provider using SAML 2.0. This package allows you to implement your own Identification Provider (idP) using the SAML 2.0 standard to be used with supporting SAML 2.0 Service Providers (SP).

263763.5k1](/packages/codegreencreative-laravel-samlidp)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
