summaryrefslogtreecommitdiffstats
path: root/Http
diff options
context:
space:
mode:
authorFabien Potencier <fabien.potencier@gmail.com>2016-05-09 14:24:00 -0500
committerFabien Potencier <fabien.potencier@gmail.com>2016-05-09 14:24:00 -0500
commit231aafdaf4c9abbc812139bd6f909008fec91cd7 (patch)
treefcb9f7445dd5d955fae4b6bee33884344997be5d /Http
parent9e447f3c6d7cd5ac712a967840edcd504f488ca2 (diff)
parent1eebd2bd10b38c068aa05aa123201c53def1bc6d (diff)
downloadsymfony-security-231aafdaf4c9abbc812139bd6f909008fec91cd7.zip
symfony-security-231aafdaf4c9abbc812139bd6f909008fec91cd7.tar.gz
symfony-security-231aafdaf4c9abbc812139bd6f909008fec91cd7.tar.bz2
Merge branch '2.7' into 2.8
* 2.7: limited the maximum length of a submitted username
Diffstat (limited to 'Http')
-rw-r--r--Http/Firewall/SimpleFormAuthenticationListener.php5
-rw-r--r--Http/Firewall/UsernamePasswordFormAuthenticationListener.php5
2 files changed, 10 insertions, 0 deletions
diff --git a/Http/Firewall/SimpleFormAuthenticationListener.php b/Http/Firewall/SimpleFormAuthenticationListener.php
index 4363763..331d018 100644
--- a/Http/Firewall/SimpleFormAuthenticationListener.php
+++ b/Http/Firewall/SimpleFormAuthenticationListener.php
@@ -24,6 +24,7 @@ use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerI
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
use Symfony\Component\Security\Core\Authentication\SimpleFormAuthenticatorInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
+use Symfony\Component\Security\Core\Exception\BadCredentialsException;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Security\Http\HttpUtils;
use Symfony\Component\Security\Http\ParameterBagUtils;
@@ -127,6 +128,10 @@ class SimpleFormAuthenticationListener extends AbstractAuthenticationListener
$password = ParameterBagUtils::getRequestParameterValue($request, $this->options['password_parameter']);
}
+ if (strlen($username) > Security::MAX_USERNAME_LENGTH) {
+ throw new BadCredentialsException('Invalid username.');
+ }
+
$request->getSession()->set(Security::LAST_USERNAME, $username);
$token = $this->simpleAuthenticator->createToken($request, $username, $password, $this->providerKey);
diff --git a/Http/Firewall/UsernamePasswordFormAuthenticationListener.php b/Http/Firewall/UsernamePasswordFormAuthenticationListener.php
index 24c3ca6..866d0c3 100644
--- a/Http/Firewall/UsernamePasswordFormAuthenticationListener.php
+++ b/Http/Firewall/UsernamePasswordFormAuthenticationListener.php
@@ -25,6 +25,7 @@ use Symfony\Component\Security\Http\HttpUtils;
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
+use Symfony\Component\Security\Core\Exception\BadCredentialsException;
use Symfony\Component\Security\Core\Exception\InvalidArgumentException;
use Symfony\Component\Security\Core\Exception\InvalidCsrfTokenException;
use Symfony\Component\Security\Core\Security;
@@ -102,6 +103,10 @@ class UsernamePasswordFormAuthenticationListener extends AbstractAuthenticationL
$password = ParameterBagUtils::getRequestParameterValue($request, $this->options['password_parameter']);
}
+ if (strlen($username) > Security::MAX_USERNAME_LENGTH) {
+ throw new BadCredentialsException('Invalid username.');
+ }
+
$request->getSession()->set(Security::LAST_USERNAME, $username);
return $this->authenticationManager->authenticate(new UsernamePasswordToken($username, $password, $this->providerKey));