sureshinde/laravel-auth-checker
Composer 安装命令:
composer require sureshinde/laravel-auth-checker
包简介
Laravel Auth Checker allows you to log users authentication, devices authenticated from and lock intrusions.
关键字:
README 文档
README
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.
Requirements
- Laravel 9 to 10
- PHP 8.0 to 8.2
Laravel support
| Version | Release |
|---|---|
| 10 | 2.1 |
| 9, 10 | 2.0 |
| 8, 9 | 1.7 |
| 6, 7 | 1.6 |
| 5.8 | 1.2 |
| 5.7, 5.6 | 1.1 |
Installation
- Require it with Composer:
composer require sureshinde/laravel-auth-checker
- Add to your User model the
SureShinde\AuthChecker\Models\HasLoginsAndDevicestrait and theSureShinde\AuthChecker\Interfaces\HasLoginsAndDevicesInterfaceinterface.
use SureShinde\AuthChecker\Models\HasLoginsAndDevices; use SureShinde\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 (viaLogin::TYPE_LOGIN)$user->fails, returns failed logins (viaLogin::TYPE_FAILED)$user->lockouts, returns locked out logins (viaLogin::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
- Log user authentication
- Collect IP addresses
- Collect devices
- Get user's login history
- Get devices history
- Capture failed logins
- 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:
LoginCreatedis fired when a user authenticates.DeviceCreatedis fired when a new device is created for a user.FailedAuthis fired when a user fails to log in.LockoutAuthis 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 loginsauths()returns all successful login attempsfails()returns all failed login attemptslockouts()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
- MarceauKa
- and all others contributors
Licence
MIT
sureshinde/laravel-auth-checker 适用场景与选型建议
sureshinde/laravel-auth-checker 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 02 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「package」 「Authentication」 「plugin」 「user」 「check」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 sureshinde/laravel-auth-checker 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sureshinde/laravel-auth-checker 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 sureshinde/laravel-auth-checker 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
CakePHP 4.x AdminLTE Theme.
Automatically logs-in users if they are already authenticated by a remote source. (e.g. environment variable REMOTE_USER)
GraphQL authentication for your headless Craft CMS applications.
Laravel middleware to restrict a site or specific routes using HTTP basic authentication
Email Toolkit Plugin for CakePHP
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-02-20
