Merge branch '5.2' into 5.x

* 5.2:
  run tests against doctrine/persistence 2.2 again
  [Security] Do not try to rehash null-passwords
  Small phpdoc imporvement
This commit is contained in:
Christian Flothmann 2021-05-01 16:00:17 +02:00
commit 83fd6ed8fb
4 changed files with 15 additions and 2 deletions

View File

@ -281,7 +281,6 @@ install:
elif [[ $deps = low ]]; then elif [[ $deps = low ]]; then
echo "$COMPONENTS" | parallel --gnu "tfold {} 'cd {} && $COMPOSER_UP --prefer-lowest --prefer-stable && $PHPUNIT_X'" echo "$COMPONENTS" | parallel --gnu "tfold {} 'cd {} && $COMPOSER_UP --prefer-lowest --prefer-stable && $PHPUNIT_X'"
else else
composer require --no-update doctrine/persistence:2.1.*
if [[ $PHP = 8.0* ]]; then if [[ $PHP = 8.0* ]]; then
# add return types before running the test suite # add return types before running the test suite
sed -i 's/"\*\*\/Tests\/"//' composer.json sed -i 's/"\*\*\/Tests\/"//' composer.json

View File

@ -698,7 +698,7 @@ class Request
* flexibility in controllers, it is better to explicitly get request parameters from the appropriate * flexibility in controllers, it is better to explicitly get request parameters from the appropriate
* public property instead (attributes, query, request). * public property instead (attributes, query, request).
* *
* Order of precedence: PATH (routing placeholders or custom attributes), GET, BODY * Order of precedence: PATH (routing placeholders or custom attributes), GET, POST
* *
* @param mixed $default The default value if the parameter key does not exist * @param mixed $default The default value if the parameter key does not exist
* *

View File

@ -58,6 +58,10 @@ class PasswordMigratingListener implements EventSubscriberInterface
} }
$user = $passport->getUser(); $user = $passport->getUser();
if (null === $user->getPassword()) {
return;
}
$passwordHasher = $this->hasherFactory instanceof EncoderFactoryInterface ? $this->hasherFactory->getEncoder($user) : $this->hasherFactory->getPasswordHasher($user); $passwordHasher = $this->hasherFactory instanceof EncoderFactoryInterface ? $this->hasherFactory->getEncoder($user) : $this->hasherFactory->getPasswordHasher($user);
if (!$passwordHasher->needsRehash($user->getPassword())) { if (!$passwordHasher->needsRehash($user->getPassword())) {
return; return;

View File

@ -110,6 +110,16 @@ class PasswordMigratingListenerTest extends TestCase
$this->listener->onLoginSuccess($event); $this->listener->onLoginSuccess($event);
} }
public function testUserWithoutPassword()
{
$this->user = new User('test', null);
$this->encoderFactory->expects($this->never())->method('getEncoder');
$event = $this->createEvent(new SelfValidatingPassport(new UserBadge('test', function () { return $this->user; }), [new PasswordUpgradeBadge('pa$$word')]));
$this->listener->onLoginSuccess($event);
}
private function createPasswordUpgrader() private function createPasswordUpgrader()
{ {
return $this->getMockForAbstractClass(TestMigratingUserProvider::class); return $this->getMockForAbstractClass(TestMigratingUserProvider::class);