User backends: Throw exception when authentication fails due to an exception
refs #5685
This commit is contained in:
parent
086e2b6197
commit
cfcaf019bd
|
@ -34,8 +34,8 @@ use \Zend_Db_Expr;
|
||||||
use \Zend_Db_Select;
|
use \Zend_Db_Select;
|
||||||
use Icinga\Authentication\UserBackend;
|
use Icinga\Authentication\UserBackend;
|
||||||
use Icinga\Data\Db\Connection;
|
use Icinga\Data\Db\Connection;
|
||||||
use Icinga\Logger\Logger;
|
|
||||||
use Icinga\User;
|
use Icinga\User;
|
||||||
|
use Icinga\Exception\AuthenticationException;
|
||||||
|
|
||||||
class DbUserBackend extends UserBackend
|
class DbUserBackend extends UserBackend
|
||||||
{
|
{
|
||||||
|
@ -75,6 +75,7 @@ class DbUserBackend extends UserBackend
|
||||||
* @param string $password
|
* @param string $password
|
||||||
*
|
*
|
||||||
* @return bool|null
|
* @return bool|null
|
||||||
|
* @throws AuthenticationException
|
||||||
*/
|
*/
|
||||||
public function authenticate(User $user, $password)
|
public function authenticate(User $user, $password)
|
||||||
{
|
{
|
||||||
|
@ -96,13 +97,14 @@ class DbUserBackend extends UserBackend
|
||||||
|
|
||||||
return ($row !== false) ? true : false;
|
return ($row !== false) ? true : false;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
Logger::error(
|
throw new AuthenticationException(
|
||||||
sprintf(
|
sprintf(
|
||||||
'Failed to authenticate user "%s" with backend "%s". Exception occured: %s',
|
'Failed to authenticate user "%s" against backend "%s". An exception was thrown:',
|
||||||
$user->getUsername(),
|
$user->getUsername(),
|
||||||
$this->getName(),
|
$this->getName()
|
||||||
$e->getMessage()
|
),
|
||||||
)
|
0,
|
||||||
|
$e
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,9 +31,9 @@ namespace Icinga\Authentication\Backend;
|
||||||
|
|
||||||
use \Exception;
|
use \Exception;
|
||||||
use Icinga\User;
|
use Icinga\User;
|
||||||
use Icinga\Logger\Logger;
|
|
||||||
use Icinga\Authentication\UserBackend;
|
use Icinga\Authentication\UserBackend;
|
||||||
use Icinga\Protocol\Ldap\Connection;
|
use Icinga\Protocol\Ldap\Connection;
|
||||||
|
use Icinga\Exception\AuthenticationException;
|
||||||
|
|
||||||
class LdapUserBackend extends UserBackend
|
class LdapUserBackend extends UserBackend
|
||||||
{
|
{
|
||||||
|
@ -95,6 +95,7 @@ class LdapUserBackend extends UserBackend
|
||||||
* @param string $password
|
* @param string $password
|
||||||
*
|
*
|
||||||
* @return bool|null
|
* @return bool|null
|
||||||
|
* @throws AuthenticationException
|
||||||
*/
|
*/
|
||||||
public function authenticate(User $user, $password)
|
public function authenticate(User $user, $password)
|
||||||
{
|
{
|
||||||
|
@ -104,13 +105,14 @@ class LdapUserBackend extends UserBackend
|
||||||
$password
|
$password
|
||||||
);
|
);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
Logger::error(
|
throw new AuthenticationException(
|
||||||
sprintf(
|
sprintf(
|
||||||
'Failed to authenticate user "%s" with backend "%s". Exception occured: %s',
|
'Failed to authenticate user "%s" against backend "%s". An exception was thrown:',
|
||||||
$user->getUsername(),
|
$user->getUsername(),
|
||||||
$this->getName(),
|
$this->getName()
|
||||||
$e->getMessage()
|
),
|
||||||
)
|
0,
|
||||||
|
$e
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue