mirror of
https://github.com/haiwen/seahub.git
synced 2025-05-12 18:05:05 +00:00
Use custom csrf cookie name to avoid name conflict
This commit is contained in:
parent
1faa061321
commit
0f59f84804
media/js
seahub
static/scripts
@ -103,7 +103,7 @@ function addConfirmTo(op_ele, popup) {
|
||||
$('<form>', {
|
||||
"method": 'POST',
|
||||
"action": $(this).data('url'),
|
||||
"html": '<input name="csrfmiddlewaretoken" value="' + getCookie('csrftoken') + '" type="hidden">'
|
||||
"html": '<input name="csrfmiddlewaretoken" value="' + getCookie('sfcsrftoken') + '" type="hidden">'
|
||||
}).appendTo(document.body).trigger('submit');
|
||||
} else { // default
|
||||
location.href = $(this).data('url');
|
||||
@ -130,7 +130,7 @@ function addFormPost(op_ele) {
|
||||
$('<form>', {
|
||||
"method": 'POST',
|
||||
"action": $(this).data('url'),
|
||||
"html": '<input name="csrfmiddlewaretoken" value="' + getCookie('csrftoken') + '" type="hidden">'
|
||||
"html": '<input name="csrfmiddlewaretoken" value="' + getCookie('sfcsrftoken') + '" type="hidden">'
|
||||
}).appendTo(document.body).trigger('submit');
|
||||
return false;
|
||||
});
|
||||
@ -223,7 +223,7 @@ function getCookie(name) {
|
||||
function prepareCSRFToken(xhr, settings) {
|
||||
if (!(/^http:.*/.test(settings.url) || /^https:.*/.test(settings.url))) {
|
||||
// Only send the token to relative URLs i.e. locally.
|
||||
xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken'));
|
||||
xhr.setRequestHeader("X-CSRFToken", getCookie('sfcsrftoken'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,6 +108,7 @@ def base(request):
|
||||
'multi_institution': getattr(dj_settings, 'MULTI_INSTITUTION', False),
|
||||
'search_repo_id': search_repo_id,
|
||||
'SITE_ROOT': SITE_ROOT,
|
||||
'CSRF_COOKIE_NAME': dj_settings.CSRF_COOKIE_NAME,
|
||||
'constance_enabled': dj_settings.CONSTANCE_ENABLED,
|
||||
'FILE_SERVER_ROOT': file_server_root,
|
||||
'LOGIN_URL': dj_settings.LOGIN_URL,
|
||||
|
@ -130,6 +130,7 @@ MIDDLEWARE_CLASSES = (
|
||||
SITE_ROOT_URLCONF = 'seahub.urls'
|
||||
ROOT_URLCONF = 'seahub.utils.rooturl'
|
||||
SITE_ROOT = '/'
|
||||
CSRF_COOKIE_NAME = 'sfcsrftoken'
|
||||
|
||||
# Python dotted path to the WSGI application used by Django's runserver.
|
||||
WSGI_APPLICATION = 'seahub.wsgi.application'
|
||||
|
@ -120,6 +120,7 @@ var app = {
|
||||
mediaUrl: '{{ MEDIA_URL }}',
|
||||
siteRoot: '{{ SITE_ROOT }}',
|
||||
loginUrl: '{{ LOGIN_URL }}',
|
||||
csrfCookieName: '{{ CSRF_COOKIE_NAME }}',
|
||||
fileServerRoot: '{{ FILE_SERVER_ROOT }}'
|
||||
}
|
||||
};
|
||||
|
@ -530,7 +530,7 @@ define([
|
||||
}
|
||||
if (!(/^http:.*/.test(settings.url) || /^https:.*/.test(settings.url))) {
|
||||
// Only send the token to relative URLs i.e. locally.
|
||||
xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken'));
|
||||
xhr.setRequestHeader("X-CSRFToken", getCookie(app.config.csrfCookieName));
|
||||
}
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user