forked from miguel456/rbrecruiter
Added logging for failed authentication attempts
This commit is contained in:
parent
e566e40404
commit
20ab381076
36
app/Listeners/LogAuthenticationFailure.php
Normal file
36
app/Listeners/LogAuthenticationFailure.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Listeners;
|
||||
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class LogAuthenticationFailure
|
||||
{
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param object $event
|
||||
* @return void
|
||||
*/
|
||||
public function handle($event)
|
||||
{
|
||||
Log::alert('SECURITY (login): Detected failed authentication attempt!', [
|
||||
'targetAccountID' => $event->user->id,
|
||||
'sourceIP' => request()->ip(),
|
||||
'matchesAccountLastIP' => request()->ip() == $event->user->originalIP,
|
||||
'sourceUserAgent' => request()->userAgent(),
|
||||
]);
|
||||
}
|
||||
}
|
@ -2,7 +2,9 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Listeners\LogAuthenticationFailure;
|
||||
use App\Listeners\OnUserRegistration;
|
||||
use Illuminate\Auth\Events\Failed;
|
||||
use Illuminate\Auth\Events\Registered;
|
||||
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
@ -20,6 +22,9 @@ class EventServiceProvider extends ServiceProvider
|
||||
SendEmailVerificationNotification::class,
|
||||
OnUserRegistration::class
|
||||
],
|
||||
Failed::class => [
|
||||
LogAuthenticationFailure::class
|
||||
],
|
||||
'App\Events\ApplicationApprovedEvent' => [
|
||||
'App\Listeners\PromoteUser'
|
||||
],
|
||||
|
Loading…
Reference in New Issue
Block a user