mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-28 16:24:04 +02:00
Merge pull request #3061 from ss23/crypt_fix
Modify authentication function to support alternative algorithms
This commit is contained in:
commit
94922ade25
@ -225,9 +225,7 @@ class DbUserBackend extends DbRepository implements UserBackendInterface, Inspec
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$passwordHash = $this->getPasswordHash($user->getUsername());
|
$passwordHash = $this->getPasswordHash($user->getUsername());
|
||||||
$passwordSalt = $this->getSalt($passwordHash);
|
return crypt($password, $passwordHash) === $passwordHash;
|
||||||
$hashToCompare = $this->hashPassword($password, $passwordSalt);
|
|
||||||
return $hashToCompare === $passwordHash;
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw new AuthenticationException(
|
throw new AuthenticationException(
|
||||||
'Failed to authenticate user "%s" against backend "%s". An exception was thrown:',
|
'Failed to authenticate user "%s" against backend "%s". An exception was thrown:',
|
||||||
@ -238,18 +236,6 @@ class DbUserBackend extends DbRepository implements UserBackendInterface, Inspec
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Extract salt from the given password hash
|
|
||||||
*
|
|
||||||
* @param string $hash The hashed password
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
protected function getSalt($hash)
|
|
||||||
{
|
|
||||||
return substr($hash, strlen(self::HASH_ALGORITHM), self::SALT_LENGTH);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a random salt
|
* Return a random salt
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user