Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can we catch the SAML user from SAMLLogoutEvent listener #225

Open
kalana3029 opened this issue May 12, 2020 · 2 comments
Open

Can we catch the SAML user from SAMLLogoutEvent listener #225

kalana3029 opened this issue May 12, 2020 · 2 comments

Comments

@kalana3029
Copy link

Hi,
I need to identified the user which user was logout from the SAML, In SAMLLogoutEvent listener return only Idp name, How can i get the related user from there.

@danmichaelo
Copy link
Contributor

You can use the authenticated user from the session :) Here's a simple Saml2Logout handler:

<?php

namespace App\Listeners;

use Aacotroneo\Saml2\Events\Saml2LogoutEvent;

class Saml2Logout
{
    /**
     * Handle the event.
     *
     * @param Saml2LogoutEvent $event
     *
     * @return void
     */
    public function handle(Saml2LogoutEvent $event)
    {
        $user = auth()->user();
        if ($user) {
            \Log::info("User {$user->id} logged out")
        }
        auth()->logout();
        session()->invalidate();
    }
}

@kalana3029
Copy link
Author

kalana3029 commented Jul 28, 2020

@danmichaelo Thing is, I am using token-based authentication. Can we get the logout user's email from the Saml2LogoutEvent ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants