23
23
from flask_swagger_ui import get_swaggerui_blueprint
24
24
from flask_jwt_extended import (
25
25
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
28
28
)
29
29
30
30
dictConfig ({
@@ -151,7 +151,7 @@ def __str__(self):
151
151
REPORT_INDEX_FILE = 'index.html'
152
152
DEFAULT_TEMPLATE = 'default.html'
153
153
LANGUAGE_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" ]
155
155
GLOBAL_CSS = "https://stackpath.bootstrapcdn.com/bootswatch/4.3.1/cosmo/bootstrap.css"
156
156
EMAILABLE_REPORT_CSS = GLOBAL_CSS
157
157
EMAILABLE_REPORT_TITLE = "Emailable Report"
@@ -440,10 +440,10 @@ def generate_security_swagger_spec():
440
440
'app_name' : "Allure Docker Service"
441
441
}
442
442
)
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 )
447
447
if URL_PREFIX :
448
448
app .register_blueprint (SWAGGERUI_BLUEPRINT ,
449
449
url_prefix = '{}{}' .format (NATIVE_PREFIX , SWAGGER_ENDPOINT ))
@@ -456,9 +456,9 @@ def generate_security_swagger_spec():
456
456
blacklist = set () #pylint: disable=invalid-name
457
457
jwt = JWTManager (app ) #pylint: disable=invalid-name
458
458
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' ]
462
462
return jti in blacklist
463
463
464
464
@jwt .invalid_token_loader
@@ -478,8 +478,8 @@ def unauthorized_loader(msg):
478
478
}), 401
479
479
480
480
@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' ]
483
483
return jsonify ({
484
484
'meta_data' : {
485
485
'message' : 'The {} token has expired' .format (token_type ),
@@ -488,7 +488,7 @@ def my_expired_token_callback(expired_token):
488
488
}), 401
489
489
490
490
@jwt .revoked_token_loader
491
- def revoked_token_loader ():
491
+ def revoked_token_loader (jwt_header , jwt_payload ):
492
492
return jsonify ({
493
493
'meta_data' : {
494
494
'message' : 'Revoked Token'
@@ -500,7 +500,7 @@ def jwt_required(fn): #pylint: disable=invalid-name, function-redefined
500
500
def wrapper (* args , ** kwargs ):
501
501
if ENABLE_SECURITY_LOGIN :
502
502
if is_endpoint_protected (request .endpoint ):
503
- verify_jwt_in_request ()
503
+ verify_jwt_in_request (refresh = False )
504
504
return fn (* args , ** kwargs )
505
505
return wrapper
506
506
@@ -509,12 +509,13 @@ def jwt_refresh_token_required(fn): #pylint: disable=invalid-name, function-rede
509
509
def wrapper (* args , ** kwargs ):
510
510
if ENABLE_SECURITY_LOGIN :
511
511
if is_endpoint_protected (request .endpoint ):
512
- verify_jwt_refresh_token_in_request ( )
512
+ verify_jwt_in_request ( refresh = True )
513
513
return fn (* args , ** kwargs )
514
514
return wrapper
515
515
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' ]
518
519
if identity not in USERS_INFO :
519
520
return None
520
521
return UserAccess (
@@ -619,7 +620,7 @@ def logout_endpoint():
619
620
resp = jsonify (body )
620
621
return resp , 404
621
622
try :
622
- jti = get_raw_jwt ()['jti' ]
623
+ jti = get_jwt ()['jti' ]
623
624
blacklist .add (jti )
624
625
return jsonify ({'meta_data' : {'message' : 'Successfully logged out' }}), 200
625
626
except Exception as ex :
@@ -644,7 +645,7 @@ def logout_refresh_token_endpoint():
644
645
resp = jsonify (body )
645
646
return resp , 404
646
647
try :
647
- jti = get_raw_jwt ()['jti' ]
648
+ jti = get_jwt ()['jti' ]
648
649
blacklist .add (jti )
649
650
resp = jsonify ({'meta_data' : {'message' : 'Successfully logged out' }})
650
651
unset_jwt_cookies (resp )
@@ -835,7 +836,7 @@ def latest_report_endpoint():
835
836
resp .status_code = 404
836
837
return resp
837
838
838
- project_report_latest_path = '/ latest/{}' .format (REPORT_INDEX_FILE )
839
+ project_report_latest_path = 'latest/{}' .format (REPORT_INDEX_FILE )
839
840
url = url_for ('get_reports_endpoint' , project_id = project_id ,
840
841
path = project_report_latest_path , redirect = 'false' , _external = True )
841
842
return redirect (url )
@@ -1257,7 +1258,7 @@ def report_export_endpoint():
1257
1258
data ,
1258
1259
mimetype = 'application/zip' ,
1259
1260
as_attachment = True ,
1260
- attachment_filename = 'allure-docker-service-report.zip'
1261
+ download_name = 'allure-docker-service-report.zip'
1261
1262
)
1262
1263
except Exception as ex :
1263
1264
body = {
0 commit comments