Skip to content

Commit

Permalink
feat: API标准化认证方案 (closed #2370)
Browse files Browse the repository at this point in the history
  • Loading branch information
wyyalt authored and ping15 committed Aug 12, 2024
1 parent 56cd18a commit d6ce079
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions common/api/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,9 @@ def _send(self, params: Dict, headers: Dict, use_admin: bool = False):
auth_value = params.get(auth_key)
if auth_value:
api_auth_params[auth_key] = auth_value
if not settings.BKAPP_LEGACY_AUTH:
# 未开启情况下删除请求参数中的验证信息
params.pop(auth_key)
session.headers.update({"X-Bkapi-Authorization": get_request_api_headers(api_auth_params)})

url = self.build_actual_url(params)
Expand Down
2 changes: 1 addition & 1 deletion common/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def get_docs_center_url():


def get_title():
return _("节点管理 | 腾讯蓝鲸智云")
return _("节点管理 | 蓝鲸智云")


@FuncCacheDecorator(cache_time=60 * constants.TimeUnit.SECOND)
Expand Down
1 change: 1 addition & 0 deletions config/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@
SCRIPT_HOOKS = env.BKAPP_SCRIPT_HOOKS

BKPAAS_SHARED_RES_URL = env.BKPAAS_SHARED_RES_URL
BKAPP_LEGACY_AUTH = env.BKAPP_LEGACY_AUTH

# 敏感参数
SENSITIVE_PARAMS = ["app_code", "app_secret", "bk_app_code", "bk_app_secret", "auth_info"]
Expand Down
2 changes: 2 additions & 0 deletions env/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
# Agent安装前置脚本
"BKAPP_SCRIPT_HOOKS",
"BKPAAS_SHARED_RES_URL",
"BKAPP_LEGACY_AUTH",
]

# ===============================================================================
Expand Down Expand Up @@ -186,3 +187,4 @@

BK_DOCS_CENTER_HOST = get_type_env(key="BK_DOCS_CENTER_HOST", default="", _type=str)
BKPAAS_SHARED_RES_URL = get_type_env(key="BKPAAS_SHARED_RES_URL", default="", _type=str)
BKAPP_LEGACY_AUTH = get_type_env(key="BKAPP_LEGACY_AUTH", default=False, _type=bool)
Binary file modified locale/en/LC_MESSAGES/django.mo
Binary file not shown.
2 changes: 1 addition & 1 deletion locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -5842,7 +5842,7 @@ msgid "标准运维"
msgstr "BK-SOPS"

#: common/context_processors.py:44
msgid "节点管理 | 腾讯蓝鲸智云"
msgid "节点管理 | 蓝鲸智云"
msgstr "NodeMan | Tencent Blueking"

#: pipeline/component_framework/models.py:42
Expand Down
2 changes: 1 addition & 1 deletion support-files/bkiam/0003_bk_nodeman_20200811-1145_iam.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"data": {
"id": "bk_nodeman",
"name": "节点管理",
"name_en": "nodeman",
"name_en": "Nodeman",
"description": "",
"description_en": "",
"clients": "bk_nodeman,bk_bknodeman",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,4 @@ data:

BKAPP_SCRIPT_HOOKS: "{{ .Values.config.bkAppScriptHooks }}"
BKPAAS_SHARED_RES_URL: "{{ .Values.bkSharedResUrl }}"
BKAPP_LEGACY_AUTH: "{{ .Values.config.bkAppLegacyAuth }}"

0 comments on commit d6ce079

Please sign in to comment.