Skip to content

Commit

Permalink
PyJWT.decode: move verify param into options (#271)
Browse files Browse the repository at this point in the history
Followup to #270:

It seems that "verify" is only deprecated with `PyJWS.decode`, which
makes sense, since you would have to override a lot of options to skip
the verification in `PyJWT._validate_claims`.

This makes `PyJWT.decode` use the `verify_signature` option when calling
`PyJWT.decode`, and therefore also allows to use `stacklevel=2` there
then for the DeprecationWarning.
  • Loading branch information
blueyed authored and jpadilla committed Jun 21, 2017
1 parent 639fa01 commit e4c67b1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion jwt/api_jws.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def decode(self, jws, key='', verify=True, algorithms=None, options=None,
else:
warnings.warn('The verify parameter is deprecated. '
'Please use verify_signature in options instead.',
DeprecationWarning)
DeprecationWarning, stacklevel=2)

return payload

Expand Down
8 changes: 6 additions & 2 deletions jwt/api_jwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,12 @@ def decode(self, jwt, key='', verify=True, algorithms=None, options=None,
**kwargs):
payload, signing_input, header, signature = self._load(jwt)

decoded = super(PyJWT, self).decode(jwt, key, verify, algorithms,
options, **kwargs)
if options is None:
options = {'verify_signature': verify}
else:
options.setdefault('verify_signature', verify)
decoded = super(PyJWT, self).decode(jwt, key, algorithms, options,
**kwargs)

try:
payload = json.loads(decoded.decode('utf-8'))
Expand Down

0 comments on commit e4c67b1

Please sign in to comment.