You are here

function ldap_sso_path_excluded_from_sso in Lightweight Directory Access Protocol (LDAP) 8.2

1 call to ldap_sso_path_excluded_from_sso()
ldap_sso_boot in ldap_sso/ldap_sso.module
Implements hook_boot(). Perform setup tasks. This entry point is used because hook_user_load no longer runs on anonymous users, and hook_boot is guaranteed to run, regardless of cache

File

ldap_sso/ldap_sso.module, line 93
This module injects itself into Drupal's Authentication stack.

Code

function ldap_sso_path_excluded_from_sso($path = FALSE) {
  $result = FALSE;
  if ($path) {

    // don't derive
  }
  elseif ($_SERVER['PHP_SELF'] == '/index.php') {
    $path = $_GET['q'];
  }
  else {
    $path = ltrim($_SERVER['PHP_SELF'], '/');

    // cron.php, etc.
  }
  if (in_array($path, ldap_sso_default_excluded_paths())) {
    return TRUE;
  }
  $ldap_authentication_conf = variable_get('ldap_authentication_conf', array());
  if (isset($ldap_authentication_conf['ssoExcludedHosts']) && is_array($ldap_authentication_conf['ssoExcludedHosts'])) {
    $host = $_SERVER['SERVER_NAME'];
    foreach ($ldap_authentication_conf['ssoExcludedHosts'] as $host_to_check) {
      if ($host_to_check == $host) {
        return TRUE;
      }
    }
  }
  if (isset($ldap_authentication_conf['ssoExcludedPaths'])) {
    $patterns = join("\r\n", $ldap_authentication_conf['ssoExcludedPaths']);
    if ($patterns) {
      if (function_exists('drupal_get_path_alias')) {
        $path = drupal_get_path_alias($path);
      }
      $path = function_exists('drupal_strtolower') ? drupal_strtolower($path) : strtolower($path);
      $to_replace = array(
        '/(\\r\\n?|\\n)/',
        // newlines
        '/\\\\\\*/',
        // asterisks
        '/(^|\\|)\\\\<front\\\\>($|\\|)/',
      );
      $replacements = array(
        '|',
        '.*',
        '\\1' . preg_quote(config('system.site')
          ->get('frontpage'), '/') . '\\2',
      );
      $patterns_quoted = preg_quote($patterns, '/');
      $regex = '/^(' . preg_replace($to_replace, $replacements, $patterns_quoted) . ')$/';
      $result = (bool) preg_match($regex, $path);
    }
  }
  return $result;
}