Skip to content

Commit

Permalink
fix: 修复csrf token检测异常问题 --story=119726972
Browse files Browse the repository at this point in the history
  • Loading branch information
cheynechen committed Sep 26, 2024
1 parent e468d21 commit 4e2b501
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion config/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion config/prod.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
# ==============================================================================
# 加载环境差异化配置
# ==============================================================================
Expand Down
2 changes: 1 addition & 1 deletion config/stag.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand Down
3 changes: 2 additions & 1 deletion itsm/sites/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
)

Expand Down

0 comments on commit 4e2b501

Please sign in to comment.