Skip to content

Commit 8fb0ed7

Browse files
Merge branch '5.2' into 5.x
* 5.2: [CI][Psalm] Install stable/released PHPUnit [Security] Add missing Finnish translations [Security][Guard] Prevent user enumeration via response content
2 parents 2ac23c6 + 293919f commit 8fb0ed7

File tree

14 files changed

+118
-12
lines changed

14 files changed

+118
-12
lines changed

.github/workflows/psalm.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
run: |
4040
echo "::group::modify composer.json"
4141
composer remove --no-update --no-interaction symfony/phpunit-bridge
42-
composer require --no-update psalm/phar phpunit/phpunit php-http/discovery psr/event-dispatcher
42+
composer require --no-update psalm/phar phpunit/phpunit:@stable php-http/discovery psr/event-dispatcher
4343
echo "::endgroup::"
4444
echo "::group::composer update"
4545
composer update --no-progress --ansi

src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ private function createFirewall(ContainerBuilder $container, string $id, array $
502502
->replaceArgument(0, $authenticators)
503503
->replaceArgument(2, new Reference($firewallEventDispatcherId))
504504
->replaceArgument(3, $id)
505-
->replaceArgument(6, $firewall['required_badges'] ?? [])
505+
->replaceArgument(7, $firewall['required_badges'] ?? [])
506506
->addTag('monolog.logger', ['channel' => 'security'])
507507
;
508508

src/Symfony/Bundle/SecurityBundle/Resources/config/guard.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
abstract_arg('Provider-shared Key'),
4646
abstract_arg('Authenticators'),
4747
service('logger')->nullOnInvalid(),
48+
param('security.authentication.hide_user_not_found'),
4849
])
4950
->tag('monolog.logger', ['channel' => 'security'])
5051
;

src/Symfony/Bundle/SecurityBundle/Resources/config/security_authenticator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
abstract_arg('provider key'),
4545
service('logger')->nullOnInvalid(),
4646
param('security.authentication.manager.erase_credentials'),
47+
param('security.authentication.hide_user_not_found'),
4748
abstract_arg('required badges'),
4849
])
4950
->tag('monolog.logger', ['channel' => 'security'])

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function testAuthenticatorManager()
4343
$this->assertEquals(AuthenticatorManager::class, $authenticatorManager->getClass());
4444

4545
// required badges
46-
$this->assertEquals([CsrfTokenBadge::class, RememberMeBadge::class], $authenticatorManager->getArgument(6));
46+
$this->assertEquals([CsrfTokenBadge::class, RememberMeBadge::class], $authenticatorManager->getArgument(7));
4747

4848
// login link
4949
$expiredStorage = $container->getDefinition($expiredStorageId = 'security.authenticator.expired_login_link_storage.main');

src/Symfony/Bundle/SecurityBundle/Tests/Functional/AuthenticatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function testFirewallUserProvider($email, $withinFirewall)
4040
if ($withinFirewall) {
4141
$this->assertJsonStringEqualsJsonString('{"email":"'.$email.'"}', $client->getResponse()->getContent());
4242
} else {
43-
$this->assertJsonStringEqualsJsonString('{"error":"Username could not be found."}', $client->getResponse()->getContent());
43+
$this->assertJsonStringEqualsJsonString('{"error":"Invalid credentials."}', $client->getResponse()->getContent());
4444
}
4545
}
4646

src/Symfony/Bundle/SecurityBundle/Tests/Functional/FormLoginTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public function testLoginThrottling()
142142

143143
break;
144144
case 2: // Third attempt with unexisting username
145-
$this->assertStringContainsString('Username could not be found.', $text, 'Invalid response on 3rd attempt');
145+
$this->assertStringContainsString('Invalid credentials.', $text, 'Invalid response on 3rd attempt');
146146

147147
break;
148148
case 3: // Fourth attempt : still login throttling !

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\Security\Core\Authentication\Token\SwitchUserToken;
1515
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
1616
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
17+
use Symfony\Component\Security\Core\Exception\AccountStatusException;
1718
use Symfony\Component\Security\Core\Exception\AuthenticationException;
1819
use Symfony\Component\Security\Core\Exception\AuthenticationServiceException;
1920
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
@@ -79,7 +80,7 @@ public function authenticate(TokenInterface $token)
7980
$this->userChecker->checkPreAuth($user);
8081
$this->checkAuthentication($user, $token);
8182
$this->userChecker->checkPostAuth($user);
82-
} catch (BadCredentialsException $e) {
83+
} catch (AccountStatusException $e) {
8384
if ($this->hideUserNotFoundExceptions) {
8485
throw new BadCredentialsException('Bad credentials.', 0, $e);
8586
}

src/Symfony/Component/Security/Core/Resources/translations/security.fi.xlf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@
7070
<source>Invalid or expired login link.</source>
7171
<target>Virheellinen tai vanhentunut kirjautumislinkki.</target>
7272
</trans-unit>
73+
<trans-unit id="19">
74+
<source>Too many failed login attempts, please try again in %minutes% minute.</source>
75+
<target>Liian monta epäonnistunutta kirjautumisyritystä, yritä uudelleen %minutes% minuutin kuluttua.</target>
76+
</trans-unit>
77+
<trans-unit id="20">
78+
<source>Too many failed login attempts, please try again in %minutes% minutes.</source>
79+
<target>Liian monta epäonnistunutta kirjautumisyritystä, yritä uudelleen %minutes% minuutin kuluttua.</target>
80+
</trans-unit>
7381
</body>
7482
</file>
7583
</xliff>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function testAuthenticateWhenProviderDoesNotReturnAnUserInterface()
8383

8484
public function testAuthenticateWhenPreChecksFails()
8585
{
86-
$this->expectException(CredentialsExpiredException::class);
86+
$this->expectException(BadCredentialsException::class);
8787
$userChecker = $this->createMock(UserCheckerInterface::class);
8888
$userChecker->expects($this->once())
8989
->method('checkPreAuth')
@@ -101,7 +101,7 @@ public function testAuthenticateWhenPreChecksFails()
101101

102102
public function testAuthenticateWhenPostChecksFails()
103103
{
104-
$this->expectException(AccountExpiredException::class);
104+
$this->expectException(BadCredentialsException::class);
105105
$userChecker = $this->createMock(UserCheckerInterface::class);
106106
$userChecker->expects($this->once())
107107
->method('checkPostAuth')
@@ -128,7 +128,7 @@ public function testAuthenticateWhenPostCheckAuthenticationFails()
128128
;
129129
$provider->expects($this->once())
130130
->method('checkAuthentication')
131-
->willThrowException(new BadCredentialsException())
131+
->willThrowException(new CredentialsExpiredException())
132132
;
133133

134134
$provider->authenticate($this->getSupportedToken());

0 commit comments

Comments
 (0)