2323from flask_swagger_ui import get_swaggerui_blueprint
2424from flask_jwt_extended import (
2525 JWTManager , jwt_required , create_access_token , create_refresh_token , current_user ,
26- get_jwt_identity , verify_jwt_in_request , jwt_refresh_token_required , get_raw_jwt ,
27- set_access_cookies , set_refresh_cookies , unset_jwt_cookies , verify_jwt_refresh_token_in_request
26+ get_jwt_identity , verify_jwt_in_request , get_jwt ,
27+ set_access_cookies , set_refresh_cookies , unset_jwt_cookies
2828)
2929
3030dictConfig ({
@@ -151,7 +151,7 @@ def __str__(self):
151151REPORT_INDEX_FILE = 'index.html'
152152DEFAULT_TEMPLATE = 'default.html'
153153LANGUAGE_TEMPLATE = 'select_language.html'
154- LANGUAGES = ["en" , "ru" , "zh" , "de" , "nl" , "he" , "br" , "pl" , "ja" , "es" , "kr" , "fr" ]
154+ LANGUAGES = ["en" , "ru" , "zh" , "de" , "nl" , "he" , "br" , "pl" , "ja" , "es" , "kr" , "fr" , "az" ]
155155GLOBAL_CSS = "https://stackpath.bootstrapcdn.com/bootswatch/4.3.1/cosmo/bootstrap.css"
156156EMAILABLE_REPORT_CSS = GLOBAL_CSS
157157EMAILABLE_REPORT_TITLE = "Emailable Report"
@@ -440,10 +440,10 @@ def generate_security_swagger_spec():
440440 'app_name' : "Allure Docker Service"
441441 }
442442)
443- app .register_blueprint (SWAGGERUI_BLUEPRINT , url_prefix = "/" )
444- app .register_blueprint (SWAGGERUI_BLUEPRINT , url_prefix = NATIVE_PREFIX )
445- app .register_blueprint (SWAGGERUI_BLUEPRINT , url_prefix = SWAGGER_ENDPOINT )
446- app .register_blueprint (SWAGGERUI_BLUEPRINT , url_prefix = SWAGGER_ENDPOINT_PATH )
443+ app .register_blueprint (SWAGGERUI_BLUEPRINT , name = "main" , url_prefix = "/" )
444+ app .register_blueprint (SWAGGERUI_BLUEPRINT , name = "native" , url_prefix = NATIVE_PREFIX )
445+ app .register_blueprint (SWAGGERUI_BLUEPRINT , name = "swagger" , url_prefix = SWAGGER_ENDPOINT )
446+ app .register_blueprint (SWAGGERUI_BLUEPRINT , name = "swagger_path" , url_prefix = SWAGGER_ENDPOINT_PATH )
447447if URL_PREFIX :
448448 app .register_blueprint (SWAGGERUI_BLUEPRINT ,
449449 url_prefix = '{}{}' .format (NATIVE_PREFIX , SWAGGER_ENDPOINT ))
@@ -456,9 +456,9 @@ def generate_security_swagger_spec():
456456blacklist = set () #pylint: disable=invalid-name
457457jwt = JWTManager (app ) #pylint: disable=invalid-name
458458
459- @jwt .token_in_blacklist_loader
460- def check_if_token_in_blacklist (decrypted_token ):
461- jti = decrypted_token ['jti' ]
459+ @jwt .token_in_blocklist_loader
460+ def check_if_token_in_blacklist (jwt_header , jwt_data ):
461+ jti = jwt_data ['jti' ]
462462 return jti in blacklist
463463
464464@jwt .invalid_token_loader
@@ -478,8 +478,8 @@ def unauthorized_loader(msg):
478478 }), 401
479479
480480@jwt .expired_token_loader
481- def my_expired_token_callback (expired_token ):
482- token_type = expired_token ['type' ]
481+ def my_expired_token_callback (jwt_headers , jwt_payload ):
482+ token_type = jwt_payload ['type' ]
483483 return jsonify ({
484484 'meta_data' : {
485485 'message' : 'The {} token has expired' .format (token_type ),
@@ -488,7 +488,7 @@ def my_expired_token_callback(expired_token):
488488 }), 401
489489
490490@jwt .revoked_token_loader
491- def revoked_token_loader ():
491+ def revoked_token_loader (jwt_header , jwt_payload ):
492492 return jsonify ({
493493 'meta_data' : {
494494 'message' : 'Revoked Token'
@@ -500,7 +500,7 @@ def jwt_required(fn): #pylint: disable=invalid-name, function-redefined
500500 def wrapper (* args , ** kwargs ):
501501 if ENABLE_SECURITY_LOGIN :
502502 if is_endpoint_protected (request .endpoint ):
503- verify_jwt_in_request ()
503+ verify_jwt_in_request (refresh = False )
504504 return fn (* args , ** kwargs )
505505 return wrapper
506506
@@ -509,12 +509,13 @@ def jwt_refresh_token_required(fn): #pylint: disable=invalid-name, function-rede
509509 def wrapper (* args , ** kwargs ):
510510 if ENABLE_SECURITY_LOGIN :
511511 if is_endpoint_protected (request .endpoint ):
512- verify_jwt_refresh_token_in_request ( )
512+ verify_jwt_in_request ( refresh = True )
513513 return fn (* args , ** kwargs )
514514 return wrapper
515515
516- @jwt .user_loader_callback_loader
517- def user_loader_callback (identity ):
516+ @jwt .user_lookup_loader
517+ def user_loader_callback (jwt_header , jwt_data ):
518+ identity = jwt_data ['sub' ]
518519 if identity not in USERS_INFO :
519520 return None
520521 return UserAccess (
@@ -619,7 +620,7 @@ def logout_endpoint():
619620 resp = jsonify (body )
620621 return resp , 404
621622 try :
622- jti = get_raw_jwt ()['jti' ]
623+ jti = get_jwt ()['jti' ]
623624 blacklist .add (jti )
624625 return jsonify ({'meta_data' : {'message' : 'Successfully logged out' }}), 200
625626 except Exception as ex :
@@ -644,7 +645,7 @@ def logout_refresh_token_endpoint():
644645 resp = jsonify (body )
645646 return resp , 404
646647 try :
647- jti = get_raw_jwt ()['jti' ]
648+ jti = get_jwt ()['jti' ]
648649 blacklist .add (jti )
649650 resp = jsonify ({'meta_data' : {'message' : 'Successfully logged out' }})
650651 unset_jwt_cookies (resp )
@@ -835,7 +836,7 @@ def latest_report_endpoint():
835836 resp .status_code = 404
836837 return resp
837838
838- project_report_latest_path = '/ latest/{}' .format (REPORT_INDEX_FILE )
839+ project_report_latest_path = 'latest/{}' .format (REPORT_INDEX_FILE )
839840 url = url_for ('get_reports_endpoint' , project_id = project_id ,
840841 path = project_report_latest_path , redirect = 'false' , _external = True )
841842 return redirect (url )
@@ -1257,7 +1258,7 @@ def report_export_endpoint():
12571258 data ,
12581259 mimetype = 'application/zip' ,
12591260 as_attachment = True ,
1260- attachment_filename = 'allure-docker-service-report.zip'
1261+ download_name = 'allure-docker-service-report.zip'
12611262 )
12621263 except Exception as ex :
12631264 body = {
0 commit comments