Skip to content

Commit

Permalink
feat: create_space api 添加 APP 白名单 TencentBlueKing#44
Browse files Browse the repository at this point in the history
  • Loading branch information
normal-wls committed Oct 24, 2024
1 parent 8dc3709 commit 07ec269
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bkflow/apigw/views/create_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions config/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions env.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", "") # 逗号分隔的字符串

0 comments on commit 07ec269

Please sign in to comment.