Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Security] json auth listener should not produce a 500 response on bad request format#22034

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

Merged
fabpot merged 1 commit intosymfony:masterfromogizanagi:fix/3.3/security/json_login
Mar 22, 2017
Merged

[Security] json auth listener should not produce a 500 response on bad request format#22034

fabpot merged 1 commit intosymfony:masterfromogizanagi:fix/3.3/security/json_login
Mar 22, 2017

Conversation

@ogizanagi
Copy link
Contributor

@ogizanagiogizanagi commentedMar 17, 2017
edited
Loading

QA
Branch?master
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed ticketsN/A
LicenseMIT
Doc PRN/A

To me, it looks wrong to simply throw aBadCredentialsException in the wild, which produces a 500 (unless an entrypoint handles it, which you probably don't have on a json login firewall). There isn't any server error, the client request originated the error due to a wrong format.

Instead, the listener should give a chance to the failure handler to resolve it, and return a proper 4XX response. (BTW, theUsernamePasswordFormAuthenticationListener also throws a similarBadCredentialsException on a too long submitted username, which is caught and forwarded to the failure handler)

Better diff:https://github.com/symfony/symfony/pull/22034/files?w=1

BTW, should we have another exception type likeBadCredentialsFormatException or whatever in order to distinct a properBadCredentialsException from a format issue in a failure listener?

@dunglas
Copy link
Member

Indeed, it looks reasonable. 👍

@fabpot
Copy link
Member

Thank you@ogizanagi.

@fabpotfabpot merged commitcb175a4 intosymfony:masterMar 22, 2017
fabpot added a commit that referenced this pull requestMar 22, 2017
…ponse on bad request format (ogizanagi)This PR was merged into the 3.3-dev branch.Discussion----------[Security] json auth listener should not produce a 500 response on bad request format| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | N/A| License       | MIT| Doc PR        | N/ATo me, it looks wrong to simply throw a `BadCredentialsException` in the wild, which produces a 500 (unless an entrypoint handles it, which you probably don't have on a json login firewall). There isn't any server error, the client request originated the error due to a wrong format.Instead, the listener should give a chance to the failure handler to resolve it, and return a proper 4XX response. (BTW, the `UsernamePasswordFormAuthenticationListener` also throws a similar `BadCredentialsException` on a too long submitted username, which is caught and forwarded to the failure handler)Better diff:https://github.com/symfony/symfony/pull/22034/files?w=1BTW, should we have another exception type like `BadCredentialsFormatException` or whatever in order to distinct a proper `BadCredentialsException` from a format issue in a failure listener?Commits-------cb175a4 [Security] json auth listener should not produce a 500 response on bad request format
@ogizanagiogizanagi deleted the fix/3.3/security/json_login branchMarch 22, 2017 20:55
fabpot added a commit that referenced this pull requestApr 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/AIn#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
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

3.3

Development

Successfully merging this pull request may close these issues.

5 participants

@ogizanagi@dunglas@fabpot@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp