mirror of
https://github.com/SuiteCRM/SuiteCRM-Core.git
synced 2025-08-29 17:46:02 +08:00
Symfony 5.3 - Update password_hashers
This commit is contained in:
parent
db33001e53
commit
fee04d30f9
2 changed files with 15 additions and 9 deletions
|
@ -2,7 +2,7 @@ security:
|
|||
enable_authenticator_manager: true
|
||||
password_hashers:
|
||||
App\Module\Users\Entity\User:
|
||||
id: App\Security\LegacyPasswordEncoder
|
||||
id: App\Security\LegacyPasswordHasher
|
||||
app_hasher:
|
||||
id: 'App\Security\LegacyPasswordHasher'
|
||||
|
||||
|
|
|
@ -28,35 +28,36 @@
|
|||
namespace App\Security;
|
||||
|
||||
use Symfony\Component\PasswordHasher\Hasher\CheckPasswordLengthTrait;
|
||||
use Symfony\Component\PasswordHasher\PasswordHasherInterface;
|
||||
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
|
||||
|
||||
class LegacyPasswordHasher
|
||||
class LegacyPasswordHasher implements PasswordHasherInterface
|
||||
{
|
||||
|
||||
use CheckPasswordLengthTrait;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function encodePassword($raw, $salt): string
|
||||
public function hash($plainPassword): string
|
||||
{
|
||||
if ($this->isPasswordTooLong($raw)) {
|
||||
if ($this->isPasswordTooLong($plainPassword)) {
|
||||
throw new BadCredentialsException('Invalid password.');
|
||||
}
|
||||
|
||||
return password_hash(strtolower(md5($raw)), PASSWORD_DEFAULT);
|
||||
return password_hash(strtolower(md5($plainPassword)), PASSWORD_DEFAULT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function isPasswordValid($encoded, $raw, $salt): bool
|
||||
public function verify($hashedPassword, $plainPassword): bool
|
||||
{
|
||||
if ($this->isPasswordTooLong($raw)) {
|
||||
if ($this->isPasswordTooLong($plainPassword)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$userHash = $encoded;
|
||||
$password = (md5($raw));
|
||||
$userHash = $hashedPassword;
|
||||
$password = (md5($plainPassword));
|
||||
|
||||
$valid = self::checkPasswordMD5($password, $userHash);
|
||||
|
||||
|
@ -87,4 +88,9 @@ class LegacyPasswordHasher
|
|||
|
||||
return $valid;
|
||||
}
|
||||
|
||||
public function needsRehash(string $hashedPassword): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue