From 5903e3b4f2822738773d532bdc3b1e24eeedc902 Mon Sep 17 00:00:00 2001 From: jdorsch Date: Thu, 23 Nov 2023 15:43:46 +0100 Subject: [PATCH] Search for 'Bearer ' string to be removed to extract token --- .gitlab-ci.yml | 2 +- src/certificator/certificator.py | 8 ++++---- src/common/cscs_api_common.py | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 98643d90..f4a995d4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -301,7 +301,7 @@ tag_release: else echo "The tag does not belong to master the branch"; - exit 0 + exit 1 fi when: on_success diff --git a/src/certificator/certificator.py b/src/certificator/certificator.py index 15dda85b..4dc36b14 100644 --- a/src/certificator/certificator.py +++ b/src/certificator/certificator.py @@ -198,8 +198,8 @@ def check_user_auth(username,system): # checks JWT from Keycloak, optionally validates signature. It only receives the content of header's auth pair (not key:content) def check_header(header): - # header = "Bearer ey...", remove first 7 chars - token = header[7:] + # header = remove the "Bearer " string + token = header.replace("Bearer ","") decoding_result = False decoding_reason = "" @@ -275,8 +275,8 @@ def check_header(header): # returns username def get_username(header): - # header = "Bearer ey...", remove first 7 chars - token = header[7:] + # header = remove the "Bearer " string + token = header.replace("Bearer ","") decoding_result = False decoding_reason = "" diff --git a/src/common/cscs_api_common.py b/src/common/cscs_api_common.py index 36f90720..b5a72a91 100644 --- a/src/common/cscs_api_common.py +++ b/src/common/cscs_api_common.py @@ -100,8 +100,8 @@ def get_null_var(var): # checks JWT from Keycloak, optionally validates signature. It only receives the content of header's auth pair (not key:content) def check_header(header): - # header = "Bearer ey...", remove first 7 chars - token = header[7:] + # header = remove the "Bearer " string + token = header.replace("Bearer ","") decoding_result = False decoding_reason = "" @@ -179,8 +179,8 @@ def check_header(header): # returns username def get_username(header): - # header = "Bearer ey...", remove first 7 chars - token = header[7:] + # header = remove the "Bearer " string + token = header.replace("Bearer ","") decoding_result = False decoding_reason = ""