Skip to content

Commit

Permalink
bk_login is_login/get_user send header x-verified-bk-app-code to back… (
Browse files Browse the repository at this point in the history
#97)

* bk_login is_login/get_user send header x-verified-bk-app-code to backend api

* upgrade bkpaas-auth to 2.0.4
  • Loading branch information
alex-smile authored Jul 17, 2023
1 parent ee18700 commit a08820d
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/dashboard/apigateway/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ bkapi-client-core==1.1.8 ; python_full_version >= "3.6.6" and python_version < "
bkapi-client-generator==0.1.28 ; python_full_version >= "3.6.6" and python_version < "3.8"
bkapi-component-open==1.1.0 ; python_full_version >= "3.6.6" and python_version < "3.8"
bkapi-paasv3==1.0.1 ; python_full_version >= "3.6.6" and python_version < "3.8"
bkpaas-auth==2.0.3 ; python_full_version >= "3.6.6" and python_version < "3.8"
bkpaas-auth==2.0.4 ; python_full_version >= "3.6.6" and python_version < "3.8"
blue-krill==1.2.3 ; python_full_version >= "3.6.6" and python_version < "3.8"
cachetools==4.2.4 ; python_full_version >= "3.6.6" and python_version < "3.8"
cattrs==1.0.0 ; python_full_version >= "3.6.6" and python_full_version < "3.7.0"
Expand Down
2 changes: 1 addition & 1 deletion src/dashboard/apigateway/requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ bkapi-client-core==1.1.8 ; python_full_version >= "3.6.6" and python_version < "
bkapi-client-generator==0.1.28 ; python_full_version >= "3.6.6" and python_version < "3.8"
bkapi-component-open==1.1.0 ; python_full_version >= "3.6.6" and python_version < "3.8"
bkapi-paasv3==1.0.1 ; python_full_version >= "3.6.6" and python_version < "3.8"
bkpaas-auth==2.0.3 ; python_full_version >= "3.6.6" and python_version < "3.8"
bkpaas-auth==2.0.4 ; python_full_version >= "3.6.6" and python_version < "3.8"
black==21.12b0 ; python_full_version >= "3.6.6" and python_version < "3.8"
blue-krill==1.2.3 ; python_full_version >= "3.6.6" and python_version < "3.8"
cachetools==4.2.4 ; python_full_version >= "3.6.6" and python_version < "3.8"
Expand Down
7 changes: 3 additions & 4 deletions src/dashboard/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/dashboard/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ typing_extensions = "4.1.1"
jsonfield = "3.1.0"
importlib-metadata = "4.8.3"
greenlet = "2.0.2"
bkpaas-auth = "2.0.3"
bkpaas-auth = "2.0.4"
blue-krill = "1.2.3"
cryptography = "3.4.8"
apigw-manager = "1.1.7"
Expand Down
5 changes: 4 additions & 1 deletion src/esb/esb/components/bk/apisv2/bk_login/get_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

class GetUser(Component):
suggest_method = HTTP_METHOD.GET
label = u"获取用户信息"
label = "获取用户信息"
label_en = "get user"

sys_name = configs.SYSTEM_NAME
Expand All @@ -44,4 +44,7 @@ def handle(self):
host=configs.host,
path="/login/api/v2/get_user/",
params=self.form_data,
headers={
"x-verified-bk-app-code": self.request.app_code,
},
)
5 changes: 4 additions & 1 deletion src/esb/esb/components/bk/apisv2/bk_login/is_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

class IsLogin(Component):
suggest_method = HTTP_METHOD.GET
label = u"用户登录态验证"
label = "用户登录态验证"
label_en = "check is login"

sys_name = configs.SYSTEM_NAME
Expand All @@ -43,4 +43,7 @@ def handle(self):
host=configs.host,
path="/login/api/v2/is_login/",
params=self.form_data,
headers={
"x-verified-bk-app-code": self.request.app_code,
},
)
15 changes: 9 additions & 6 deletions src/esb/esb/components/bk/apisv2/bk_login/toolkit/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,25 @@ class LOGINClient(object):
def __init__(self, http_client):
self.http_client = http_client

def request(self, method, host, path, data=None, params=None):
def request(self, method, host, path, data=None, params=None, headers=None):
headers = headers or {}
headers.update(configs.headers)

result = self.http_client.request(
method=method,
host=host,
path=path,
data=data,
params=params,
headers=configs.headers,
headers=headers,
)
return self.format_result(result)

def post(self, host, path, data=None):
return self.request(method="POST", host=host, path=path, data=data)
def post(self, host, path, data=None, headers=None):
return self.request(method="POST", host=host, path=path, data=data, headers=headers)

def get(self, host, path, params=None):
return self.request(method="GET", host=host, path=path, params=params)
def get(self, host, path, params=None, headers=None):
return self.request(method="GET", host=host, path=path, params=params, headers=headers)

def format_result(self, result):
if result["bk_error_code"] == 0:
Expand Down

0 comments on commit a08820d

Please sign in to comment.