Skip to content

Fix Exception on empty JSON login: BadCredentials message too generic #61152

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[Security] Replace BadRequestHttpException with BadCredentialsExcepti…
…on on empty username/password
  • Loading branch information
Yashingle1307 committed Jul 18, 2025
commit 98d2d4c0644c7300523203d659ff49ce8e71514f
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Component\Security\Http\Authenticator;

use Symfony\Component\Security\Core\Exception\BadCredentialsException;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand Down Expand Up @@ -147,7 +148,7 @@ private function getCredentials(\stdClass $data): array
$credentials['username'] = $this->propertyAccessor->getValue($data, $this->options['username_path']);

if (!\is_string($credentials['username']) || '' === $credentials['username']) {
throw new BadRequestHttpException(\sprintf('The key "%s" must be a non-empty string.', $this->options['username_path']));
throw new BadRequestHttpException('The key "username" must be a non-empty string.');
}
} catch (AccessException $e) {
throw new BadRequestHttpException(\sprintf('The key "%s" must be provided.', $this->options['username_path']), $e);
Expand All @@ -158,7 +159,7 @@ private function getCredentials(\stdClass $data): array
$this->propertyAccessor->setValue($data, $this->options['password_path'], null);

if (!\is_string($credentials['password']) || '' === $credentials['password']) {
throw new BadRequestHttpException(\sprintf('The key "%s" must be a non-empty string.', $this->options['password_path']));
throw new BadRequestHttpException('The key "password" must be a non-empty string.');
}
} catch (AccessException $e) {
throw new BadRequestHttpException(\sprintf('The key "%s" must be provided.', $this->options['password_path']), $e);
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy