laravel-saml2 icon indicating copy to clipboard operation
laravel-saml2 copied to clipboard

Question: Where to add listeners for events?

Open happenpappen opened this issue 2 years ago • 5 comments

Hi,

the readme says under "Authentication events", that you should "add listeners on Slides\Saml2\SignedIn and Slides\Saml2\SignedOut events.", but it does not tell where (in which file) one should do that - is there any example showing exactly what to do?

kind regards,

Christoph

happenpappen avatar May 03 '23 07:05 happenpappen

Run this command: php artisan make:listener SsoLoginListener --event=\Slides\Saml2\Events\SignedIn

This will create a new Listener class under the app\Listeners dir.

chris5tu88s avatar May 04 '23 05:05 chris5tu88s

Auth::login here doesn't work!

mohamed-salah-tawfik avatar May 15 '23 18:05 mohamed-salah-tawfik

@mohamed-salah-tawfik The same thing happened to me. I could login the user in the listener but once they were redirected to the app, they were not logged in.

Check you have routesMiddleware set in your config/saml2.php file. Mine is set to 'web'. You need to make sure the middleware group is using StartSession in Kernel.php (the 'web' middleware group will do this by default).

chris5tu88s avatar May 16 '23 05:05 chris5tu88s

@mohamed-salah-tawfik The same thing happened to me. I could login the user in the listener but once they were redirected to the app, they were not logged in.

Check you have routesMiddleware set in your config/saml2.php file. Mine is set to 'web'. You need to make sure the middleware group is using StartSession in Kernel.php (the 'web' middleware group will do this by default).

Thank you so much. This really helped a lot. To anyone who experiences 419 error, you need to edit your VerifyCsrfToken Middleware.

imhaggarwal avatar May 31 '23 04:05 imhaggarwal