Skip to content

Commit abecff7

Browse files
committed
bis
1 parent b073c43 commit abecff7

File tree

5 files changed

+15
-21
lines changed

5 files changed

+15
-21
lines changed

.github/workflows/unit-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
([ -d "$COMPOSER_HOME" ] || mkdir "$COMPOSER_HOME") && cp .github/composer-config.json "$COMPOSER_HOME/config.json"
6666
6767
echo COLUMNS=120 >> $GITHUB_ENV
68-
echo PHPUNIT="$(pwd)/phpunit --exclude-group tty,benchmark,intl-data,integration" >> $GITHUB_ENV
68+
echo PHPUNIT="$(pwd)/phpunit --exclude-group tty,benchmark,intl-data,integration --debug" >> $GITHUB_ENV
6969
echo COMPOSER_UP='composer update --no-progress --ansi' >> $GITHUB_ENV
7070
7171
SYMFONY_VERSIONS=$(git ls-remote -q --heads | cut -f2 | grep -o '/[1-9][0-9]*\.[0-9].*' | sort -V)

src/Symfony/Component/Security/Http/Authenticator/FormLoginAuthenticator.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,6 @@ private function getCredentials(Request $request): array
132132

133133
$credentials['username'] = trim($credentials['username']);
134134

135-
if (\strlen($credentials['username']) > self::MAX_USERNAME_LENGTH) {
136-
throw new BadCredentialsException('Invalid username.');
137-
}
138-
139135
$request->getSession()->set(SecurityRequestAttributes::LAST_USERNAME, $credentials['username']);
140136

141137
return $credentials;

src/Symfony/Component/Security/Http/Authenticator/JsonLoginAuthenticator.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,10 @@ public function authenticate(Request $request): Passport
8585
throw $e;
8686
}
8787

88+
$userBadge = new UserBadge($credentials['username'], [$this->userProvider, 'loadUserByIdentifier']);
89+
8890
$passport = new Passport(
89-
new UserBadge($credentials['username'], $this->userProvider->loadUserByIdentifier(...)),
91+
$userBadge,
9092
new PasswordCredentials($credentials['password'])
9193
);
9294
if ($this->userProvider instanceof PasswordUpgraderInterface) {
@@ -149,10 +151,6 @@ private function getCredentials(Request $request)
149151
if (!\is_string($credentials['username'])) {
150152
throw new BadRequestHttpException(sprintf('The key "%s" must be a string.', $this->options['username_path']));
151153
}
152-
153-
if (\strlen($credentials['username']) > self::MAX_USERNAME_LENGTH) {
154-
throw new BadCredentialsException('Invalid username.');
155-
}
156154
} catch (AccessException $e) {
157155
throw new BadRequestHttpException(sprintf('The key "%s" must be provided.', $this->options['username_path']), $e);
158156
}

src/Symfony/Component/Security/Http/Tests/Authenticator/FormLoginAuthenticatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function testHandleWhenUsernameLength($username, $ok)
5050
$this->expectNotToPerformAssertions();
5151
} else {
5252
$this->expectException(BadCredentialsException::class);
53-
$this->expectExceptionMessage('Invalid username.');
53+
$this->expectExceptionMessage('Username too long.');
5454
}
5555

5656
$request = Request::create('/login_check', 'POST', ['_username' => $username, '_password' => 's$cr$t']);

src/Symfony/Component/Security/Http/Tests/Authenticator/JsonLoginAuthenticatorTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
use Symfony\Component\Security\Core\Exception\AuthenticationException;
1818
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
1919
use Symfony\Component\Security\Core\User\InMemoryUserProvider;
20+
use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface;
21+
use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface;
2022
use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface;
2123
use Symfony\Component\Security\Http\Authenticator\JsonLoginAuthenticator;
2224
use Symfony\Component\Security\Http\Authenticator\Passport\Credentials\PasswordCredentials;
@@ -91,17 +93,19 @@ public function testAuthenticateWithCustomPath()
9193
$this->assertEquals('foo', $passport->getBadge(PasswordCredentials::class)->getPassword());
9294
}
9395

94-
/**
95-
* @dataProvider provideInvalidAuthenticateData
96-
*/
97-
public function testAuthenticateInvalid($request, $errorMessage, $exceptionType = BadRequestHttpException::class)
96+
97+
public function testAuthenticateUsernameTooLong()
9898
{
99-
$this->expectException($exceptionType);
100-
$this->expectExceptionMessage($errorMessage);
99+
$this->expectException(BadCredentialsException::class);
100+
$this->expectExceptionMessage('Username too long.');
101101

102102
$this->setUpAuthenticator();
103103

104+
$username = str_repeat('x', 4097);
105+
$request = new Request([], [], [], [], [], ['HTTP_CONTENT_TYPE' => 'application/json'], sprintf('{"username": "%s", "password": "foo"}', $username));
106+
104107
$this->authenticator->authenticate($request);
108+
$this->setUpAuthenticator();
105109
}
106110

107111
public function provideInvalidAuthenticateData()
@@ -120,10 +124,6 @@ public function provideInvalidAuthenticateData()
120124

121125
$request = new Request([], [], [], [], [], ['HTTP_CONTENT_TYPE' => 'application/json'], '{"username": "dunglas", "password": 1}');
122126
yield [$request, 'The key "password" must be a string.'];
123-
124-
$username = str_repeat('x', AuthenticatorInterface::MAX_USERNAME_LENGTH + 1);
125-
$request = new Request([], [], [], [], [], ['HTTP_CONTENT_TYPE' => 'application/json'], sprintf('{"username": "%s", "password": 1}', $username));
126-
yield [$request, 'Invalid username.', BadCredentialsException::class];
127127
}
128128

129129
public function testAuthenticationFailureWithoutTranslator()

0 commit comments

Comments
 (0)