Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Security] Enforce maximum username length in UserBadge#46584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -13,6 +13,7 @@ | ||
| use Symfony\Component\Security\Core\Exception\AuthenticationException; | ||
| use Symfony\Component\Security\Core\Exception\AuthenticationServiceException; | ||
| use Symfony\Component\Security\Core\Exception\BadCredentialsException; | ||
| use Symfony\Component\Security\Core\Exception\UserNotFoundException; | ||
| use Symfony\Component\Security\Core\User\UserInterface; | ||
| use Symfony\Component\Security\Http\EventListener\UserProviderListener; | ||
| @@ -27,6 +28,8 @@ | ||
| */ | ||
| class UserBadge implements BadgeInterface | ||
| { | ||
| public const MAX_USERNAME_LENGTH = 4096; | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Perhaps out of context but why reintroducing username here? Why not user identifier? Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. We need a more advanced BC layer for that. I'm going to work on getting rid of that "username" leftovers in a dedicated PR if we don't do it here (there's also Security::LAST_USERNAME) | ||
| private string $userIdentifier; | ||
| /** @var callable|null */ | ||
| private $userLoader; | ||
| @@ -47,6 +50,10 @@ class UserBadge implements BadgeInterface | ||
| */ | ||
| public function __construct(string $userIdentifier, callable $userLoader = null) | ||
| { | ||
| if (\strlen($userIdentifier) > self::MAX_USERNAME_LENGTH) { | ||
| throw new BadCredentialsException('Username too long.'); | ||
| } | ||
| $this->userIdentifier = $userIdentifier; | ||
| $this->userLoader = $userLoader; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,11 @@ | ||
| CHANGELOG | ||
| ========= | ||
| 6.2 | ||
| --- | ||
| * Add maximum username length enforcement of 4096 characters in `UserBadge` | ||
| 6.0 | ||
| --- | ||