akira/laravel-auth-logs

Track, query, and act on authentication activity in your Laravel application. Automatically records successful and failed sign-ins, with optional notifications and geolocation context.

Maintainers

Package info

github.com/akira-io/laravel-auth-logs

pkg:composer/akira/laravel-auth-logs

Transparency log

Fund package maintenance!

Akira

Statistics

Installs: 3 072

Dependents: 0

Suggesters: 0

Stars: 6

Open Issues: 0

v1.2.0 2026-06-26 12:34 UTC

This package is auto-updated.

Last update: 2026-07-02 23:43:24 UTC


README

Laravel Authentication Logs

Latest Version on Packagist Total Downloads PHPStan Level License img.png

Laravel Authentication Logs records authentication activity for Laravel applications. It listens to Laravel authentication events, stores request context in a polymorphic log table, and sends mail notifications for security-relevant events.

Features

  • Records successful login attempts.
  • Records failed login attempts when Laravel provides a user instance.
  • Marks the latest authentication log as logged out on user logout.
  • Detects new devices by successful login history for the same IP address and user agent.
  • Sends queued mail notifications for failed login and new device login events.
  • Resolves optional geolocation context for notification messages.
  • Supports configurable table name, database connection, events, listeners, templates, notification toggles, and retention value.

The package also subscribes to Laravel's OtherDeviceLogout event as a customization hook. The default listener does not write a log entry.

Requirements

  • PHP 8.4 or higher
  • Laravel 12.0 or 13.0
  • An authenticatable model that uses Laravel notifications

The test workflow validates both Laravel 12 and Laravel 13 dependency sets.

Installation

Install the package with Composer:

composer require akira/laravel-auth-logs

Publish the configuration and migration:

php artisan auth-logs:install
php artisan migrate

Add the AuthLogs trait to your authenticatable model:

use Akira\LaravelAuthLogs\Concerns\AuthLogs;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

class User extends Authenticatable
{
    use Notifiable, AuthLogs;
}

Documentation

Full documentation is available under docs/:

Testing

composer test

The full gate runs Pint, Rector dry-run, PHPStan, Pest type coverage, and Pest coverage.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.