git subrepo commit (merge) mailcow/src/mailcow-dockerized
subrepo:
subdir: "mailcow/src/mailcow-dockerized"
merged: "81fb18894"
upstream:
origin: "https://github.com/mailcow/mailcow-dockerized.git"
branch: "master"
commit: "4ca02ecee"
git-subrepo:
version: "0.4.6"
origin: "???"
commit: "???"
Update to upstream 2026-10. Local patches re-applied by hand
(no Unbound DNS for containers, IPv6 off by default, fake-MySQL
stubs in dockerapi, Postfix overrides, no .env symlink); dropped
the unused dovecot and clamd Dockerfile patches.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Change-Id: I2c2c194d1d436b841358685f5f94aef09eb19ae8
diff --git a/mailcow/src/mailcow-dockerized/data/web/inc/sessions.inc.php b/mailcow/src/mailcow-dockerized/data/web/inc/sessions.inc.php
index 1a33e76..ac308b6 100644
--- a/mailcow/src/mailcow-dockerized/data/web/inc/sessions.inc.php
+++ b/mailcow/src/mailcow-dockerized/data/web/inc/sessions.inc.php
@@ -1,10 +1,14 @@
<?php
// Start session
if (session_status() !== PHP_SESSION_ACTIVE) {
+ session_name($SESSION_NAME);
ini_set("session.cookie_httponly", 1);
+ ini_set("session.cookie_samesite", $SESSION_SAMESITE_POLICY);
ini_set('session.gc_maxlifetime', $SESSION_LIFETIME);
}
+$_SESSION['access_all_exception'] = '0';
+
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) &&
strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == "https") {
if (session_status() !== PHP_SESSION_ACTIVE) {
@@ -94,16 +98,33 @@
if (isset($_SESSION["dual-login"])) {
$_SESSION["mailcow_cc_username"] = $_SESSION["dual-login"]["username"];
$_SESSION["mailcow_cc_role"] = $_SESSION["dual-login"]["role"];
+ unset($_SESSION['sogo-sso-user-allowed']);
+ unset($_SESSION['sogo-sso-pass']);
unset($_SESSION["dual-login"]);
- header("Location: /mailbox");
+ if ($_SESSION["mailcow_cc_role"] == "admin"){
+ header("Location: /admin/mailbox");
+ } elseif ($_SESSION["mailcow_cc_role"] == "domainadmin") {
+ header("Location: /domainadmin/mailbox");
+ } else {
+ header("Location: /");
+ }
exit();
}
else {
+ $role = $_SESSION["mailcow_cc_role"];
session_regenerate_id(true);
session_unset();
session_destroy();
session_write_close();
- header("Location: /");
+ if ($role == "admin") {
+ header("Location: /admin");
+ }
+ elseif ($role == "domainadmin") {
+ header("Location: /domainadmin");
+ }
+ else {
+ header("Location: /");
+ }
}
}
@@ -119,17 +140,32 @@
);
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;
}