Skip to content

Commit e4c67b1

Browse files
blueyedjpadilla
authored andcommitted
PyJWT.decode: move verify param into options (jpadilla#271)
Followup to jpadilla#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.
1 parent 639fa01 commit e4c67b1

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

jwt/api_jws.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def decode(self, jws, key='', verify=True, algorithms=None, options=None,
127127
else:
128128
warnings.warn('The verify parameter is deprecated. '
129129
'Please use verify_signature in options instead.',
130-
DeprecationWarning)
130+
DeprecationWarning, stacklevel=2)
131131

132132
return payload
133133

jwt/api_jwt.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,12 @@ def decode(self, jwt, key='', verify=True, algorithms=None, options=None,
6060
**kwargs):
6161
payload, signing_input, header, signature = self._load(jwt)
6262

63-
decoded = super(PyJWT, self).decode(jwt, key, verify, algorithms,
64-
options, **kwargs)
63+
if options is None:
64+
options = {'verify_signature': verify}
65+
else:
66+
options.setdefault('verify_signature', verify)
67+
decoded = super(PyJWT, self).decode(jwt, key, algorithms, options,
68+
**kwargs)
6569

6670
try:
6771
payload = json.loads(decoded.decode('utf-8'))

0 commit comments

Comments
 (0)