summaryrefslogtreecommitdiffstats
path: root/Http
diff options
context:
space:
mode:
authorFabien Potencier <fabien.potencier@gmail.com>2016-05-01 06:13:23 +0200
committerFabien Potencier <fabien.potencier@gmail.com>2016-05-09 13:29:33 -0500
commit83b345fdf01cb980fb8bd5e15224573d93b8e369 (patch)
tree955da7a10d029847ebb3fd5e46cb3de14c223c52 /Http
parenta2aa4cdad5949c3bebea89e8aece52a74de4798c (diff)
downloadsymfony-security-83b345fdf01cb980fb8bd5e15224573d93b8e369.zip
symfony-security-83b345fdf01cb980fb8bd5e15224573d93b8e369.tar.gz
symfony-security-83b345fdf01cb980fb8bd5e15224573d93b8e369.tar.bz2
limited the maximum length of a submitted usernamev2.3.42v2.3.41origin/2.3
Diffstat (limited to 'Http')
-rw-r--r--Http/Firewall/UsernamePasswordFormAuthenticationListener.php5
1 files changed, 5 insertions, 0 deletions
diff --git a/Http/Firewall/UsernamePasswordFormAuthenticationListener.php b/Http/Firewall/UsernamePasswordFormAuthenticationListener.php
index 2147817..26aeb67 100644
--- a/Http/Firewall/UsernamePasswordFormAuthenticationListener.php
+++ b/Http/Firewall/UsernamePasswordFormAuthenticationListener.php
@@ -20,6 +20,7 @@ use Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterfa
use Symfony\Component\Security\Http\HttpUtils;
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
+use Symfony\Component\Security\Core\Exception\BadCredentialsException;
use Symfony\Component\Security\Core\Exception\InvalidCsrfTokenException;
use Symfony\Component\Security\Core\SecurityContextInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@@ -83,6 +84,10 @@ class UsernamePasswordFormAuthenticationListener extends AbstractAuthenticationL
$password = $request->get($this->options['password_parameter'], null, true);
}
+ if (strlen($username) > SecurityContextInterface::MAX_USERNAME_LENGTH) {
+ throw new BadCredentialsException('Invalid username.');
+ }
+
$request->getSession()->set(SecurityContextInterface::LAST_USERNAME, $username);
return $this->authenticationManager->authenticate(new UsernamePasswordToken($username, $password, $this->providerKey));