yadahan/laravel-authentication-log
AuthenticatesUsers trait) without requiring custom middleware or event listeners.AuthLog model is Eloquent-based, enabling custom queries (e.g., filtering by IP, user agent, or status).illuminate/notifications).AuthLogEvent or override logAuthentication in the service provider.auth.logged-in/auth.logged-out events.auth_logs table by extending the AuthLog model or using a custom connection (e.g., PostgreSQL JSONB).auth.attempting).session_id, mfa_status) required?status, user_id) suffice, or is Elasticsearch needed?Auth::attempt(), Auth::login()). Works with:
Illuminate\Auth\AuthenticatesUsers.AuthLogServiceProvider to support API tokens, SSO, etc.auth.failed, auth.logout).composer require yadahan/laravel-authentication-log
php artisan vendor:publish --provider="Yadahan\AuthenticationLog\AuthenticationLogServiceProvider"
php artisan migrate
user_agent for privacy).// app/Providers/EventServiceProvider.php
protected $listen = [
'auth.logged-in' => [
'App\Notifications\AdminLoginNotification',
],
];
\Yadahan\AuthenticationLog\Models\AuthLog::latest()->take(5)->get();
| Component | Compatibility | Mitigation |
|---|---|---|
| Laravel Version | 5.5+ (tested up to 10.x) | Use ^ in composer.json for flexibility. |
| PHP Version | 7.0+ (8.0+ recommended) | Update PHP if using legacy versions. |
| Database | MySQL, PostgreSQL, SQLite (via Eloquent) | No issues; ensure DB supports JSON fields. |
| Auth Systems | Default auth, API tokens (if events are fired) | Extend AuthLogServiceProvider for custom guards. |
| Notification Channels | Mail, Slack, etc. (via Laravel Notifications) | Use existing channel drivers. |
| Caching | No direct impact, but log queries may benefit from caching. | Add remember() to frequent queries. |
authenticate).auth_logs table for performance.geolocation via IP API).auth_logs table growth; consider partitioning for large datasets.auth_logs.auth.attempting).select(*)).auth.attempting listener) for high traffic.user_id, status, and created_at.SoftDeletes or a cron job.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Database downtime | Lost logs during outage. | Queue logs with fallback to file storage. |
| Notification channel failure | Unnoticed security events. | Implement retry logic (e.g., Notifiable trait). |
| Auth system changes (Laravel) | Package breaks |
How can I help you explore Laravel packages today?