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 ($auth['kolab_ldap_error'] ?? false) { | ||||
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']; | ||||
} | } | ||||
$error = null; | |||||
$error_str = null; | |||||
// 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); | $user_id = ($auth['abort'] ?? false) ? 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; | ||||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | protected function _login($username, $password, $host, &$error = null) | ||||
$rcube = rcube::get_instance(); | $rcube = rcube::get_instance(); | ||||
$storage = $rcube->get_storage(); | $storage = $rcube->get_storage(); | ||||
$login_lc = $rcube->config->get('login_lc'); | $login_lc = $rcube->config->get('login_lc'); | ||||
$default_port = $rcube->config->get('default_port', 143); | $default_port = $rcube->config->get('default_port', 143); | ||||
$username_domain = $rcube->config->get('username_domain'); | $username_domain = $rcube->config->get('username_domain'); | ||||
// parse $host | // parse $host | ||||
$a_host = parse_url($host); | $a_host = parse_url($host); | ||||
$port = null; | |||||
if ($a_host['host']) { | if ($a_host['host']) { | ||||
$host = $a_host['host']; | $host = $a_host['host']; | ||||
$ssl = (isset($a_host['scheme']) && in_array($a_host['scheme'], array('ssl','imaps','tls'))) ? $a_host['scheme'] : null; | $ssl = (isset($a_host['scheme']) && in_array($a_host['scheme'], array('ssl','imaps','tls'))) ? $a_host['scheme'] : 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; | ||||
▲ Show 20 Lines • Show All 87 Lines • Show Last 20 Lines |