From b69efd40145a540a127edc1ea88e2a2f003976c1 Mon Sep 17 00:00:00 2001 From: Jesse Vista Date: Tue, 9 May 2023 10:12:02 -0400 Subject: [PATCH] Fix deprecation Replace deprecated dispatchNow with dispatchSync. Thanks @will-dive for this catch. Signed-off-by: Jesse Vista --- src/Http/Controllers/LogoutController.php | 8 ++++---- src/Listeners/SamlAuthenticated.php | 11 ++++++++--- src/Listeners/SamlLogin.php | 10 +++++++--- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/Http/Controllers/LogoutController.php b/src/Http/Controllers/LogoutController.php index a611dd9..457a1d0 100644 --- a/src/Http/Controllers/LogoutController.php +++ b/src/Http/Controllers/LogoutController.php @@ -2,10 +2,10 @@ namespace CodeGreenCreative\SamlIdp\Http\Controllers; +use Illuminate\Support\Str; +use Illuminate\Http\Request; use Illuminate\Routing\Controller; use CodeGreenCreative\SamlIdp\Jobs\SamlSlo; -use Illuminate\Http\Request; -use Illuminate\Support\Str; class LogoutController extends Controller { @@ -29,10 +29,10 @@ public function index(Request $request) // Loop through our service providers and "touch" the logout URL's foreach (config('samlidp.sp') as $key => $sp) { // Check if the service provider supports SLO - if (! empty($sp['logout']) && ! in_array($key, $request->session()->get('saml.slo', []))) { + if (!empty($sp['logout']) && !in_array($key, $request->session()->get('saml.slo', []))) { // Push this SP onto the saml slo array $request->session()->push('saml.slo', $key); - return redirect(SamlSlo::dispatchNow($sp)); + return redirect(SamlSlo::dispatchSync($sp)); } } diff --git a/src/Listeners/SamlAuthenticated.php b/src/Listeners/SamlAuthenticated.php index d7fdd39..a91b776 100644 --- a/src/Listeners/SamlAuthenticated.php +++ b/src/Listeners/SamlAuthenticated.php @@ -2,8 +2,8 @@ namespace CodeGreenCreative\SamlIdp\Listeners; -use CodeGreenCreative\SamlIdp\Jobs\SamlSso; use Illuminate\Auth\Events\Authenticated; +use CodeGreenCreative\SamlIdp\Jobs\SamlSso; class SamlAuthenticated { @@ -15,8 +15,13 @@ class SamlAuthenticated */ public function handle(Authenticated $event) { - if (in_array($event->guard, config('samlidp.guards')) && request()->filled('SAMLRequest') && ! request()->is('saml/logout') && request()->isMethod('get')) { - abort(response(SamlSso::dispatchNow($event->guard)), 302); + if ( + in_array($event->guard, config('samlidp.guards')) && + request()->filled('SAMLRequest') && + !request()->is('saml/logout') && + request()->isMethod('get') + ) { + abort(response(SamlSso::dispatchSync($event->guard)), 302); } } } diff --git a/src/Listeners/SamlLogin.php b/src/Listeners/SamlLogin.php index bb83494..81ad5aa 100644 --- a/src/Listeners/SamlLogin.php +++ b/src/Listeners/SamlLogin.php @@ -2,8 +2,8 @@ namespace CodeGreenCreative\SamlIdp\Listeners; -use CodeGreenCreative\SamlIdp\Jobs\SamlSso; use Illuminate\Auth\Events\Login; +use CodeGreenCreative\SamlIdp\Jobs\SamlSso; class SamlLogin { @@ -15,8 +15,12 @@ class SamlLogin */ public function handle(Login $event) { - if (in_array($event->guard, config('samlidp.guards')) && request()->filled('SAMLRequest') && ! request()->is('saml/logout')) { - abort(response(SamlSso::dispatchNow($event->guard)), 302); + if ( + in_array($event->guard, config('samlidp.guards')) && + request()->filled('SAMLRequest') && + !request()->is('saml/logout') + ) { + abort(response(SamlSso::dispatchSync($event->guard)), 302); } } }