Skip to content

Commit

Permalink
Merge branch '3.4' into 4.4
Browse files Browse the repository at this point in the history
* 3.4:
  [Security][Guard] Prevent user enumeration via response content
  • Loading branch information
nicolas-grekas committed May 12, 2021
2 parents b02e7d7 + 7e1a526 commit 8188709
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Authentication/Provider/UserAuthenticationProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Symfony\Component\Security\Core\Authentication\Token\SwitchUserToken;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Core\Exception\AccountStatusException;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Core\Exception\AuthenticationServiceException;
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
Expand Down Expand Up @@ -80,7 +81,7 @@ public function authenticate(TokenInterface $token)
$this->userChecker->checkPreAuth($user);
$this->checkAuthentication($user, $token);
$this->userChecker->checkPostAuth($user);
} catch (BadCredentialsException $e) {
} catch (AccountStatusException $e) {
if ($this->hideUserNotFoundExceptions) {
throw new BadCredentialsException('Bad credentials.', 0, $e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function testAuthenticateWhenProviderDoesNotReturnAnUserInterface()

public function testAuthenticateWhenPreChecksFails()
{
$this->expectException(CredentialsExpiredException::class);
$this->expectException(BadCredentialsException::class);
$userChecker = $this->createMock(UserCheckerInterface::class);
$userChecker->expects($this->once())
->method('checkPreAuth')
Expand All @@ -101,7 +101,7 @@ public function testAuthenticateWhenPreChecksFails()

public function testAuthenticateWhenPostChecksFails()
{
$this->expectException(AccountExpiredException::class);
$this->expectException(BadCredentialsException::class);
$userChecker = $this->createMock(UserCheckerInterface::class);
$userChecker->expects($this->once())
->method('checkPostAuth')
Expand All @@ -128,7 +128,7 @@ public function testAuthenticateWhenPostCheckAuthenticationFails()
;
$provider->expects($this->once())
->method('checkAuthentication')
->willThrowException(new BadCredentialsException())
->willThrowException(new CredentialsExpiredException())
;

$provider->authenticate($this->getSupportedToken());
Expand Down

0 comments on commit 8188709

Please sign in to comment.