This repository was archived by the owner on Feb 22, 2024. It is now read-only.
Stop 500's on a non-JSON /auth request#75
Open
DavidCain wants to merge 2 commits intopallets-eco:masterfrom
Open
Stop 500's on a non-JSON /auth request#75DavidCain wants to merge 2 commits intopallets-eco:masterfrom
DavidCain wants to merge 2 commits intopallets-eco:masterfrom
Conversation
When the request is not JSON (and the `force` flag is False), Flask's `get_json()` will return None: https://github.com/mitsuhiko/flask/blob/0.10.1/flask/wrappers.py#L127 If somebody POSTs to `/auth` with a non-JSON mimetype, the server will 500 with `'NoneType' object has no attribute 'get'`. Additionally, the default second parameter to `get()` is already None - it can be safely omitted. And more than one criterion are criteria. =)
flask_jwt/__init__.py
Outdated
Author
There was a problem hiding this comment.
The second parameter to get() is already None - it can be safely omitted.
If the mimetype is indeed JSON, but strings or arrays are POSTed, an `AttributeError` will be thrown when trying to call `get()`.
|
What about this one? |
Author
|
@mattupstate, any input on this one? It closes a pretty easy mechanism for invoking 500's. |
|
This one is basically the same as #70 |
Author
|
@dequis it's similar, but actually catches errors not handled by #70. If you were to pass a string or array with a valid JSON mimetype, That said, if I'd seen #70, I probably would have just left this as a comment instead of making a new PR. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
When the request is not JSON (and the
forceflag is False), Flask'sget_json()will returnNone.If somebody POSTs to
/authwith a non-JSON mimetype, the server will 500 with'NoneType' object has no attribute 'get'.This fixes this behavior in the default
auth_request_handler.