File tree Expand file tree Collapse file tree 4 files changed +16
-5
lines changed
src/cloudforet/console_api_v2 Expand file tree Collapse file tree 4 files changed +16
-5
lines changed Original file line number Diff line number Diff line change 11spaceone-api
22typing-inspect
33python-multipart
4+ PyJWT
Original file line number Diff line number Diff line change 1+ from cloudforet .console_api_v2 .handler .authentication_handler import (
2+ ConsoleAPIAuthenticationHandler ,
3+ )
Original file line number Diff line number Diff line change 11import jwt
2+ from typing import Union
3+
24from spaceone .core import cache
35from spaceone .core .error import ERROR_PERMISSION_DENIED
46from spaceone .core .handler .authentication_handler import SpaceONEAuthenticationHandler
7+ from spaceone .core .transaction import get_transaction
58
69
710class ConsoleAPIAuthenticationHandler (SpaceONEAuthenticationHandler ):
811 def verify (self , params : dict ) -> None :
9- token = self ._get_token ()
10- token_info = self ._extract_token_info (token )
12+ if token := self ._get_token ():
13+ token_info = self ._extract_token_info (token )
14+ self ._update_meta (token_info )
1115
12- self ._update_meta (token_info )
16+ @staticmethod
17+ def _get_token () -> Union [str , None ]:
18+ transaction = get_transaction ()
19+ token = transaction .meta .get ("token" )
20+ return token
1321
1422 @staticmethod
1523 @cache .cacheable (key = "console-api-v2:authentication:{token}" , expire = 300 )
Original file line number Diff line number Diff line change @@ -33,8 +33,7 @@ def _add_paths_from_openapi_json():
3333 openapi_json_dirs = config .get_global ("OPENAPI_JSON_DIRS" )
3434
3535 for openapi_json_dir in openapi_json_dirs :
36- openapi_json_files = glob .glob (os .path .join (openapi_json_dir ))
37- if openapi_json_files :
36+ if openapi_json_files := glob .glob (os .path .join (openapi_json_dir )):
3837 with open (openapi_json_files [0 ], "r" ) as f :
3938 openapi_json = json .loads (f .read ())
4039 for path , value in openapi_json .get ("paths" ).items ():
You can’t perform that action at this time.
0 commit comments