function simple_ldap_sso_populate_session in Simple LDAP 7.2
Same name and namespace in other branches
- 7 simple_ldap_sso/simple_ldap_sso.inc \simple_ldap_sso_populate_session()
Helper function to decrypt the SSO cookie, and verify its data.
Return value
bool TRUE if a session id was found and populated. FALSE otherwise.
1 call to simple_ldap_sso_populate_session()
- simple_ldap_sso_detect_sid in simple_ldap_sso/
simple_ldap_sso.inc - Detects an existing session from another site.
File
- simple_ldap_sso/
simple_ldap_sso.inc, line 120 - Simple LDAP SSO API functions.
Code
function simple_ldap_sso_populate_session() {
// The SSO cookie is trusted implicitly here if it can be decoded. It is then
// checked in hook_init against the LDAP stored value during hook_init(). If
// it is found to not be valid there, the session we create here is destroyed,
// a watchdog error is logged, and the user is logged out.
if (!($data = simple_ldap_sso_get_cookie_data())) {
return FALSE;
}
$key = array(
'sid' => $data['sid'],
'ssid' => $data['ssid'],
);
if ($data['uid'] == 1) {
// Do nothing for user 1.
return FALSE;
}
// Unset the name field, as we don't need that here.
unset($data['name']);
// Empty out the session data.
$data['session'] = '';
// If the user sync method is hook_user_login, queue a sync.
if (simple_ldap_user_variable_get('simple_ldap_user_sync') == 'hook_user_login') {
simple_ldap_sso_queue_user_sync();
}
$query = db_merge('sessions')
->key($key)
->fields($data);
return $query
->execute();
}