Skip to content
This repository was archived by the owner on May 31, 2024. It is now read-only.

Commit 604dacd

Browse files
committed
Merge branch '4.3' into 4.4
* 4.3: [DotEnv] Remove `usePutEnv` property default value Set up typo fix [Validator] Allow underscore character "_" in URL username and password [SecurityBundle] Passwords are not encoded when algorithm set to \"true\" do not validate passwords when the hash is null [DI] fix resolving bindings for named TypedReference [DI] Fix making the container path-independent when the app is in /app Allow copy instead of symlink for ./link script [FrameworkBundle] resolve service locators in `debug:*` commands bumped Symfony version to 4.3.10 updated VERSION for 4.3.9 updated CHANGELOG for 4.3.9 bumped Symfony version to 3.4.37 updated VERSION for 3.4.36 update CONTRIBUTORS for 3.4.36 updated CHANGELOG for 3.4.36 Add test on ServerLogHandler
2 parents 26f6ceb + 827437e commit 604dacd

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

Core/Authentication/Provider/DaoAuthenticationProvider.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ protected function checkAuthentication(UserInterface $user, UsernamePasswordToke
5555
throw new BadCredentialsException('The presented password cannot be empty.');
5656
}
5757

58+
if (null === $user->getPassword()) {
59+
throw new BadCredentialsException('The presented password is invalid.');
60+
}
61+
5862
$encoder = $this->encoderFactory->getEncoder($user);
5963

6064
if (!$encoder->isPasswordValid($user->getPassword(), $presentedPassword, $user->getSalt())) {

Core/Encoder/UserPasswordEncoder.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ public function encodePassword(UserInterface $user, $plainPassword)
4242
*/
4343
public function isPasswordValid(UserInterface $user, $raw)
4444
{
45+
if (null === $user->getPassword()) {
46+
return false;
47+
}
48+
4549
$encoder = $this->encoderFactory->getEncoder($user);
4650

4751
return $encoder->isPasswordValid($user->getPassword(), $raw, $user->getSalt());

Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public function testCheckAuthenticationWhenCredentialsAre0()
152152

153153
$method->invoke(
154154
$provider,
155-
$this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(),
155+
new User('username', 'password'),
156156
$token
157157
);
158158
}
@@ -176,7 +176,7 @@ public function testCheckAuthenticationWhenCredentialsAreNotValid()
176176
->willReturn('foo')
177177
;
178178

179-
$method->invoke($provider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(), $token);
179+
$method->invoke($provider, new User('username', 'password'), $token);
180180
}
181181

182182
public function testCheckAuthenticationDoesNotReauthenticateWhenPasswordHasChanged()
@@ -248,7 +248,7 @@ public function testCheckAuthentication()
248248
->willReturn('foo')
249249
;
250250

251-
$method->invoke($provider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(), $token);
251+
$method->invoke($provider, new User('username', 'password'), $token);
252252
}
253253

254254
public function testPasswordUpgrades()

Core/Validator/Constraints/UserPasswordValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function validate($password, Constraint $constraint)
5353

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

56-
if (!$encoder->isPasswordValid($user->getPassword(), $password, $user->getSalt())) {
56+
if (null === $user->getPassword() || !$encoder->isPasswordValid($user->getPassword(), $password, $user->getSalt())) {
5757
$this->context->addViolation($constraint->message);
5858
}
5959
}

0 commit comments

Comments
 (0)