8000 Merge branch '3.4' into 4.4 · symfony/symfony@cbdb66a · GitHub
[go: up one dir, main page]

Skip to content

Commit cbdb66a

Browse files
Merge branch '3.4' into 4.4
* 3.4: [Security\Core] Fix user enumeration via response body on invalid credentials Update VERSION for 3.4.48 Update CHANGELOG for 3.4.48
2 parents 5f8035e + 1ad13fe commit cbdb66a

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/Symfony/Component/Security/Core/Authentication/Provider/UserAuthenticationProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function authenticate(TokenInterface $token)
8181
$this->userChecker->checkPreAuth($user);
8282
$this->checkAuthentication($user, $token);
8383
$this->userChecker->checkPostAuth($user);
84-
} catch (AccountStatusException $e) {
84+
} catch (AccountStatusException | BadCredentialsException $e) {
8585
if ($this->hideUserNotFoundExceptions) {
8686
throw new BadCredentialsException('Bad credentials.', 0, $e);
8787
}

src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,24 @@ public function testAuthenticateWhenUsernameIsNotFoundAndHideIsTrue()
6969
$provider->authenticate($this->getSupportedToken());
7070
}
7171

72+
public function testAuthenticateWhenCredentialsAreInvalidAndHideIsTrue()
73+
{
74+
$provider = $this->getProvider();
75+
$provider->expects($this->once())
76+
->method('retrieveUser')
77+
->willReturn($this->createMock(UserInterface::class))
78+
;
79+
$provider->expects($this->once())
80+
->method('checkAuthentication')
81+
->willThrowException(new BadCredentialsException())
82+
;
83+
84+
$this->expectException(BadCredentialsException::class);
85+
$this->expectExceptionMessage('Bad credentials.');
86+
87+
$provider->authenticate($this->getSupportedToken());
88+
}
89+
7290
public function testAuthenticateWhenProviderDoesNotReturnAnUserInterface()
7391
{
7492
$this->expectException(AuthenticationServiceException::class);

0 commit comments

Comments
 (0)
0