Skip to content

Commit 3e460b4

Browse files
committed
limited the maximum length of a submitted username
1 parent ad9962a commit 3e460b4

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Firewall/UsernamePasswordFormAuthenticationListener.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Symfony\Component\Security\Http\HttpUtils;
2121
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
2222
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
23+
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
2324
use Symfony\Component\Security\Core\Exception\InvalidCsrfTokenException;
2425
use Symfony\Component\Security\Core\SecurityContextInterface;
2526
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@@ -83,6 +84,10 @@ protected function attemptAuthentication(Request $request)
8384
$password = $request->get($this->options['password_parameter'], null, true);
8485
}
8586

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

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

0 commit comments

Comments
 (0)