Session facade, Auth contract, and middleware-based auth).auth:throttle or custom middleware may already address this.SessionRegistryExpirationListener leverages Symfony’s event system (kernel.response), which Laravel replaces with its own event system (e.g., Illuminate\Events). This requires abstraction or wrapper logic.AuthenticationStrategy. Integration would require:
kernel.response (e.g., Illuminate\Http\Kernel::terminate).SessionInterface with Laravel’s Session or Request objects.file, database, redis) would need compatibility checks or normalization.Why Not Laravel Native?
auth:throttle or custom middleware not suffice? If so, what gaps does this package fill?spatie/laravel-activitylog, laravel/sanctum) that already handle concurrent sessions?Session Storage Compatibility
database or redis drivers?Event System Integration
kernel.response event be mapped to Laravel’s event system? Are there existing Laravel packages (e.g., spatie/laravel-event-scheduler) that can help?SessionRegistryExpirationListener fires at the wrong time in Laravel’s request lifecycle?Testing and Validation
Alternatives
Illuminate\Session\Store, Illuminate\Auth\Events)?nwidart/laravel-modules) that already solve this?AuthenticationStrategy with Laravel middleware (e.g., HandleConcurrentSessions) that:
SessionInterface (e.g., via Illuminate\Contracts\Session\Session adapter).kernel.response with Laravel’s terminate or Illuminate\Auth\Events\Attempting/Authenticated events.user_id, session_count, last_activity).Session facade to read/write session data, but normalize it for the package’s expectations.Authenticating, Validating middleware).SessionInterface (e.g., LaravelSessionAdapter).Authenticate).Illuminate\Auth\Events\Authenticated to track active sessions.Illuminate\Session\Events\Starting to validate concurrency on session start.symfony/security-core). Use composer require symfony/security-core and configure Laravel’s autoloader to avoid conflicts.redis or database drivers for shared session storage across instances.file driver for production due to race conditions in concurrency checks.telescope or custom dashboard).terminate vs. kernel.response).SELECT/UPDATE queries for session counts could degrade performance under high load. Mitigate with:
| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Session data corruption | False session expiration/duplication | Use transactions for session updates. |
| Database connection loss | Sessions locked or expired prematurely | Implement retry logic with exponential backoff. |
| Event listener not triggered | Concurrent sessions not validated | Add health checks for critical events. |
| Cache invalidation issues | Stale session counts | Short TTL for cached session data. |
| Middleware bypass | Unauthorized concurrent sessions | Validate middleware order in app/Http/Kernel.php. |
| Symfony component version conflict | Package breaks due to dependency issues | Pin Symfony versions in composer.json. |
How can I help you explore Laravel packages today?