This repository was archived by the owner on Feb 22, 2024. It is now read-only.
Fix jwt_decode ignoring options#90
Open
CptSpaceToaster wants to merge 1 commit intopallets-eco:masterfrom
Open
Fix jwt_decode ignoring options#90CptSpaceToaster wants to merge 1 commit intopallets-eco:masterfrom
CptSpaceToaster wants to merge 1 commit intopallets-eco:masterfrom
Conversation
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`.
|
The PR is old but it works and its a required fix. Any plans of merging? |
Author
|
It seems to have made it into: #95 |
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.
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_exptoFalse. The current algorithm willlook at the list, see that
verify_expwas omitted, and pass in nothingfor
verify_exp, which then makes the PyJWT assume a default (which isverify_exp=True)To fix, the _default_jwt_decode_handler was updated to generate an
options dictionary that sets each option to
TrueorFalsesoJWT_VERIFY_CLAIMS = ['signature', 'nbf', 'iat']
Now will properly set
verify_ext=False.