Added logging for successful authentication attempts
This commit is contained in:
parent
20ab381076
commit
e93abd2ab7
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Listeners;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class LogAuthenticationSuccess
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create the event listener.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the event.
|
||||||
|
*
|
||||||
|
* @param object $event
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle($event)
|
||||||
|
{
|
||||||
|
Log::info('SECURITY (postauth-pre2fa): Detected successful login attempt', [
|
||||||
|
'accountID' => $event->user->id,
|
||||||
|
'sourceIP' => request()->ip(),
|
||||||
|
'matchesAccountLastIP' => request()->ip() == $event->user->originalIP,
|
||||||
|
'sourceUserAgent' => request()->userAgent(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,8 +3,10 @@
|
||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
use App\Listeners\LogAuthenticationFailure;
|
use App\Listeners\LogAuthenticationFailure;
|
||||||
|
use App\Listeners\LogAuthenticationSuccess;
|
||||||
use App\Listeners\OnUserRegistration;
|
use App\Listeners\OnUserRegistration;
|
||||||
use Illuminate\Auth\Events\Failed;
|
use Illuminate\Auth\Events\Failed;
|
||||||
|
use Illuminate\Auth\Events\Login;
|
||||||
use Illuminate\Auth\Events\Registered;
|
use Illuminate\Auth\Events\Registered;
|
||||||
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
||||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||||
|
@ -25,6 +27,9 @@ class EventServiceProvider extends ServiceProvider
|
||||||
Failed::class => [
|
Failed::class => [
|
||||||
LogAuthenticationFailure::class
|
LogAuthenticationFailure::class
|
||||||
],
|
],
|
||||||
|
Login::class => [
|
||||||
|
LogAuthenticationSuccess::class
|
||||||
|
],
|
||||||
'App\Events\ApplicationApprovedEvent' => [
|
'App\Events\ApplicationApprovedEvent' => [
|
||||||
'App\Listeners\PromoteUser'
|
'App\Listeners\PromoteUser'
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in New Issue