Skip to content

Commit

Permalink
Merge pull request #113 from ImMin5/master
Browse files Browse the repository at this point in the history
Modify Dockerfile add default value for BRANCH_NAME
  • Loading branch information
ImMin5 authored Dec 19, 2024
2 parents d1e3ce0 + d29b66a commit 775299b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
16 changes: 8 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 7 additions & 3 deletions src/cloudforet/console_api_v2/handler/authentication_handler.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import logging

import jwt
from typing import Union

Expand All @@ -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
Expand All @@ -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},
Expand All @@ -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()

0 comments on commit 775299b

Please sign in to comment.