From d29b66ac47b55b4b4c8a5923367e2573fb53eb73 Mon Sep 17 00:00:00 2001 From: ImMin5 Date: Thu, 19 Dec 2024 17:27:11 +0900 Subject: [PATCH] build: modify Dockerfile add default value for BRANCH_NAME Signed-off-by: ImMin5 --- Dockerfile | 16 ++++++++-------- .../handler/authentication_handler.py | 10 +++++++--- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1fe97ec..6b13de1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,13 @@ FROM cloudforet/python-core:2.0 ARG PACKAGE_VERSION -ARG BRANCH_NAME -ENV PYTHONUNBUFFERED 1 -ENV SPACEONE_PORT 8000 -ENV SRC_DIR /tmp/src -ENV CONF_DIR /etc/spaceone -ENV LOG_DIR /var/log/spaceone -ENV GIT_DIR /tmp/git -ENV OPENAPI_JSON_DIR /opt/openapi +ARG BRANCH_NAME=master +ENV PYTHONUNBUFFERED=1 +ENV SPACEONE_PORT=8000 +ENV SRC_DIR=/tmp/src +ENV CONF_DIR=/etc/spaceone +ENV LOG_DIR=/var/log/spaceone +ENV GIT_DIR=/tmp/git +ENV OPENAPI_JSON_DIR=/opt/openapi ENV PACKAGE_VERSION=$PACKAGE_VERSION COPY pkg/pip_requirements.txt pip_requirements.txt diff --git a/src/cloudforet/console_api_v2/handler/authentication_handler.py b/src/cloudforet/console_api_v2/handler/authentication_handler.py index 8faf976..029e6f8 100644 --- a/src/cloudforet/console_api_v2/handler/authentication_handler.py +++ b/src/cloudforet/console_api_v2/handler/authentication_handler.py @@ -1,3 +1,5 @@ +import logging + import jwt from typing import Union @@ -6,15 +8,17 @@ from spaceone.core.handler.authentication_handler import SpaceONEAuthenticationHandler from spaceone.core.transaction import get_transaction +_LOOGER = logging.getLogger(__name__) + class ConsoleAPIAuthenticationHandler(SpaceONEAuthenticationHandler): def verify(self, params: dict) -> None: - if token := self._get_token(): + if token := self._get_token_from_transaction(): token_info = self._extract_token_info(token) self._update_meta(token_info) @staticmethod - def _get_token() -> Union[str, None]: + def _get_token_from_transaction() -> Union[str, None]: transaction = get_transaction() token = transaction.meta.get("token") return token @@ -23,7 +27,6 @@ def _get_token() -> Union[str, None]: @cache.cacheable(key="console-api-v2:authentication:{token}", expire=300) def _extract_token_info(token: str): try: - decoded_payload = jwt.decode( token, options={"verify_signature": False}, @@ -34,4 +37,5 @@ def _extract_token_info(token: str): return token_info except Exception as e: + _LOOGER.error(f"Failed to decode token: {e}") raise ERROR_PERMISSION_DENIED()