label84/laravel-auth-log 问题修复 & 功能扩展

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

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

label84/laravel-auth-log

最新稳定版本:v1.4.0

Composer 安装命令:

composer require label84/laravel-auth-log

包简介

Log user authentication actions in Laravel.

README 文档

README

Latest Stable Version MIT Licensed Total Downloads GitHub Workflow Status

The laravel-auth-log package will log all the default Laravel authentication events (Login, Attempting, Lockout, etc.) to your database. In the config file you can select the events that you would like to log. It will save the event name, email, user id, ip address and user agent to the database. No other configurations are required. This package could be useful for tracking unwanted activity in your Laravel application.

Laravel Support

Version Release
12.x ^1.4
11.x ^1.4

Installation

1. Install the package via composer

composer require label84/laravel-auth-log

2. Publish the config file and migration

php artisan vendor:publish --provider="Label84\AuthLog\AuthLogServiceProvider" --tag="config"
php artisan vendor:publish --provider="Label84\AuthLog\AuthLogServiceProvider" --tag="migrations"

3. Run migration

php artisan migrate

Usage

In the config file config/authlog.php you can (un)comment the events that you'd like to log to your database.

// config/authlog.php

return [
    // ...
    'events' => [
        \Illuminate\Auth\Events\Registered::class,
        \Illuminate\Auth\Events\Attempting::class,
        // \Illuminate\Auth\Events\Authenticated::class,
        \Illuminate\Auth\Events\Login::class,
        \Illuminate\Auth\Events\Failed::class,
        // \Illuminate\Auth\Events\Validated::class,
        \Illuminate\Auth\Events\Verified::class,
        // \Illuminate\Auth\Events\Logout::class,
        // \Illuminate\Auth\Events\CurrentDeviceLogout::class,
        // \Illuminate\Auth\Events\OtherDeviceLogout::class,
        \Illuminate\Auth\Events\Lockout::class,
        \Illuminate\Auth\Events\PasswordReset::class,
    ],
];

In the same file you can can also change the database connection and table name.

Enable/disable logging

You can add the AUTH_LOG_ENABLED= to your .env file to enable/disable the logging.

// .env

AUTH_LOG_ENABLED=true

Table format example

id event_name email user_id ip_address user_agent context created_at
1 Attempting info@example.org 127.0.0.1 Mozilla/5.0 (Windows NT 10.0... 2022-01-10 00:00:00
2 Login 1 127.0.0.1 Mozilla/5.0 (Windows NT 10.0... 2022-01-10 00:00:00

Tests

./vendor/bin/phpstan analyse
./vendor/bin/phpunit

License

MIT

统计信息

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

GitHub 信息

  • Stars: 36
  • Watchers: 1
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-01-10