Skip to content

Commit 61515b6

Browse files
Merge branch '3.0'
* 3.0: (31 commits) Drop hirak/prestissimo [MonologBridge] Uninstallable together with symfony/http-kernel in 3.0.6 bumped Symfony version to 3.0.7 updated VERSION for 3.0.6 updated CHANGELOG for 3.0.6 bumped Symfony version to 2.8.7 updated VERSION for 2.8.6 updated CHANGELOG for 2.8.6 bumped Symfony version to 2.7.14 updated VERSION for 2.7.13 updated CHANGELOG for 2.7.13 bumped Symfony version to 2.3.42 [Debug] Fix fatal error handlers on PHP 7 updated VERSION for 2.3.41 update CONTRIBUTORS for 2.3.41 updated CHANGELOG for 2.3.41 fixed bad merge Fixed issue with blank password with Ldap limited the maximum length of a submitted username [2.3][Component/Security] Fixed phpdoc in AnonymousToken constructor for user param ... Conflicts: src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php src/Symfony/Component/HttpKernel/Kernel.php
2 parents f1c0655 + a86e6a1 commit 61515b6

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Firewall/SimpleFormAuthenticationListener.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
2222
use Symfony\Component\Security\Http\Authentication\SimpleFormAuthenticatorInterface;
2323
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
24+
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
2425
use Symfony\Component\Security\Core\Security;
2526
use Symfony\Component\Security\Http\HttpUtils;
2627
use Symfony\Component\Security\Http\ParameterBagUtils;
@@ -107,6 +108,10 @@ protected function attemptAuthentication(Request $request)
107108
$password = ParameterBagUtils::getRequestParameterValue($request, $this->options['password_parameter']);
108109
}
109110

111+
if (strlen($username) > Security::MAX_USERNAME_LENGTH) {
112+
throw new BadCredentialsException('Invalid username.');
113+
}
114+
110115
$request->getSession()->set(Security::LAST_USERNAME, $username);
111116

112117
$token = $this->simpleAuthenticator->createToken($request, $username, $password, $this->providerKey);

Firewall/UsernamePasswordFormAuthenticationListener.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
2424
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
2525
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
26+
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
2627
use Symfony\Component\Security\Core\Exception\InvalidCsrfTokenException;
2728
use Symfony\Component\Security\Core\Security;
2829
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@@ -83,6 +84,10 @@ protected function attemptAuthentication(Request $request)
8384
$password = ParameterBagUtils::getRequestParameterValue($request, $this->options['password_parameter']);
8485
}
8586

87+
if (strlen($username) > Security::MAX_USERNAME_LENGTH) {
88+
throw new BadCredentialsException('Invalid username.');
89+
}
90+
8691
$request->getSession()->set(Security::LAST_USERNAME, $username);
8792

8893
return $this->authenticationManager->authenticate(new UsernamePasswordToken($username, $password, $this->providerKey));

0 commit comments

Comments
 (0)