mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-18 01:42:14 +09:00
Insert CSRF token in all AJAX requests via exec_xml(), exec_json(), exec_html()
일단 공식적으로 지원하는 AJAX 함수 3종에 CSRF 토큰을 삽입해 본다. 추후 체크 방식을 변경하거나 보안을 더욱 강화할 경우 X-CSRF-Token 헤더와 비교할 수도 있다. 일반 폼 제출이나 임의의 AJAX 요청에도 CSRF 토큰을 삽입하는 것은 다음 커밋에...
This commit is contained in:
parent
e2511a0269
commit
b3fb993f73
2 changed files with 13 additions and 0 deletions
|
|
@ -441,6 +441,13 @@ function move_url(url, open_window) {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get CSRF token for the document
|
||||
*/
|
||||
function getCSRFToken() {
|
||||
return $("meta[name='csrf-token']").attr("content");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 멀티미디어 출력용 (IE에서 플래쉬/동영상 주변에 점선 생김 방지용)
|
||||
**/
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
params.module = module;
|
||||
params.act = act;
|
||||
params._rx_ajax_compat = 'XMLRPC';
|
||||
params._rx_csrf_token = getCSRFToken();
|
||||
|
||||
// Fill in the XE vid.
|
||||
if (typeof(xeVid) != "undefined") params.vid = xeVid;
|
||||
|
|
@ -148,6 +149,7 @@
|
|||
$.ajax({
|
||||
url : url,
|
||||
type : "POST",
|
||||
headers: { "X-CSRF-Token": params._rx_csrf_token },
|
||||
dataType : "json",
|
||||
data : params,
|
||||
success : successHandler,
|
||||
|
|
@ -172,6 +174,7 @@
|
|||
params.module = action[0];
|
||||
params.act = action[1];
|
||||
params._rx_ajax_compat = 'JSON';
|
||||
params._rx_csrf_token = getCSRFToken();
|
||||
|
||||
// Fill in the XE vid.
|
||||
if (typeof(xeVid) != "undefined") params.vid = xeVid;
|
||||
|
|
@ -256,6 +259,7 @@
|
|||
$.ajax({
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
headers: { "X-CSRF-Token": params._rx_csrf_token },
|
||||
url: request_uri,
|
||||
data: params,
|
||||
success : successHandler,
|
||||
|
|
@ -278,6 +282,7 @@
|
|||
//if (action.length != 2) return;
|
||||
params.module = action[0];
|
||||
params.act = action[1];
|
||||
params._rx_csrf_token = getCSRFToken();
|
||||
|
||||
// Fill in the XE vid.
|
||||
if (typeof(xeVid) != "undefined") params.vid = xeVid;
|
||||
|
|
@ -319,6 +324,7 @@
|
|||
$.ajax({
|
||||
type: "POST",
|
||||
dataType: "html",
|
||||
headers: { "X-CSRF-Token": params._rx_csrf_token },
|
||||
url: request_uri,
|
||||
data: params,
|
||||
success: successHandler,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue