Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite34cd7d

Browse files
Merge branch '5.2' into 5.x
* 5.2: [Security\Core] Fix user enumeration via response body on invalid credentials Update VERSION for 3.4.48 Update CHANGELOG for 3.4.48
2 parentsd319beb +309f36d commite34cd7d

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
useSymfony\Component\Security\Core\Exception\AuthenticationException;
1919
useSymfony\Component\Security\Core\Exception\AuthenticationServiceException;
2020
useSymfony\Component\Security\Core\Exception\BadCredentialsException;
21+
useSymfony\Component\Security\Core\Exception\CustomUserMessageAccountStatusException;
2122
useSymfony\Component\Security\Core\Exception\UserNotFoundException;
2223
useSymfony\Component\Security\Core\User\UserCheckerInterface;
2324
useSymfony\Component\Security\Core\User\UserInterface;
@@ -84,8 +85,8 @@ public function authenticate(TokenInterface $token)
8485
$this->userChecker->checkPreAuth($user);
8586
$this->checkAuthentication($user,$token);
8687
$this->userChecker->checkPostAuth($user);
87-
}catch (AccountStatusException$e) {
88-
if ($this->hideUserNotFoundExceptions) {
88+
}catch (AccountStatusException|BadCredentialsException$e) {
89+
if ($this->hideUserNotFoundExceptions && !$einstanceof CustomUserMessageAccountStatusException) {
8990
thrownewBadCredentialsException('Bad credentials.',0,$e);
9091
}
9192

‎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+
publicfunctiontestAuthenticateWhenCredentialsAreInvalidAndHideIsTrue()
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(newBadCredentialsException())
82+
;
83+
84+
$this->expectException(BadCredentialsException::class);
85+
$this->expectExceptionMessage('Bad credentials.');
86+
87+
$provider->authenticate($this->getSupportedToken());
88+
}
89+
7290
publicfunctiontestAuthenticateWhenProviderDoesNotReturnAnUserInterface()
7391
{
7492
$this->expectException(AuthenticationServiceException::class);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp