> */ protected $listen = [ Registered::class => [ SendEmailVerificationNotification::class, ], CustomerPasswordReset::class => [ PasswordHasReset::class, ], NewNotification::class => [ CreateNotification::class, ], ]; /** * Determine if events and listeners should be automatically discovered. */ public function shouldDiscoverEvents(): bool { return false; } /** * Register any events for your application. */ public function boot(): void { Event::listen('Slides\Saml2\Events\SignedIn', function (SignedIn $event) { $messageId = $event->getAuth()->getLastMessageId(); if (Cache::get(config('cache.prefix') . '_saml_message_id_' . $messageId)) { logger()->error( 'SAML MESSAGE ID HANDLER', ['error' => 'Message ID : ' . $messageId . ' replayed !'] ); abort(403); } else { // Cache for 8h. Cache::put(config('cache.prefix') . '_saml_message_id_' . $messageId, $messageId, 28800); } $user = $event->getSaml2User(); $email = $user->getNameId(); $lUser = User::query()->where('email', $email)->first(); if (! $lUser) { abort(403); } Auth::guard('backend')->login($lUser); session(['sessionIndex' => $user->getSessionIndex()]); $lUser->last_connection = now(); $lUser->saveQuietly(); }); Event::listen('Slides\Saml2\Events\SignedOut', function () { Auth::guard('backend')->logout(); Session::save(); }); } }