Download the PHP package siberfx/authentication-logger without Composer
On this page you can find all versions of the php package siberfx/authentication-logger. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download siberfx/authentication-logger
More information about siberfx/authentication-logger
Files in siberfx/authentication-logger
Package authentication-logger
Short Description Log user authentication details and send new device notifications.
License MIT
Homepage https://github.com/siberfx/authentication-logger
Informations about the package authentication-logger
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
You can install the package via composer:
If you want the location features you must also install torann/geoip
:
You can publish and run the migrations with:
You can publish the view/email files with:
You can publish the config file with:
This is the contents of the published config file:
If you installed torann/geoip
you should also publish that config file to set your defaults:
Configuration
You must add the AuthenticationLoggable
and Notifiable
traits to the models you want to track.
The package will listen for Laravel's Login, Logout, Failed, and OtherDeviceLogout events.
Usage
Get all authentication logs for the user:
Get the user's last login information:
Get the user's previous login time & IP address (ignoring the current login):
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:
You must install the Slack and Nexmo drivers to use those routes and follow their documentation on setting it up for your specific authenticatable models.
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
Disabled by default, they use the \Siberfx\AuthenticationLogger\Notifications\FailedLogin
class which can be overridden in the config file.
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
Records that are older than the number of days specified in the purge
option in your config/authentication-log.php
will be deleted.
You can also schedule the command at with Prunnable
which shipped with Laravel 8.50 version:
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.