vkoori/laravel-stateless-auth

There is no license information available for the latest version (0.1.3) of this package.

Stateless authentication for Laravel using JWT (JSON Web Tokens). This package enables secure, token-based authentication for API endpoints.

0.1.3 2025-07-18 17:46 UTC

This package is auto-updated.

Last update: 2025-07-18 17:46:43 UTC


README

A fully stateless JWT authentication guard and provider for Laravel.
Supports access/refresh tokens, automatic cookie injection, multi-source token parsing (header, query, cookie), and token revocation.

✨ Features

  • 🔐 Custom Laravel guard + provider (fully stateless)
  • ♻️ Refresh token support
  • 🍪 Cookie-based tokens (HttpOnly, optional)
  • 📩 Header / Query string token support
  • 🔄 Token revocation
  • 💡 Simple trait-based token issuing
  • ⚡️ Octane-ready

📦 Installation

composer require vkoori/laravel-stateless-auth

⚙️ Configuration

Publish the config file:

php artisan vendor:publish --provider="Vkoori\JwtAuth\AuthServiceProvider" --tag=jwt-guard

This will publish config/jwt-guard.php.

also read optionally

🛡 Register the Guard & Provider

In your config/auth.php:

'guards' => [
    'api' => [
        'driver' => 'jwt-auth',
        'provider' => 'jwt-users',
    ],
],

'providers' => [
    'jwt-users' => [
        'driver' => 'jwt-auth-provider',
        'model' => App\Models\User::class,
    ],
],

👤 Token Support on User Model

Your User model must use the provided trait:

use Vkoori\JwtAuth\Auth\Traits\HasApiTokens;

class User extends Authenticatable
{
    use HasApiTokens;
}