[Security] Handle bad request format in json auth listener#22569
Merged
fabpot merged 1 commit intosymfony:masterfrom Apr 29, 2017
ogizanagi:feat
8000
ure/3.3/security/json_login_bad_format_ex
Merged
[Security] Handle bad request format in json auth listener#22569fabpot merged 1 commit intosymfony:masterfrom ogizanagi:feature/3.3/security/json_login_bad_format_ex
fabpot merged 1 commit intosymfony:masterfrom
ogizanagi:feature/3.3/security/json_login_bad_format_ex
Conversation
chalasr
approved these changes
Apr 28, 2017
Member
There was a problem hiding this comment.
👍 These exceptions are not about a failed authentication but a wrongly formatted request (and don't provide any sensitive info) thus should not trigger the authentication failure handler nor any authentication exception to be thrown.
Member
|
Fair enough 👍 |
Member
|
Thank you @ogizanagi. |
fabpot
added a commit
that referenced
this pull request
Apr 29, 2017
… (ogizanagi) This PR was merged into the 3.3-dev branch. Discussion ---------- [Security] Handle bad request format in json auth listener | Q | A | ------------- | --- | Branch? | master (3.3) | Bug fix? | yesish | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | N/A | License | MIT | Doc PR | N/A In #22034, I wondered myself if we shouldn't throw a dedicated exception to handle bad formatted requests and give more inputs to the client by returning a 400 response with an explicit message. ~~Here is a suggestion, introducing a new `BadRequestFormatException` and using it in `UsernamePasswordJsonAuthenticationListener` whenever there is no custom failure handler set (but someone using its own handler should be able to treat the failure properly too).~~ As discussed with @chalasr , it seems better to directly throw a `BadRequestHttpException` as it's actually out of the whole security process. PR updated. Commits ------- 93a8cb9 [Security] Handle bad request format in json auth listener
Member
|
@ogizanagi master is red after this PR has been merged, would you mind looking at it please (or anyone else really?) |
Merged
Contributor
Author
|
|
Member
|
See #22582 |
nicolas-grekas
added a commit
that referenced
this pull request
Apr 29, 2017
This PR was merged into the 3.3-dev branch. Discussion ---------- Fix tests | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #22569 (comment) | License | MIT | Doc PR | n/a Commits ------- b6948dd Fix tests
fabpot
added a commit
that referenced
this pull request
Jan 16, 2018
This PR was merged into the 2.7 branch. Discussion ---------- [Security] Fix fatal error on non string username | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #25612 | License | MIT | Doc PR | n/a That's consistent with what #22569 did for the `json_login` listener. Commits ------- 8f09568 [Security] Fix fatal error on non string username
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In #22034, I wondered myself if we shouldn't throw a dedicated exception to handle bad formatted requests and give more inputs to the client by returning a 400 response with an explicit message.
Here is a suggestion, introducing a newBadRequestFormatExceptionand using it inUsernamePasswordJsonAuthenticationListenerwhenever there is no custom failure handler set (but someone using its own handler should be able to treat the failure properly too).As discussed with @chalasr , it seems better to directly throw a
BadRequestHttpExceptionas it's actually out of the whole security process. PR updated.