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 {
|
||||
$passwordHash = $this->getPasswordHash($user->getUsername());
|
||||
$passwordSalt = $this->getSalt($passwordHash);
|
||||
$hashToCompare = $this->hashPassword($password, $passwordSalt);
|
||||
return $hashToCompare === $passwordHash;
|
||||
return crypt($password, $passwordHash) === $passwordHash;
|
||||
} catch (Exception $e) {
|
||||
throw new AuthenticationException(
|
||||
'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
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue