@@ -48,6 +48,7 @@ def verify_jwt_in_request(
48
48
refresh : bool = False ,
49
49
locations : Optional [LocationType ] = None ,
50
50
verify_type : bool = True ,
51
+ skip_revocation_check : bool = False ,
51
52
) -> Optional [Tuple [dict , dict ]]:
52
53
"""
53
54
Verify that a valid JWT is present in the request, unless ``optional=True`` in
@@ -76,6 +77,14 @@ def verify_jwt_in_request(
76
77
to the ``refresh`` argument. If ``False``, type will not be checked and both
77
78
access and refresh tokens will be accepted.
78
79
80
+ :param skip_revocation_check:
81
+ If ``True``, revocation status of the token will be *not* checked. If ``False``,
82
+ revocation status of the token will be checked.
83
+
84
+ :param skip_revocation_check:
85
+ If ``True``, revocation status of the token will be *not* checked. If ``False``,
86
+ revocation status of the token will be checked.
87
+
79
88
:return:
80
89
A tuple containing the jwt_header and the jwt_data if a valid JWT is
81
90
present in the request. If ``optional=True`` and no JWT is in the request,
@@ -87,7 +96,11 @@ def verify_jwt_in_request(
87
96
88
97
try :
89
98
jwt_data , jwt_header , jwt_location = _decode_jwt_from_request (
90
- locations , fresh , refresh = refresh , verify_type = verify_type
99
+ locations ,
100
+ fresh ,
101
+ refresh = refresh ,
102
+ verify_type = verify_type ,
103
+ skip_revocation_check = skip_revocation_check ,
91
104
)
92
105
93
106
except NoAuthorizationError :
@@ -115,6 +128,7 @@ def jwt_required(
115
128
refresh : bool = False ,
116
129
locations : Optional [LocationType ] = None ,
117
130
verify_type : bool = True ,
131
+ skip_revocation_check : bool = False ,
118
132
) -> Any :
119
133
"""
120
134
A decorator to protect a Flask endpoint with JSON Web Tokens.
@@ -145,12 +159,18 @@ def jwt_required(
145
159
If ``True``, the token type (access or refresh) will be checked according
146
160
to the ``refresh`` argument. If ``False``, type will not be checked and both
147
161
access and refresh tokens will be accepted.
162
+
163
+ :param skip_revocation_check:
164
+ If ``True``, revocation status of the token will be *not* checked. If ``False``,
165
+ revocation status of the token will be checked.
148
166
"""
149
167
150
168
def wrapper (fn ):
151
169
@wraps (fn )
152
170
def decorator (* args , ** kwargs ):
153
- verify_jwt_in_request (optional , fresh , refresh , locations , verify_type )
171
+ verify_jwt_in_request (
172
+ optional , fresh , refresh , locations , verify_type , skip_revocation_check
173
+ )
154
174
return current_app .ensure_sync (fn )(* args , ** kwargs )
155
175
156
176
return decorator
@@ -284,6 +304,7 @@ def _decode_jwt_from_request(
284
304
fresh : bool ,
285
305
refresh : bool = False ,
286
306
verify_type : bool = True ,
307
+ skip_revocation_check : bool = False ,
287
308
) -> Tuple [dict , dict , str ]:
288
309
# Figure out what locations to look for the JWT in this request
289
310
if isinstance (locations , str ):
@@ -346,7 +367,10 @@ def _decode_jwt_from_request(
346
367
347
368
if fresh :
348
369
_verify_token_is_fresh (jwt_header , decoded_token )
349
- verify_token_not_blocklisted (jwt_header , decoded_token )
370
+
371
+ if not skip_revocation_check :
372
+ verify_token_not_blocklisted (jwt_header , decoded_token )
373
+
350
374
custom_verification_for_token (jwt_header , decoded_token )
351
375
352
376
return decoded_token , jwt_header , jwt_location
0 commit comments