mirror of
https://github.com/mailcow/mailcow-dockerized.git
synced 2026-05-17 04:51:49 +00:00
Merge pull request #7089 from mailcow/fix/7039
[Web] switch from GET to POST for datatable requests
This commit is contained in:
@@ -140,17 +140,32 @@ function session_check() {
|
||||
);
|
||||
return false;
|
||||
}
|
||||
if (!empty($_POST)) {
|
||||
if ($_SESSION['CSRF']['TOKEN'] != $_POST['csrf_token']) {
|
||||
$_SESSION['return'][] = array(
|
||||
'type' => 'warning',
|
||||
'msg' => 'session_token'
|
||||
);
|
||||
return false;
|
||||
// Check if this is a POST request (form-encoded or JSON)
|
||||
$is_post_request = !empty($_POST) || (
|
||||
isset($_SERVER['CONTENT_TYPE']) &&
|
||||
strpos($_SERVER['CONTENT_TYPE'], 'application/json') !== false
|
||||
);
|
||||
|
||||
if ($is_post_request) {
|
||||
// Skip CSRF check for DataTables server-side processing endpoints
|
||||
// These are read-only operations (equivalent to GET) authenticated by session
|
||||
$is_search_endpoint = (
|
||||
isset($_GET['query']) &&
|
||||
preg_match('#^search/(domain|mailbox)$#', $_GET['query'])
|
||||
);
|
||||
|
||||
if (!$is_search_endpoint && !empty($_POST)) {
|
||||
if ($_SESSION['CSRF']['TOKEN'] != $_POST['csrf_token']) {
|
||||
$_SESSION['return'][] = array(
|
||||
'type' => 'warning',
|
||||
'msg' => 'session_token'
|
||||
);
|
||||
return false;
|
||||
}
|
||||
unset($_POST['csrf_token']);
|
||||
$_SESSION['CSRF']['TOKEN'] = bin2hex(random_bytes(32));
|
||||
$_SESSION['CSRF']['TIME'] = time();
|
||||
}
|
||||
unset($_POST['csrf_token']);
|
||||
$_SESSION['CSRF']['TOKEN'] = bin2hex(random_bytes(32));
|
||||
$_SESSION['CSRF']['TIME'] = time();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user