-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Security] [LoginLink] Throw InvalidLoginLinkException on missing parameter #48292
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
Conversation
MatTheCat
commented
Nov 23, 2022
Q | A |
---|---|
Branch? | 5.4 |
Bug fix? | yes |
New feature? | no |
Deprecations? | no |
Tickets | Fix #48291 |
License | MIT |
Doc PR | N/A |
9f3b172
to
dcc314e
Compare
src/Symfony/Component/Security/Http/LoginLink/LoginLinkHandler.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Security/Http/LoginLink/LoginLinkHandler.php
Outdated
Show resolved
Hide resolved
dcc314e
to
46f93d3
Compare
throw new InvalidLoginLinkException('Missing "hash" parameter.'); | ||
} | ||
if (!$expires = $request->get('expires')) { | ||
throw new InvalidLoginLinkException('Missing "expires" parameter.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other authenticators throw a BadRequestHttpException
in such cases, I would do the same here. See e.g.
symfony/src/Symfony/Component/Security/Http/Authenticator/JsonLoginAuthenticator.php
Line 161 in c79d4ab
throw new BadRequestHttpException(sprintf('The key "%s" must be a string.', $this->options['password_path'])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm LoginLinkHandlerInterface::consumeLoginLink
is supposed to throw InvalidLoginLinkException
:
symfony/src/Symfony/Component/Security/Http/LoginLink/LoginLinkHandlerInterface.php
Lines 32 to 34 in f67ff76
* Throw InvalidLoginLinkExceptionInterface if the link is invalid. | |
*/ | |
public function consumeLoginLink(Request $request): UserInterface; |
The LoginLinkAuthenticator
then converts it to InvalidLoginLinkAuthenticationException
which triggers its onAuthenticationFailure
method to be called.
Are you sure we should bypass this behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking twice about it, I think it's safer to go with your approach.
Thank you @MatTheCat. |