private function LdapSsoBootSubscriber::checkExcludePath in LDAP Single Sign On 8
Same name and namespace in other branches
- 8.4 src/LdapSsoBootSubscriber.php \Drupal\ldap_sso\LdapSsoBootSubscriber::checkExcludePath()
Check to exclude paths from SSO.
Parameters
bool|string $path: Path to check for exclusion.
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 146
Class
- LdapSsoBootSubscriber
- Provides the automated single sign-on provider.
Namespace
Drupal\ldap_ssoCode
private function checkExcludePath($path = FALSE) {
$result = FALSE;
if ($path) {
// don't derive.
}
elseif ($_SERVER['PHP_SELF'] == '/index.php') {
$path = $this->currentPath
->getPath();
}
else {
// cron.php, etc.
$path = ltrim($_SERVER['PHP_SELF'], '/');
}
if (in_array($path, $this
->defaultPathsToExclude())) {
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;
}
}
}
if ($this->config
->get('ssoExcludedPaths')) {
$patterns = implode("\r\n", $this->config
->get('ssoExcludedPaths'));
if ($patterns) {
if (function_exists('drupal_get_path_alias')) {
$path = drupal_get_path_alias($path);
}
$path = mb_strtolower($path);
// Replacements for newlines, asterisks, and the <front> placeholder.
$to_replace = [
'/(\\r\\n?|\\n)/',
'/\\\\\\*/',
'/(^|\\|)\\\\<front\\\\>($|\\|)/',
];
$replacements = [
'|',
'.*',
'\\1' . preg_quote($this->frontpage, '/') . '\\2',
];
$patterns_quoted = preg_quote($patterns, '/');
$regex = '/^(' . preg_replace($to_replace, $replacements, $patterns_quoted) . ')$/';
$result = (bool) preg_match($regex, $path);
}
}
return $result;
}