You are here

protected function LdapSsoBootSubscriber::checkExcludePath in LDAP Single Sign On 8.4

Same name and namespace in other branches
  1. 8 src/LdapSsoBootSubscriber.php \Drupal\ldap_sso\LdapSsoBootSubscriber::checkExcludePath()

Check to exclude paths from SSO.

Return value

bool Path excluded or not.

1 call to LdapSsoBootSubscriber::checkExcludePath()
LdapSsoBootSubscriber::checkSsoLoad in src/LdapSsoBootSubscriber.php
Determine if we should attempt SSO.

File

src/LdapSsoBootSubscriber.php, line 188

Class

LdapSsoBootSubscriber
Provides the automated single sign-on provider.

Namespace

Drupal\ldap_sso

Code

protected function checkExcludePath() : bool {
  if ($_SERVER['PHP_SELF'] === $this->currentRequest
    ->getBasePath() . '/index.php') {

    // Remove base_path from current path to match subdirectories, too.
    $path = str_replace($this->currentRequest
      ->getBasePath(), '', $this->currentPath
      ->getPath());
  }
  else {

    // cron.php, etc.
    $path = ltrim($_SERVER['PHP_SELF'], '/');
  }
  if (\in_array($path, self::DEFAULT_EXCLUDE_PATHS, TRUE)) {
    return TRUE;
  }
  if (\is_array($this->config
    ->get('ssoExcludedHosts'))) {
    $host = $_SERVER['SERVER_NAME'];
    foreach ($this->config
      ->get('ssoExcludedHosts') as $host_to_check) {
      if ($host_to_check === $host) {
        return TRUE;
      }
    }
  }
  foreach ($this->config
    ->get('ssoExcludedPaths') as $path_to_exclude) {
    if (mb_strtolower($path) === mb_strtolower($path_to_exclude) || $path_to_exclude === '<front>' && mb_strtolower($this->frontpage) === mb_strtolower($path)) {
      return TRUE;
    }
  }
  return FALSE;
}