Commit 976b079b authored by Clark Lin's avatar Clark Lin
Browse files

fixed hardcode for credential file path; removed sensitive log info; fixed...

fixed hardcode for credential file path; removed sensitive log info; fixed result check of get_credentials()
parent b4f2e4a0
......@@ -40,7 +40,7 @@ lm = LoggingManager.get_instance()
# Init Global Variables
# ------------------------------------------------
# Credential file
credential_file = '/home/ecs-user/paddleocr/credential/oauth2.json'
credential_file = './credential/oauth2.json'
# to get a string like this run:
# openssl rand -hex 32
......@@ -142,9 +142,6 @@ def create_access_token(data: dict, expires_delta: timedelta | None = None):
expire = datetime.now(timezone.utc) + timedelta(minutes=15)
to_encode.update({"exp": expire})
lm.log(logging.INFO, curr_module, "algorithm: " + algorithm)
lm.log(logging.INFO, curr_module, "secret_key: " + secret_key)
encoded_jwt = jwt.encode(to_encode, secret_key, algorithm=algorithm)
return encoded_jwt
......@@ -159,7 +156,7 @@ def get_access_token(form_data: OAuth2PasswordRequestForm) -> Token:
# Get credentials
secret_key, client_db = get_credentials(credential_file)
if secret_key == "" or client_db == {}:
if secret_key == None or client_db == None:
lm.log(logging.INFO, curr_module, "Failed to get credentials from file [" + credential_file + "]")
raise HTTPException(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
......@@ -186,4 +183,4 @@ def get_access_token(form_data: OAuth2PasswordRequestForm) -> Token:
)
lm.log(logging.INFO, curr_module, 'get_access_token complated with normal')
return Token(access_token=access_token, token_type="bearer")
\ No newline at end of file
return Token(access_token=access_token, token_type="bearer")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment