PHPackages                             siberfx/authentication-logger - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. siberfx/authentication-logger

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

siberfx/authentication-logger
=============================

Log user authentication details and send new device notifications.

6.1.2(1mo ago)50MITPHPPHP ^8.2|^8.3|^8.4CI passing

Since Oct 13Pushed 1mo agoCompare

[ Source](https://github.com/siberfx/authentication-logger)[ Packagist](https://packagist.org/packages/siberfx/authentication-logger)[ Docs](https://github.com/siberfx/authentication-logger)[ GitHub Sponsors](https://github.com/rappasoft)[ RSS](/packages/siberfx-authentication-logger/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (14)Used By (0)

Authentication Logger is a package which tracks your user's authentication information such as login/logout time, IP, Browser, Location, etc. as well as sends out notifications via mail, slack, or sms for new devices and failed logins.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require siberfx/authentication-logger
```

If you want the location features you must also install `torann/geoip`:

```
composer require torann/geoip
```

You can publish and run the migrations with:

```
php artisan vendor:publish --provider="Siberfx\AuthenticationLogger\AuthenticationLogServiceProviderger" --tag="authentication-log-migrations"
php artisan migrate
```

You can publish the view/email files with:

```
php artisan vendor:publish --provider="Siberfx\AuthenticationLogger\AuthenticationLogServiceProviderger" --tag="authentication-log-views"
```

You can publish the config file with:

```
php artisan vendor:publish --provider="Siberfx\AuthenticationLogger\AuthenticationLogServiceProviderger" --tag="authentication-log-config"
```

This is the contents of the published config file:

```
return [
    // The database table name
    // You can change this if the database keys get too long for your driver
    'table_name' => 'authentication_log',

    'notifications' => [
        'new-device' => [
            // Send the NewDevice notification
            'enabled' => env('NEW_DEVICE_NOTIFICATION', true),

            // Use torann/geoip to attempt to get a location
            'location' => true,

            // The Notification class to send
            'template' => \Siberfx\AuthenticationLogger\Notifications\NewDevice::class,
        ],
        'failed-login' => [
            // Send the FailedLogin notification
            'enabled' => env('FAILED_LOGIN_NOTIFICATION', false),

            // Use torann/geoip to attempt to get a location
            'location' => true,

            // The Notification class to send
            'template' => \Siberfx\AuthenticationLogger\Notifications\FailedLogin::class,
        ],
    ],

    // When the clean-up command is run, delete old logs greater than `purge` days
    // Don't schedule the clean-up command if you want to keep logs forever.
    'purge' => 60,
];
```

If you installed `torann/geoip` you should also publish that config file to set your defaults:

```
php artisan vendor:publish --provider="Torann\GeoIP\GeoIPServiceProvider" --tag=config

```

Configuration
-------------

[](#configuration)

You must add the `AuthenticationLoggable` and `Notifiable` traits to the models you want to track.

```
use Illuminate\Notifications\Notifiable;
use Siberfx\AuthenticationLogger\Traits\AuthenticationLoggable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use Notifiable, AuthenticationLoggable;
}
```

The package will listen for Laravel's Login, Logout, Failed, and OtherDeviceLogout events.

Usage
-----

[](#usage)

Get all authentication logs for the user:

```
User::find(1)->authentications;
```

Get the user's last login information:

```
User::find(1)->lastLoginAt();

User::find(1)->lastSuccessfulLoginAt();

User::find(1)->lastLoginIp();

User::find(1)->lastSuccessfulLoginIp();
```

Get the user's previous login time &amp; IP address (ignoring the current login):

```
auth()->user()->previousLoginAt();

