All Projects → 404labfr → Laravel Auth Checker

404labfr / Laravel Auth Checker

Laravel Auth Checker allows you to log users authentication, devices authenticated from and lock intrusions.

Projects that are alternatives of or similar to Laravel Auth Checker

Jwt Auth Guard
JWT Auth Guard for Laravel and Lumen Frameworks.
Stars: ✭ 319 (+80.23%)
Mutual labels:  laravel, laravel-package, auth
Laravel Db Profiler
Database Profiler for Laravel Web and Console Applications.
Stars: ✭ 141 (-20.34%)
Mutual labels:  laravel, laravel-package
Laravel Scout Postgres
PostgreSQL Full Text Search Engine for Laravel Scout
Stars: ✭ 140 (-20.9%)
Mutual labels:  laravel, laravel-package
Laravelresources
Speed Up package development for Laravel Apps with API's
Stars: ✭ 152 (-14.12%)
Mutual labels:  laravel, laravel-package
Laravel Deletable
👾 Gracefully restrict deletion of Laravel Eloquent models
Stars: ✭ 137 (-22.6%)
Mutual labels:  laravel, laravel-package
Laravel Easypanel
A beautiful and flexible admin panel creator based on Livewire for Laravel
Stars: ✭ 135 (-23.73%)
Mutual labels:  laravel, laravel-package
Servermonitor
💓 Laravel package to periodically monitor the health of your server and application.
Stars: ✭ 148 (-16.38%)
Mutual labels:  laravel, laravel-package
Laravel Emojione
Laravel package to make it easy to use the gorgeous emojis from EmojiOne
Stars: ✭ 133 (-24.86%)
Mutual labels:  laravel, laravel-package
Laravel Early Access
This package makes it easy to add early access mode to your existing application.
Stars: ✭ 160 (-9.6%)
Mutual labels:  laravel, laravel-package
Laravel Source Encrypter
Laravel and Lumen Source Code Encrypter
Stars: ✭ 175 (-1.13%)
Mutual labels:  laravel, laravel-package
Laravel Security Checker
Added Laravel functionality to Enlightn Security Checker. Adds a command to check for, and optionally emails you, vulnerabilities when they affect you.
Stars: ✭ 163 (-7.91%)
Mutual labels:  laravel, laravel-package
Laravel Hashslug
Package providing a trait to use Hashids on a model
Stars: ✭ 136 (-23.16%)
Mutual labels:  laravel, laravel-package
Twitter
Twitter Notifications Channel for Laravel
Stars: ✭ 135 (-23.73%)
Mutual labels:  laravel, laravel-package
Laravel Api Explorer
API explorer for laravel applications
Stars: ✭ 138 (-22.03%)
Mutual labels:  laravel, laravel-package
Simple Qrcode
An easy-to-use PHP QrCode generator with first-party support for Laravel.
Stars: ✭ 1,923 (+986.44%)
Mutual labels:  laravel, laravel-package
Laravel Themer
Multi theme support for Laravel application
Stars: ✭ 142 (-19.77%)
Mutual labels:  laravel, laravel-package
Laravel Page Speed
Package to optimize your site automatically which results in a 35%+ optimization
Stars: ✭ 2,097 (+1084.75%)
Mutual labels:  laravel, laravel-package
Eloquent Tree
Eloquent Tree is a tree model for Laravel Eloquent ORM.
Stars: ✭ 131 (-25.99%)
Mutual labels:  laravel, laravel-package
Laravel Paddle
Paddle.com API integration for Laravel with support for webhooks/events
Stars: ✭ 132 (-25.42%)
Mutual labels:  laravel, laravel-package
Laravel Auto Translate
Automatically translate your language files using a translator service
Stars: ✭ 153 (-13.56%)
Mutual labels:  laravel, laravel-package

Laravel Auth Checker

Build Status Scrutinizer Code Quality

Laravel Auth Checker is a plugin to collect login info and devices used when a user authenticates. It makes it easy to catch user authentication attempts and lockouts from new IP address or new devices.

Example logins table

Requirements

  • Laravel 6.x to 8.x
  • PHP >= 7.2

Laravel support

Version Release
6.x to 8.x 1.6
5.8 1.2
5.7, 5.6 1.1

Installation

  • Require it with Composer:
composer require lab404/laravel-auth-checker
  • Add to your User model the Lab404\AuthChecker\Models\HasLoginsAndDevices trait and the Lab404\AuthChecker\Interfaces\HasLoginsAndDevicesInterface interface.
use Lab404\AuthChecker\Models\HasLoginsAndDevices;
use Lab404\AuthChecker\Interfaces\HasLoginsAndDevicesInterface;

class User extends Authenticatable implements HasLoginsAndDevicesInterface
{
    use Notifiable, HasLoginsAndDevices;  
}
  • Publish migrations and migrate your database:
php artisan vendor:publish --tag=auth-checker
php artisan migrate

Note: Migrations are published in case you need to customize migration timestamps to integrate to your existing project.

Access collected data

This library collects login data and devices data about your users.

Logins

// Your user model:
$logins = $user->logins;
// Output: 
[
    [
        'ip_address' => '1.2.3.4',
        'device_id' => 1, // ID of the used device
        'type' => 'auth',
        'device' => [
            // See Devices
        ],
        'created_at' => '2017-03-25 11:42:00',
    ],
    // ... and more
]

Also, you can directly access logins by their type:

  • $user->auths, returns successful logins (via Login::TYPE_LOGIN)
  • $user->fails, returns failed logins (via Login::TYPE_FAILED)
  • $user->lockouts, returns locked out logins (via Login::TYPE_LOCKOUT)

Devices

// Your user model:
$devices = $user->devices;
// Outputs:
[
    [
        'platform' => 'OS X',
        'platform_version' => '10_12_2',
        'browser' => 'Chrome',
        'browser_version' => '54',
        'is_desktop' => true,
        'is_mobile' => false,
        'language' => 'fr-fr',
        'login' => [
          // See logins
        ],
    ],
    // ... and more
]

Roadmap

  • [x] Log user authentication
  • [x] Collect IP addresses
  • [x] Collect devices
  • [x] Get user's login history
  • [x] Get devices history
  • [x] Capture failed logins
  • [x] Capture lockout logins
  • [ ] Trust / Untrust devices
  • [ ] Notify user when an unknown device log in

Events

There are many events available that can be used to add features to your app:

  • LoginCreated is fired when a user authenticates.
  • DeviceCreated is fired when a new device is created for a user.
  • FailedAuth is fired when a user fails to log in.
  • LockoutAuth is fired when authentication is locked for a user (too many attempts).

Each event passes a Login model and a Device model to your listeners.

Practical usage

Once the trait HasLoginsAndDevices is added to your User model, it is extended with these methods:

  • logins() returns all logins
  • auths() returns all successful login attemps
  • fails() returns all failed login attempts
  • lockouts() returns all lockouts

Each login returned is associated with the Device model used.

  • devices() returns all devices used by the user to authenticate.

Tests

vendor/bin/phpunit

Contributors

Licence

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].