ajout d'une methode spécifique à ssha
Cadoles/hydra-sql/pipeline/pr-develop Build started... Details
Cadoles/hydra-sql/pipeline/head This commit looks good Details

This commit is contained in:
Rudy Masson 2023-01-06 17:06:29 +01:00
parent 437a40e309
commit f19d68ae93
2 changed files with 17 additions and 1 deletions

View File

@ -27,7 +27,7 @@ parameters:
locales: '%env(APP_LOCALES)%'
app.supported_locales: ~
env(PEPPER): "257d62c24cd352c21b51c26dba678c8ff05011a89022aec106185bf67c69aa8b"
env(PEPPER): ""
pepper: '%env(resolve:PEPPER)%'
services:
# default configuration for services in *this* file

View File

@ -47,6 +47,9 @@ class PasswordEncoder implements LegacyPasswordHasherInterface
$completedPassword = $this->getPasswordToHash($plainPassword, $salt);
foreach ($this->hashAlgoLegacy as $algo) {
if ('ssha' === $algo) {
return $this->compareSsha($hashedPassword, $completedPassword);
}
if ($this->isObsoleteAlgo($algo)) {
if (hash_equals(hash($algo, $completedPassword), $hashedPassword)) {
return true;
@ -98,4 +101,17 @@ class PasswordEncoder implements LegacyPasswordHasherInterface
return $completedPlainPassword;
}
protected function compareSsha($hashPassword, $plainPassword)
{
$base_64_hash_with_salt = substr($hashPassword, 6);
$hash_with_salt = base64_decode($base_64_hash_with_salt);
$hash = substr($hash_with_salt, 0, 20);
$salt = substr($hash_with_salt, 20);
// hash given password
$hash_given = sha1($plainPassword.$salt, true);
return $hash == $hash_given;
}
}