aacotroneo / laravel-saml2

A Laravel 5 package for Saml2 integration as a SP (service provider) based on the simple OneLogin toolkit
MIT License
567 stars 239 forks source link

Swoole exit() triggered using Laravel Octane & Swoole #252

Open wanadri opened 3 years ago

wanadri commented 3 years ago

Hi,

Laravel = 8.* PHP = 8 Laravel Octane Swoole

Currently, I'm facing a problem with this package if using Laravel Octane & Swoole.

During redirect to IDP URL,

swoole Exit()

will trigger because of the class that calling exit() method. To be exact, I have noticed that redirect() method in Utils.php class calling exit() method.

Below is the sample screenshot of the error response.

Screenshot 2021-10-22 at 11 09 58 AM

Kindly, need your guide/help to encounter this problem, or is there any solution that I can refer to.

Thank you.

haught commented 2 years ago

Here is what I am doing to support swoole/octane: https://gist.github.com/haught/09f48e172ec347787b542eb03e23bd5f

You can set saml2_controller in your config to use your own instead of the bundled one.

The thing about swoole is that you don't get super globals set, so we set and unset them for onelogin/php-saml as in the above gist.

For your specific question, php-saml wants to set redirect headers and then exit - neither is going to work - so we directly use the Saml2Auth->login() method setting $stay to true. $stay is passed to Saml2Auth->redirectTo, then to OneLogin_Saml2_Utils::redirect which instead just returns the redirect url rather than setting headers and exiting.

wanadri commented 2 years ago

Hi @haught, Thank you for your response. Will try on your suggestion.