Skip to content

Commit

Permalink
Bug: 15077 Support specific case when auth server is unavailable.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrubinsk committed Oct 25, 2021
1 parent 7b6c589 commit fc39d44
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions lib/Horde/Core/ActiveSync/Driver.php
Expand Up @@ -217,10 +217,31 @@ public function authenticate($username, $password, $domain = null)
}

// Now check Basic. Happens for authtype == 'basic' || 'basic_cert'
if ($conf['activesync']['auth']['type'] != 'cert' &&
!$this->_auth->authenticate($username, array('password' => $password))) {
$injector->getInstance('Horde_Log_Logger')->notice(sprintf('Login failed from ActiveSync client for user %s.', $username));
return false;
if ($conf['activesync']['auth']['type'] != 'cert') {
try {
$authResult = $this->_auth->authenticate($username, array('password' => $password));
} catch (Horde_Auth_Exception $e) {
if ($e->getCode() == Horde_Auth::REASON_MESSAGE) {
// This error code would only happen if it's an error
// from the underlaying auth backend, and NOT an invalid
// authentication attempt.
$this->_logger->warn('Authentication server unavailable.');

// TODO: Remove BC shim
if (defined('Horde_ActiveSync::AUTH_REASON_UNAVAILABLE')) {
return constant('Horde_ActiveSync::AUTH_REASON_UNAVAILABLE');
}

return false;
}
}

if (!$authResult) {
$injector->getInstance('Horde_Log_Logger')->notice(sprintf('Login failed from ActiveSync client for user %s.', $username));
return false;
}

return true;
}

// Get the username from the registry so we capture it after any
Expand Down

0 comments on commit fc39d44

Please sign in to comment.