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

fix: 修复csrf token检测异常问题 --story=119726972 #1411

Merged
merged 1 commit into from
Sep 26, 2024
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
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
Loading