11import json
2- import warnings
32from calendar import timegm
43from datetime import datetime , timedelta
54
@@ -77,28 +76,25 @@ def decode(
7776 self ,
7877 jwt , # type: str
7978 key = "" , # type: str
80- verify = True , # type: bool
8179 algorithms = None , # type: List[str]
8280 options = None , # type: Dict
8381 complete = False , # type: bool
8482 ** kwargs
8583 ):
8684 # type: (...) -> Dict[str, Any]
8785
88- if verify and not algorithms :
89- warnings .warn (
90- "It is strongly recommended that you pass in a "
91- + 'value for the "algorithms" argument when calling decode(). '
92- + "This argument will be mandatory in a future version." ,
93- DeprecationWarning ,
94- )
95-
9686 payload , _ , _ , _ = self ._load (jwt )
9787
9888 if options is None :
99- options = {"verify_signature" : verify }
89+ options = {"verify_signature" : True }
10090 else :
101- options .setdefault ("verify_signature" , verify )
91+ options .setdefault ("verify_signature" , True )
92+
93+ if options ["verify_signature" ] and not algorithms :
94+ raise DecodeError (
95+ "It is required that you pass in a "
96+ + 'value for the "algorithms" argument when calling decode(). '
97+ )
10298
10399 decoded = super (PyJWT , self ).decode (
104100 jwt ,
@@ -119,7 +115,7 @@ def decode(
119115 if not isinstance (payload , dict ):
120116 raise DecodeError ("Invalid payload string: must be a json object" )
121117
122- if verify :
118+ if options [ "verify_signature" ] :
123119 merged_options = merge_dict (self .options , options )
124120 self ._validate_claims (payload , merged_options , ** kwargs )
125121
@@ -133,14 +129,6 @@ def _validate_claims(
133129 self , payload , options , audience = None , issuer = None , leeway = 0 , ** kwargs
134130 ):
135131
136- if "verify_expiration" in kwargs :
137- options ["verify_exp" ] = kwargs .get ("verify_expiration" , True )
138- warnings .warn (
139- "The verify_expiration parameter is deprecated. "
140- "Please use verify_exp in options instead." ,
141- DeprecationWarning ,
142- )
143-
144132 if isinstance (leeway , timedelta ):
145133 leeway = leeway .total_seconds ()
146134
0 commit comments