From 165aecbb13ddc07fc553538451b8313f3e515a59 Mon Sep 17 00:00:00 2001 From: juuliabellcom Date: Wed, 26 Aug 2020 19:52:14 +0300 Subject: [PATCH] Fixes for SSO redirect --- src/EventSubscriber/SimplesamlSubscriber.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/EventSubscriber/SimplesamlSubscriber.php b/src/EventSubscriber/SimplesamlSubscriber.php index 7a9d7c7..7aa2154 100644 --- a/src/EventSubscriber/SimplesamlSubscriber.php +++ b/src/EventSubscriber/SimplesamlSubscriber.php @@ -51,11 +51,12 @@ public function __construct(SimplesamlphpAuthManager $simplesaml, AccountInterfa public function redirectToSimplesamlLogin(GetResponseEvent $event) { // If user is not anonymous, if SimpleSAML is not activated or if PHP_SAPI // is cli - don't do any redirects. - if (!$this->account->isAnonymous() || !$this->simplesaml->isActivated() || PHP_SAPI === 'cli') { - return; + $request = $event->getRequest(); + $saml_login_path = Url::fromRoute('simplesamlphp_auth.saml_login')->toString(); + if (!$this->account->isAnonymous() || !$this->simplesaml->isActivated() || PHP_SAPI === 'cli' || $request->getRequestUri() == $saml_login_path) { + return; } - $request = $event->getRequest(); $config = \Drupal::config('os2web_simplesaml.settings'); // Only redirect if we are on redirect triggering page. $patterns = str_replace(',', "\n", $config->get('redirect_trigger_path')); @@ -63,10 +64,10 @@ public function redirectToSimplesamlLogin(GetResponseEvent $event) { // Killing cache for redirect triggering page. \Drupal::service('page_cache_kill_switch')->trigger(); - // Check has been already performed, wait for the cookies to expire. - if ($request->cookies->has('os2web_simplesaml_redirect_to_saml')) { - return; - } + // Check has been already performed, wait for the cookies to expire. + // if ($request->cookies->has('os2web_simplesaml_redirect_to_saml')) { + // return; + // } $simplesamlRedirect = FALSE; $remoteIp = $request->getClientIp();