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

Fixes for SSO redirect #5

Open
wants to merge 1 commit into
base: 8.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/EventSubscriber/SimplesamlSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,23 @@ 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'));
if (empty($patterns) || \Drupal::service('path.matcher')->matchPath($request->getRequestUri(), $patterns)) {
// 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();
Expand Down