function ldap_sso_boot in Lightweight Directory Access Protocol (LDAP) 8.2
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 48 - This module injects itself into Drupal's Authentication stack.
Code
function ldap_sso_boot() {
if (!drupal_is_cli() && $GLOBALS['user']->uid == 0) {
if (ldap_sso_path_excluded_from_sso()) {
return;
}
if (!isset($_COOKIE['seamless_login']) || $_COOKIE['seamless_login'] == 'auto login') {
if (arg(0) == 'user' && !is_numeric(arg(1)) || arg(0) == 'logout') {
return;
}
else {
if (isset($_COOKIE['seamless_login_attempted'])) {
$login_attempted = $_COOKIE['seamless_login_attempted'];
}
else {
$login_attempted = FALSE;
}
require_once DRUPAL_ROOT . '/includes/common.inc';
require_once DRUPAL_ROOT . '/includes/path.inc';
$ldap_authentication_conf = variable_get('ldap_authentication_conf', array());
if (isset($ldap_authentication_conf['seamlessLogin']) && $ldap_authentication_conf['seamlessLogin'] == 1 && $login_attempted != 'true') {
setcookie("seamless_login_attempted", 'true', time() + (int) $ldap_authentication_conf['cookieExpire'], base_path(), "");
$_SESSION['seamless_login_attempted'] = $login_attempted;
// removed with http://drupal.org/node/1485118 patch
//$ldap_sso_q = (!isset($_GET['q']) || $_GET['q'] == '') ? 'user' : $_GET['q'];
//drupal_goto('user/login/sso', array('query' => array('destination' => rawurlencode($ldap_sso_q))));
drupal_bootstrap(DRUPAL_BOOTSTRAP_LANGUAGE);
if (ldap_sso_path_excluded_from_sso()) {
// seems redundant, but need to check this again after additional bootstrap
return;
}
drupal_goto('user/login/sso', array(
'query' => drupal_get_destination(),
));
}
else {
return;
}
}
}
}
}