summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2014-01-07 14:41:55 (GMT)
committerThomas Bruederli <bruederli@kolabsys.com>2014-01-07 15:41:14 (GMT)
commit05c26255a8e6cdcb258e66b64b2b70779f819cca (patch)
tree12501c545265ee072d64efd239ee2b8033f5077f
parent9e50d6e533db67fb3a7f1726d0e60a033cf4e967 (diff)
downloadiRony-05c26255a8e6cdcb258e66b64b2b70779f819cca.tar.gz
React on LDAP server errors with a 503 Service Unavailable exception (#2745)
-rw-r--r--lib/Kolab/DAV/Auth/HTTPBasic.php21
1 files changed, 18 insertions, 3 deletions
diff --git a/lib/Kolab/DAV/Auth/HTTPBasic.php b/lib/Kolab/DAV/Auth/HTTPBasic.php
index 1f841e9..4bf2aa8 100644
--- a/lib/Kolab/DAV/Auth/HTTPBasic.php
+++ b/lib/Kolab/DAV/Auth/HTTPBasic.php
@@ -26,12 +26,12 @@ namespace Kolab\DAV\Auth;
use \rcube;
use \rcube_user;
use \rcube_utils;
-use Kolab\Utils\CacheAPC;
+use Sabre\DAV;
/**
*
*/
-class HTTPBasic extends \Sabre\DAV\Auth\Backend\AbstractBasic
+class HTTPBasic extends DAV\Auth\Backend\AbstractBasic
{
// Make the current user name available to all classes
public static $current_user = null;
@@ -62,7 +62,7 @@ class HTTPBasic extends \Sabre\DAV\Auth\Backend\AbstractBasic
'pass' => $password,
));
- if ($cache) {
+ if ($cache && !$auth['abort']) {
$cache->set($cache_key, array(
'user' => $auth['user'],
'host' => $auth['host'],
@@ -82,6 +82,21 @@ class HTTPBasic extends \Sabre\DAV\Auth\Backend\AbstractBasic
return true;
}
+ else {
+ // check LDAP auth if using cached data
+ if (!isset($auth['abort'])) {
+ $auth = $rcube->plugins->exec_hook('authenticate', array(
+ 'host' => $auth['host'],
+ 'user' => $username,
+ 'pass' => $password,
+ ));
+ }
+
+ // LDAP server failure... send 503 error
+ if ($auth['kolab_ldap_error']) {
+ throw new DAV\Exception\ServiceUnavailable('The service is temporarily unavailable (LDAP failure)');
+ }
+ }
return false;
}