@@ -188,12 +188,14 @@ def _check_blacklist(jwt_data):
188188 token_type = jwt_data ['type' ]
189189 jti = jwt_data ['jti' ]
190190
191+ # Only check access tokens if BLACKLIST_TOKEN_CHECKS is set to 'all`
191192 if token_type == 'access' and _blacklist_checks () == 'all' :
192193 token_status = store [jti ]
193194 if token_status != 'active' :
194195 raise RevokedTokenError ('{} has been revoked' .format )
195196
196- if token_type == 'refresh' and _blacklist_checks () in ('all' , 'refresh' ):
197+ # Always check refresh tokens
198+ if token_type == 'refresh' :
197199 token_status = store [jti ]
198200 if token_status != 'active' :
199201 raise RevokedTokenError ('{} has been revoked' .format )
@@ -264,7 +266,7 @@ def wrapper(*args, **kwargs):
264266 return wrapper
265267
266268
267- def authenticate (identity ):
269+ def create_refresh_access_tokens (identity ):
268270 # Token settings
269271 config = current_app .config
270272 access_expire_delta = config .get ('JWT_ACCESS_TOKEN_EXPIRES' , ACCESS_EXPIRES )
@@ -285,8 +287,21 @@ def authenticate(identity):
285287 return jsonify (ret ), 200
286288
287289
290+ def create_fresh_access_token (identity ):
291+ # Token options
292+ secret = _get_secret_key ()
293+ config = current_app .config
294+ access_expire_delta = config .get ('JWT_ACCESS_TOKEN_EXPIRES' , ACCESS_EXPIRES )
295+ algorithm = config .get ('JWT_ALGORITHM' , ALGORITHM )
296+ user_claims = current_app .jwt_manager .user_claims_callback (identity )
297+ access_token = _encode_access_token (identity , secret , algorithm , access_expire_delta ,
298+ fresh = True , user_claims = user_claims )
299+ ret = {'access_token' : access_token }
300+ return jsonify (ret ), 200
301+
302+
288303@_handle_callbacks_on_error
289- def refresh ():
304+ def refresh_access_token ():
290305 # Get the JWT
291306 jwt_data = _decode_jwt_from_request ()
292307
@@ -310,19 +325,6 @@ def refresh():
310325 return jsonify (ret ), 200
311326
312327
313- def fresh_authenticate (identity ):
314- # Token options
315- secret = _get_secret_key ()
316- config = current_app .config
317- access_expire_delta = config .get ('JWT_ACCESS_TOKEN_EXPIRES' , ACCESS_EXPIRES )
318- algorithm = config .get ('JWT_ALGORITHM' , ALGORITHM )
319- user_claims = current_app .jwt_manager .user_claims_callback (identity )
320- access_token = _encode_access_token (identity , secret , algorithm , access_expire_delta ,
321- fresh = True , user_claims = user_claims )
322- ret = {'access_token' : access_token }
323- return jsonify (ret ), 200
324-
325-
326328def _get_secret_key ():
327329 key = current_app .config .get ('SECRET_KEY' , None )
328330 if not key :
@@ -339,7 +341,11 @@ def _get_blacklist_store():
339341
340342
341343def _blacklist_checks ():
342- return current_app .config .get ('JWT_BLACKLIST_TOKEN_CHECKS' , BLACKLIST_TOKEN_CHECKS )
344+ config = current_app .config
345+ check_type = config .get ('JWT_BLACKLIST_TOKEN_CHECKS' , BLACKLIST_TOKEN_CHECKS )
346+ if check_type not in ('all' , 'refresh' ):
347+ raise RuntimeError ('Invalid option for JWT_BLACKLIST_TOKEN_CHECKS' )
348+ return check_type
343349
344350
345351def _store_supports_ttl (store ):
0 commit comments