Skip to content

Commit

Permalink
feat(backend): 数据脱敏兼容性处理 #8776
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzhw8 committed Dec 23, 2024
1 parent c511191 commit 0d08a9b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions dbm-ui/backend/bk_web/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,14 @@ def __call__(self, request):
response = self.get_response(request)

# 如果是来自外部转发的请求,进行脱敏
if getattr(request, "is_external", False) and request.path.startswith("/apis/") and env.BKDATA_DATA_TOKEN:
response.data = json.loads(BKBaseApi.data_desensitization(response.content.decode("utf-8")))
if (
getattr(request, "is_external", False)
and request.path.startswith("/apis/")
and response.headers.get("Content-Type").startswith("application/json")
and env.BKDATA_DATA_TOKEN
):
data = BKBaseApi.data_desensitization(response.content.decode("utf-8"))
return JsonResponse(json.loads(data))

return response

Expand Down

0 comments on commit 0d08a9b

Please sign in to comment.