diff --git a/config/default.py b/config/default.py index bc068762..204c354a 100644 --- a/config/default.py +++ b/config/default.py @@ -439,7 +439,7 @@ def _(s): # Django 项目配置 - 其他 # ============================================================================== CSRF_COOKIE_PATH = "/" -CSRF_COOKIE_NAME = "bkitsm_csrftoken" +CSRF_COOKIE_NAME = os.environ.get("BKAPP_CSRF_COOKIE_NAME", "bkitsm_csrftoken") SESSION_COOKIE_NAME = "bkitsm_sessionid" # Template diff --git a/config/prod.py b/config/prod.py index 3ba5fa38..9178fd94 100644 --- a/config/prod.py +++ b/config/prod.py @@ -99,7 +99,7 @@ ) MEDIA_URL = "%smedia/" % SITE_URL -CSRF_COOKIE_NAME = "bkitsm_csrftoken" +CSRF_COOKIE_NAME = os.environ.get("BKAPP_CSRF_COOKIE_NAME", "bkitsm_csrftoken") # ============================================================================== # 加载环境差异化配置 # ============================================================================== diff --git a/config/stag.py b/config/stag.py index f51a5c27..da6c85c9 100644 --- a/config/stag.py +++ b/config/stag.py @@ -83,7 +83,7 @@ MIDDLEWARE = ("common.middlewares.DisableCSRFCheck",) + MIDDLEWARE MEDIA_URL = "%smedia/" % SITE_URL -CSRF_COOKIE_NAME = "bkitsm_csrftoken" +CSRF_COOKIE_NAME = os.environ.get("BKAPP_CSRF_COOKIE_NAME", "bkitsm_csrftoken") # REMOTE_STATIC_URL = "http://127.0.0.1:8000/static/" # STATIC_URL = "http://127.0.0.1:8000/static/" diff --git a/itsm/sites/views.py b/itsm/sites/views.py index 010d05c4..02fc3344 100644 --- a/itsm/sites/views.py +++ b/itsm/sites/views.py @@ -137,7 +137,8 @@ def index(request): "NOTICE_CENTER_SWITCH": notice_center_switch_value, "BK_SHARED_RES_URL": settings.BK_SHARED_RES_URL, "BK_PLATFORM_NAME": settings.BK_PLATFORM_NAME, - "VERSION": get_version() + "VERSION": get_version(), + "CSRF_COOKIE_NAME": settings.CSRF_COOKIE_NAME, }, )