8000 [Security] Fix some broken BC layers · symfony/symfony@842d4c1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 842d4c1

Browse files
committed
[Security] Fix some broken BC layers
1 parent 4d91b8f commit 842d4c1

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

src/Symfony/Component/Security/Core/Encoder/UserPasswordEncoderInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ 10000
1111

1212
namespace Symfony\Component\Security\Core\Encoder;
1313

14-
trigger_deprecation('symfony/security-core', '5.3', sprintf('The "%s" interface is deprecated, use "%s" on hasher implementations that deal with salts instead.', UserPasswordEncoderInterface::class, UserPasswordHasherInterface::class));
14+
trigger_deprecation('symfony/security-core', '5.3', sprintf('The "%s" interface is deprecated, use "%s" instead.', UserPasswordEncoderInterface::class, UserPasswordHasherInterface::class));
1515

1616
use Symfony\Component\Security\Core\User\UserInterface;
1717
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;

src/Symfony/Component/Security/Guard/Provider/GuardAuthenticationProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ private function authenticateViaGuard(AuthenticatorInterface $guardAuthenticator
130130

131131
throw new BadCredentialsException(sprintf('Authentication failed because "%s::checkCredentials()" did not return true.', get_debug_type($guardAuthenticator)));
132132
}
133-
if ($this->userProvider instanceof PasswordUpgraderInterface && $guardAuthenticator instanceof PasswordAuthenticatedInterface && null !== $this->passwordHasher && (null !== $password = $guardAuthenticator->getPassword($token->getCredentials())) && method_exists($this->passwordHasher, 'needsRehash') && $this->passwordHasher->needsRehash($user)) {
134-
if ($this->passwordHasher instanceof PasswordEncoderInterface) {
133+
if ($this->userProvider instanceof PasswordUpgraderInterface && $guardAuthenticator instanceof PasswordAuthenticatedInterface && null !== $this->passwordHasher && (null !== $password = $guardAuthenticator->getPassword($token->getCredentials())) && $this->passwordHasher->needsRehash($user)) {
134+
if ($this->passwordHasher instanceof UserPasswordEncoderInterface) {
135135
// @deprecated since Symfony 5.3
136136
$this->userProvider->upgradePassword($user, $this->passwordHasher->encodePassword($user, $password));
137137
} else {

src/Symfony/Component/Security/Http/EventListener/PasswordMigratingListener.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,14 @@
1212
namespace Symfony\Component\Security\Http\EventListener;
1313

1414
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
15-
use Symfony\Component\PasswordHasher\Exception\InvalidPasswordException;
15+
use Symfony\Component\PasswordHasher\Hasher\PasswordHasherFactoryInterface;
16+
use Symfony\Component\PasswordHasher\PasswordHasherInterface;
1617
use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface;
17-
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
1818
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
1919
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\PasswordUpgradeBadge;
2020
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
2121
use Symfony\Component\Security\Http\Authenticator\Passport\UserPassportInterface;
2222
use Symfony\Component\Security\Http\Event\LoginSuccessEvent;
23-
use Symfony\Component\PasswordHasher\Hasher\PasswordHasherFactoryInterface;
2423

2524
/**
2625
* @author Wouter de Jong <wouter@wouterj.nl>
@@ -82,7 +81,7 @@ public function onLoginSuccess(LoginSuccessEvent $event): void
8281
}
8382
}
8483

85-
$passwordUpgrader->upgradePassword($user, $passwordHasher->hash($plaintextPassword, $user->getSalt()));
84+
$passwordUpgrader->upgradePassword($user, $passwordHasher instanceof PasswordHasherInterface ? $passwordHasher->hash($plaintextPassword, $user->getSalt()) : $passwordHasher->encodePassword($plaintextPassword, $user->getSalt()));
8685
}
8786

8887
public static function getSubscribedEvents(): array

0 commit comments

Comments
 (0)
0