From fa6b9685340313b80ad3feb4c3fc33114c231233 Mon Sep 17 00:00:00 2001 From: waylon <1158341873@qq.com> Date: Thu, 24 Oct 2024 11:48:52 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20create=5Fspace=20api=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=20APP=20=E7=99=BD=E5=90=8D=E5=8D=95=20#44?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bkflow/apigw/views/create_space.py | 3 ++- config/default.py | 2 ++ env.py | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/bkflow/apigw/views/create_space.py b/bkflow/apigw/views/create_space.py index 6f85605..467426d 100644 --- a/bkflow/apigw/views/create_space.py +++ b/bkflow/apigw/views/create_space.py @@ -21,6 +21,7 @@ from apigw_manager.apigw.decorators import apigw_require from blueapps.account.decorators import login_exempt +from django.conf import settings from django.db import transaction from django.views.decorators.csrf import csrf_exempt from django.views.decorators.http import require_POST @@ -46,7 +47,7 @@ def create_space(request): } """ data = json.loads(request.body) - if hasattr(request, "app"): + if hasattr(request, "app") and request.app.bk_app_code not in settings.APP_WHITE_LIST: data["app_code"] = request.app.bk_app_code ser = CreateSpaceSerializer(data=data) diff --git a/config/default.py b/config/default.py index 094d687..6788a60 100644 --- a/config/default.py +++ b/config/default.py @@ -85,6 +85,8 @@ APP_INTERNAL_FROM_SUPERUSER_HEADER_KEY = "Bkflow-Internal-From-SuperUser" APP_INTERNAL_TOKEN_REQUEST_META_KEY = "HTTP_BKFLOW_INTERNAL_TOKEN" +APP_WHITE_LIST = env.APP_WHITE_LIST_STR.split(",") if env.APP_WHITE_LIST_STR else [] + # PAAS SERVICE DETECTION BKPAAS_SERVICE_ADDRESSES_BKSAAS = os.getenv("BKPAAS_SERVICE_ADDRESSES_BKSAAS") BKSAAS_DEFAULT_MODULE_NAME = "default" diff --git a/env.py b/env.py index eac6a7e..11f0d90 100644 --- a/env.py +++ b/env.py @@ -131,3 +131,6 @@ # 文档中心链接 BK_DOC_CENTER_HOST = os.getenv("BK_DOC_CENTER_HOST", os.getenv("BK_DOCS_URL_PREFIX", "")).rstrip("/") + +# APP 白名单 +APP_WHITE_LIST_STR = os.getenv("BKAPP_APP_WHITE_LIST", "") # 逗号分隔的字符串