Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: create_space api 添加 APP 白名单 #44 #45

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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", "") # 逗号分隔的字符串
Loading