Changeset View
Changeset View
Standalone View
Standalone View
lib/Kolab/DAV/Auth/HTTPBasic.php
Show First 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | protected function validateUserPass($username, $password) | ||||
'user' => $auth['user'], | 'user' => $auth['user'], | ||||
'host' => $auth['host'], | 'host' => $auth['host'], | ||||
'dn' => $_SESSION['kolab_dn'], | 'dn' => $_SESSION['kolab_dn'], | ||||
'vars' => $_SESSION['kolab_auth_vars'], | 'vars' => $_SESSION['kolab_auth_vars'], | ||||
)); | )); | ||||
} | } | ||||
// LDAP server failure... send 503 error | // LDAP server failure... send 503 error | ||||
if ($auth['kolab_ldap_error']) { | if (!empty($auth['kolab_ldap_error'])) { | ||||
throw new ServiceUnavailable('The service is temporarily unavailable (LDAP failure)'); | throw new ServiceUnavailable('The service is temporarily unavailable (LDAP failure)'); | ||||
} | } | ||||
} | } | ||||
else { | else { | ||||
$auth['pass'] = $password; | $auth['pass'] = $password; | ||||
// set some session vars from kolab_auth | // set some session vars from kolab_auth | ||||
$_SESSION['kolab_dn'] = $auth['dn']; | $_SESSION['kolab_dn'] = $auth['dn']; | ||||
$_SESSION['kolab_auth_vars'] = $auth['vars']; | $_SESSION['kolab_auth_vars'] = $auth['vars']; | ||||
} | } | ||||
// authenticate user against the IMAP server | // authenticate user against the IMAP server | ||||
$user_id = $auth['abort'] ? 0 : $this->_login($auth['user'], $auth['pass'], $auth['host'], $error); | $error = null; | ||||
$user_id = !empty($auth['abort']) ? 0 : $this->_login($auth['user'], $auth['pass'], $auth['host'], $error); | |||||
if ($user_id) { | if ($user_id) { | ||||
self::$current_user = $auth['user']; | self::$current_user = $auth['user']; | ||||
self::$current_pass = $auth['pass']; | self::$current_pass = $auth['pass']; | ||||
$plugin = $rcube->plugins->exec_hook('ready', array('task' => 'iRony')); | $plugin = $rcube->plugins->exec_hook('ready', array('task' => 'iRony')); | ||||
return true; | return true; | ||||
} | } | ||||
if (class_exists('kolab_auth')) { | |||||
if ($error) { | if ($error) { | ||||
$error_str = rcube::get_instance()->get_storage()->get_error_str(); | $error_str = rcube::get_instance()->get_storage()->get_error_str(); | ||||
} | } | ||||
if (class_exists('kolab_auth')) { | \kolab_auth::log_login_error($auth['user'], $error_str ?? null); | ||||
\kolab_auth::log_login_error($auth['user'], $error_str ?: $error); | |||||
} | } | ||||
// IMAP server failure... send 503 error | // IMAP server failure... send 503 error | ||||
if ($error == rcube_imap_generic::ERROR_BAD) { | if ($error == rcube_imap_generic::ERROR_BAD) { | ||||
throw new ServiceUnavailable('The service is temporarily unavailable (Storage failure)'); | throw new ServiceUnavailable('The service is temporarily unavailable (Storage failure)'); | ||||
} | } | ||||
return false; | return false; | ||||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | protected function _login($username, $password, $host, &$error = null) | ||||
if (!empty($a_host['port'])) { | if (!empty($a_host['port'])) { | ||||
$port = $a_host['port']; | $port = $a_host['port']; | ||||
} | } | ||||
else if ($ssl && $ssl != 'tls' && (!$default_port || $default_port == 143)) { | else if ($ssl && $ssl != 'tls' && (!$default_port || $default_port == 143)) { | ||||
$port = 993; | $port = 993; | ||||
} | } | ||||
} | } | ||||
if (!$port) { | if (empty($port)) { | ||||
$port = $default_port; | $port = $default_port; | ||||
} | } | ||||
// Check if we need to add/force domain to username | // Check if we need to add/force domain to username | ||||
if (!empty($username_domain)) { | if (!empty($username_domain)) { | ||||
$domain = is_array($username_domain) ? $username_domain[$host] : $username_domain; | $domain = is_array($username_domain) ? $username_domain[$host] : $username_domain; | ||||
if ($domain = rcube_utils::parse_host((string)$domain, $host)) { | if ($domain = rcube_utils::parse_host((string)$domain, $host)) { | ||||
▲ Show 20 Lines • Show All 75 Lines • Show Last 20 Lines |