php-open-source-saver/jwt-auth
Laravel JWT authentication package (fork of tymondesigns/jwt-auth) maintained by PHP Open Source Saver. Provides the same API with a new namespace, easy migration, and adds new features and ongoing support. Full docs available online.
Auth::guard() system, supporting multi-guard setups (e.g., JWT + Session).Authenticated, Attempting, Failed), enabling observability and custom logic (e.g., logging, analytics).jwt.auth middleware for route protection, replacing auth:api in traditional setups.JWTGuard or AbstractServiceProvider for custom token claims/validation.roles, permissions) via payload configuration.cookie_key_name config).| Risk Area | Severity | Mitigation |
|---|---|---|
| Breaking Changes | Medium | Fork from tymon/jwt-auth introduces minor API shifts (e.g., JWTGuard constructor). Test thoroughly in staging. |
| Dependency Updates | Low | Dropped PHP 8.1 support; ensure CI/CD validates PHP 8.4+ compatibility. |
| Carbon Version Conflicts | Low | Supports Carbon 2/3; test with your app’s Carbon version. |
| Secret Key Management | High | Use Laravel’s env or Vault for secrets. Avoid hardcoding. |
| Token Revocation Latency | Medium | Redis blacklists reduce DB load; monitor getMinutesUntilExpired for performance. |
| Octane Edge Cases | Low | Test async request handling (e.g., token refresh races). |
Auth Flow Complexity:
Auth::guard('api')->attempt($credentials, true) vs. manual JWT generation.Scalability Needs:
blacklist_add/isBlacklisted latency.Compliance:
JWTAuthEvent listeners.auth.attempted events to a SIEM.Legacy Migration:
tymon/jwt-auth, test:
Auth::id() delegation (v2.6.0+).id claim fallback (v2.3.0+).Performance:
Auth::login()).Auth::invalidateBlacklistedTokens()).Auth, Events, and Middleware.Dependency Swap:
composer remove tymon/jwt-auth
composer require php-open-source-saver/jwt-auth
use Tymon\JWTAuth with use PHPOpenSourceSaver\JWTAuth.Config Updates:
php artisan vendor:publish --provider="PHPOpenSourceSaver\JWTAuth\Providers\LaravelServiceProvider".show_blacklist_exception (default: true).cookie_key_name (customize auth cookie name).iat_unchanged_on_refresh (v2.8.0+).Guard Initialization:
JWTGuard constructor if autodiscovery is disabled:
$guard = new JWTGuard($request, $app['auth'], $eventDispatcher);
Middleware:
auth:api with jwt.auth in app/Http/Kernel.php:
'api' => \PHPOpenSourceSaver\JWTAuth\Middleware\GetUserFromToken::class,
Testing:
Auth::login()).Auth::invalidateBlacklistedTokens()).| Component | Compatibility |
|---|---|
| Laravel 13 | ✅ Supported (v2.9.0+). |
| Laravel 12 | ✅ Supported (v2.8.0+). |
| Laravel 11 | ✅ Supported (v2.2.0+). |
| Lumen | ✅ Partial (use LumenServiceProvider). |
| Carbon 2/3 | ✅ Supported (v2.7.0+). |
| lcobucci/jwt 5.x | ✅ Required (v2.4.0+; dropped 4.x). |
| Redis | ✅ Recommended for blacklists. |
| Database Blacklists | ✅ Supported (MySQL/PostgreSQL). |
Phase 1: Core Integration (1–2 sprints)
Phase 2: Advanced Features (1 sprint)
roles).Phase 3: Optimization (Ongoing)
auth.attempted events.Phase 4: Security Hardening (1 sprint)
php artisan jwt:secret).lcobucci/jwt and Laravel version compatibility.php artisan jwt:secret to regenerate keys.// app/Console/Commands/CleanupBlacklist.php
public function handle() {
\PHPOpenSourceSaver\JWTAuth\Facades\JWTAuth::invalidateOldBlacklistedTokens(now()->subDays(30));
}
ttl config and iat claim handling.auth.attempted/auth.failed events.dd(\PHPOpenSourceSaver\JWTAuth\Facades\JWTAuth::getToken()) to inspect tokens.tymon/jwt-auth).How can I help you explore Laravel packages today?