auth()->user()->previousLoginIp();
```

### Notifications

[](#notifications)

Notifications may be sent on the `mail`, `nexmo`, and `slack` channels but by **default notify via email**.

You may define a `notifyAuthenticationLogVia` method on your authenticatable models to determine which channels the notification should be delivered on:

```
public function notifyAuthenticationLogVia()
{
    return ['nexmo', 'mail', 'slack'];
}
```

You must install the [Slack](https://laravel.com/docs/8.x/notifications#routing-slack-notifications) and [Nexmo](https://laravel.com/docs/8.x/notifications#routing-sms-notifications) drivers to use those routes and follow their documentation on setting it up for your specific authenticatable models.

#### New Device Notifications

[](#new-device-notifications)

Enabled by default, they use the `\Siberfx\AuthenticationLogger\Notifications\NewDevice` class which can be overridden in the config file.

#### Failed Login Notifications

[](#failed-login-notifications)

Disabled by default, they use the `\Siberfx\AuthenticationLogger\Notifications\FailedLogin` class which can be overridden in the config file.

#### Location

[](#location)

If the `torann/geoip` package is installed, it will attempt to include location information to the notifications by default.

You can turn this off within the configuration for each template.

**Note:** By default when working locally, no location will be recorded because it will send back the `default address` from the `geoip` config file. You can override this behavior in the email templates.

Purging Old Logs
----------------

[](#purging-old-logs)

Records that are older than the number of days specified in the `purge` option in your `config/authentication-log.php` will be deleted.

```
'purge' => 60,
```

You can also schedule the command at with `Prunnable` which shipped with Laravel 8.50 version:

```
$schedule->command('model:prune')->daily();
```

Displaying The Log
------------------

[](#displaying-the-log)

**Note:** This example uses the `jenssegers/agent` package which is included by default with Laravel Jetstream as well as `jamesmills/laravel-timezone` for displaying timezones in the users local timezone. Both are optional, modify the table to fit your needs.

```
use Illuminate\Support\ServiceProvider;
use Illuminate\Auth\Events\Failed;
use Illuminate\Auth\Events\Login;
use Illuminate\Auth\Events\Logout;
use Siberfx\AuthenticationLogger\Listeners\FailedLoginListener;
use Siberfx\AuthenticationLogger\Listeners\LoginListener;
use Siberfx\AuthenticationLogger\Listeners\LogoutListener;
use Siberfx\AuthenticationLogger\Listeners\OtherDeviceLogoutListener;

        $events->listen(Login::class, LoginListener::class);
        $events->listen(Failed::class, FailedLoginListener::class);
        $events->listen(Logout::class, LogoutListener::class);
        $events->listen(OtherDeviceLogout::class, OtherDeviceLogoutListener::class);
```

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance90

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~135 days

Recently: every ~284 days

Total

13

Last Release

49d ago

Major Versions

1.1.0 → 2.0.02022-02-17

2.1.0 → 5.0.02023-02-14

5.0.0 → 6.02023-02-14

PHP version history (6 changes)1.0.0PHP ^7.4|^8.0

1.0.1PHP ^7|^8

5.0.0PHP ^8

6.0.1PHP ^8.1|^8.2

6.1.0PHP ^8.4

6.1.2PHP ^8.2|^8.3|^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/319c5a3ca014236bc2d28e3e37825e1ec467b51455c020c6666d1f40f493c2e1?d=identicon)[siberfx](/maintainers/siberfx)

---

Top Contributors

[![siberfx](https://avatars.githubusercontent.com/u/10257240?v=4)](https://github.com/siberfx "siberfx (40 commits)")

---

Tags

laravelSiberfxauthentication-logger

### Embed Badge

![Health badge](/badges/siberfx-authentication-logger/health.svg)

```
[![Health](https://phpackages.com/badges/siberfx-authentication-logger/health.svg)](https://phpackages.com/packages/siberfx-authentication-logger)
```

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

12.9k89.8M1.0k](/packages/spatie-laravel-permission)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[php-open-source-saver/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

8359.8M53](/packages/php-open-source-saver-jwt-auth)[spatie/laravel-login-link

Quickly login to your local environment

4381.2M1](/packages/spatie-laravel-login-link)[ryangjchandler/laravel-cloudflare-turnstile

A simple package to help integrate Cloudflare Turnstile.

438896.6k2](/packages/ryangjchandler-laravel-cloudflare-turnstile)[spatie/laravel-passkeys

Use passkeys in your Laravel app

444494.4k16](/packages/spatie-laravel-passkeys)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
