Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

One PR to rule them all #95

Closed
wants to merge 43 commits into from
Closed

One PR to rule them all #95

wants to merge 43 commits into from

Conversation

stephane
Copy link

@stephane stephane commented Aug 3, 2016

No description provided.

magnusstahre and others added 27 commits October 28, 2015 11:26
Unfortunately Python 2.6 does not support dict comprehensions.
When using a dict object to represent an identity the default
jwt_encode_callback handler fails as getattr does not work with dict
objects. This change sets the default value of getattr to None so the
dict get part of the statement is evaluated.
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. =)
If the mimetype is indeed JSON, but strings or arrays are POSTed,
an `AttributeError` will be thrown when trying to call `get()`.
Included a note about deployment to Apache/mod_wsgi gotcha.
As of 0.3.2 flask_jwt creates an endpoint named '_default_auth_request_handler',
no matter what JWT_AUTH_ENDPOINT is
@coveralls
Copy link

coveralls commented Aug 3, 2016

Coverage Status

Coverage increased (+0.1%) to 95.783% when pulling ea36b80 on webstack:fork into c270841 on mattupstate:master.

@rlam3
Copy link

rlam3 commented Aug 4, 2016

Please merge this!

@guillermo-carrasco
Copy link

This is a great library, let's keep the progress, please merge!

CptSpaceToaster and others added 3 commits March 24, 2017 14:40
The JWT_VERIFY_CLAIMS and JWT_REQUIRED_CLAIMS assume that item precense
implies each item should be verified/required, and items that are excluded,
should NOT be verified or required.

Unfortunately, the PyJWT library will merge the supplied list of options
against a list of defaults:
https://github.com/jpadilla/pyjwt/blob/1.4.0/jwt/api_jwt.py#L74-L75

This means that if a user wanted to disable verification on expiration,
a user can NOT change
JWT_VERIFY_CLAIMS = ['signature', 'ext', 'nbf', 'iat']
to
JWT_VERIFY_CLAIMS = ['signature', 'nbf', 'iat']

If a user DOESN'T want it to verify the expiration, then they need to
explicitly set `verify_exp` to `False`.  The current algorithm will
look at the list, see that `verify_exp` was omitted, and pass in nothing
for `verify_exp` , which then makes the PyJWT assume a default (which is
`verify_exp=True`)

To fix, the _default_jwt_decode_handler was updated to generate an
options dictionary that sets each option to `True` or `False` so
JWT_VERIFY_CLAIMS = ['signature', 'nbf', 'iat']
Now will properly set `verify_ext=False`.
@stephane
Copy link
Author

The project is dead if you really want to use flask-jwt (for existing project), you can use my fork https://github.com/webstack/flask-jwt (and the public release on PyPi https://pypi.org/project/Webstack-Flask-JWT/). I don't use Flask anymore so I don't intend to maintain it.

For newer projects, I recommend https://github.com/vimalloc/flask-jwt-extended

@stephane stephane closed this Apr 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet