New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

nathandunn/laravel-auth-history

Reusable authentication history logging for Laravel.
5,186

Larablocks Analysis

nathandunn/laravel-auth-history works with Laravel 11, 12 and 13 (latest release v1.0.0, Aug 9, 2026).

Recommendation checks

Solid choice

Solid choice: maintained and up to date, meets 2 of 4 checks; below the bar for Recommended on use.

  • Works with Laravel 13, the current version
  • Released in the last 12 months (Aug 9, 2026)
  • 2,513 downloads a month (needs 10,000)
  • 0 GitHub stars (needs 100)

State

Maintained
  • Last stable release: Aug 9, 2026.
  • 1 release in the last 12 months.
  • First released: Aug 9, 2026.
  • Monthly downloads: 2,513.
  • 0 open issues on GitHub.

Data from Packagist and GitHub, checked by Larablocks on Nov 28, 2026.

Install
composer require nathandunn/laravel-auth-history
Latest Version:v1.0.0
PHP:^8.2
Laravel:11 · 12 · 13
License:MIT
Last Updated:Aug 9, 2026
Links: GitHub  ·  Packagist
Maintainer: nathandunn

Laravel Auth History

Reusable authentication history logging for Laravel 11–13.

The package listens to Laravel's login, logout, and failed-login events. It records the authenticatable model, guard, IP address, user agent, and timestamp without coupling to an application's User class.

Installation

composer require nathandunn/laravel-auth-history

php artisan vendor:publish --tag=auth-history-migrations
php artisan migrate

Laravel discovers the package service provider automatically.

Model integration

Add HasAuthHistory to any Eloquent authenticatable model:

use Illuminate\Foundation\Auth\User as Authenticatable;
use NathanDunn\AuthHistory\Traits\HasAuthHistory;

class User extends Authenticatable
{
    use HasAuthHistory;
}

Login, logout, and failed-login events for that model are now recorded automatically. Failed attempts without a resolved authenticatable are skipped.

Querying history

$history = $user->authHistories()
    ->with(['ipAddress', 'userAgent'])
    ->paginate();

$latestLogin = $user->authHistories()
    ->where('event', 'login')
    ->first();

$countryCode = $latestLogin?->ipAddress?->country_code;
$userAgent = $latestLogin?->userAgent?->user_agent;

IP addresses and user agents are stored once and reused across history records.

Optional IP enrichment

IP enrichment is disabled by default. Publish the configuration and enable IPinfo Lite:

php artisan vendor:publish --tag=auth-history-config
// config/auth-history.php
'ip_enrichment' => [
    'enabled' => true,
    'driver' => 'ipinfo',
    'token' => env('IPINFO_TOKEN'),
],
IPINFO_TOKEN=your-token

Only country code, ASN, and organisation name are stored. A lookup occurs only when an IP address is first discovered. Missing configuration, failed requests, and unavailable providers never prevent authentication history from being recorded.

To use another provider, implement NathanDunn\AuthHistory\Contracts\IpAddressEnricher and set its class as the driver:

'driver' => App\Auth\CustomIpAddressEnricher::class,

Configuration

Set enabled to false in config/auth-history.php to stop registering the authentication event listeners. Model classes can also be replaced under the models configuration key.

Testing

composer test
composer format-test

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

670,032,257 9,703
laravel/framework

The Laravel Framework.

640,572,096 35,338
laravel/tinker

Powerful REPL for the Laravel framework.

546,909,908 7,440
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

465,816,364 607
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

431,187,642 4,660

Version History

Version Released PHP Laravel License
v1.0.0 ^8.2 ^11.0|^12.0|^13.0 MIT