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() ...@@ -40,7 +40,7 @@ lm = LoggingManager.get_instance()
# Init Global Variables # Init Global Variables
# ------------------------------------------------ # ------------------------------------------------
# Credential file # Credential file
credential_file = '/home/ecs-user/paddleocr/credential/oauth2.json' credential_file = './credential/oauth2.json'
# to get a string like this run: # to get a string like this run:
# openssl rand -hex 32 # openssl rand -hex 32
...@@ -142,9 +142,6 @@ def create_access_token(data: dict, expires_delta: timedelta | None = None): ...@@ -142,9 +142,6 @@ def create_access_token(data: dict, expires_delta: timedelta | None = None):
expire = datetime.now(timezone.utc) + timedelta(minutes=15) expire = datetime.now(timezone.utc) + timedelta(minutes=15)
to_encode.update({"exp": expire}) 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) encoded_jwt = jwt.encode(to_encode, secret_key, algorithm=algorithm)
return encoded_jwt return encoded_jwt
...@@ -159,7 +156,7 @@ def get_access_token(form_data: OAuth2PasswordRequestForm) -> Token: ...@@ -159,7 +156,7 @@ def get_access_token(form_data: OAuth2PasswordRequestForm) -> Token:
# Get credentials # Get credentials
secret_key, client_db = get_credentials(credential_file) 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 + "]") lm.log(logging.INFO, curr_module, "Failed to get credentials from file [" + credential_file + "]")
raise HTTPException( raise HTTPException(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
......
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