lab404/laravel-auth-checker 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

lab404/laravel-auth-checker

Composer 安装命令:

composer require lab404/laravel-auth-checker

包简介

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

README 文档

README

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

Version Release
11 3.0
9, 10 2.0
8, 9 1.7
6, 7 1.6

Installation

  • Require the package: composer require lab404/laravel-auth-checker
  • Publish migration files: php artisan vendor:publish --tag=auth-checker
  • Migrate your database: php artisan migrate
  • Configure your Authenticatable model (see below)

Usage

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

Authenticatable model

Your Authenticatable model (usually User) must implement the HasLoginsAndDevicesInterface interface.

The trait HasLoginsAndDevices is provided with for a working default implementation.

use Lab404\AuthChecker\Models\HasLoginsAndDevices;
use Lab404\AuthChecker\Interfaces\HasLoginsAndDevicesInterface;

class User extends Authenticatable implements HasLoginsAndDevicesInterface
{
    // ...
    use HasLoginsAndDevices;  
}

Once configured, you can access the following 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.

Logins

Calling $user->logins outputs:

[
    [
        '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',
    ],
    // ...
]

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

Calling $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
        ],
    ],
    // ...
]

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.

Tests

vendor/bin/phpunit

Contributors

Licence

MIT

lab404/laravel-auth-checker 适用场景与选型建议

lab404/laravel-auth-checker 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 167.14k 次下载、GitHub Stars 达 223, 最近一次更新时间为 2017 年 03 月 25 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「package」 「Authentication」 「plugin」 「user」 「check」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 lab404/laravel-auth-checker 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 lab404/laravel-auth-checker 我们能提供哪些服务?
定制开发 / 二次开发

基于 lab404/laravel-auth-checker 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 167.14k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 225
  • 点击次数: 28
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 223
  • Watchers: 12
  • Forks: 36
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-03-25