Skip to content

Commit

Permalink
bug #34802 [Security] Check UserInterface::getPassword is not null be…
Browse files Browse the repository at this point in the history
…fore calling needsRehash (dbrekelmans)

This PR was squashed before being merged into the 4.4 branch (closes #34802).

Discussion
----------

[Security] Check UserInterface::getPassword is not null before calling needsRehash

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

`Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface::needsRehash()` expects a string as the input argument. In some cases `Symfony\Component\Security\Core\User\UserInterface::getPassword()` is used as the input argument, but this function can return `null` resulting in a potential type error.

Commits
-------

8e4cf49 [Security] Check UserInterface::getPassword is not null before calling needsRehash
  • Loading branch information
chalasr committed Dec 6, 2019
2 parents 70dec3c + 8e4cf49 commit 215dca4
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public function isPasswordValid(UserInterface $user, $raw)
*/
public function needsRehash(UserInterface $user): bool
{
if (null === $user->getPassword()) {
return false;
}

$encoder = $this->encoderFactory->getEncoder($user);

return method_exists($encoder, 'needsRehash') && $encoder->needsRehash($user->getPassword());
Expand Down

0 comments on commit 215dca4

Please sign in to comment.