protected function _check_login($username = NULL, $password = FALSE)
{
if (empty($username)) {
return FALSE;
}
$auth_source = strtolower($this->config->item('auth_source'));
$rest_auth = strtolower($this->config->item('rest_auth'));
$valid_logins = $this->config->item('rest_valid_logins');
if (!$this->config->item('auth_source') && $rest_auth === 'digest') {
// For digest we do not have a password passed as argument
return md5($username . ':' . $this->config->item('rest_realm') . ':' . (isset($valid_logins[$username]) ? $valid_logins[$username] : ''));
}
if ($password === FALSE) {
return FALSE;
}
if ($auth_source === 'ldap') {
log_message('debug', "Performing LDAP authentication for {$username}");
return $this->_perform_ldap_auth($username, $password);
}
if ($auth_source === 'library') {
log_message('debug', "Performing Library authentication for {$username}");
return $this->_perform_library_auth($username, $password);
}
if (array_key_exists($username, $valid_logins) === FALSE) {
return FALSE;
}
if ($valid_logins[$username] !== $password) {
return FALSE;
}
return TRUE;
}