diff --git a/dev/docker/opencloud/csp.yaml b/dev/docker/opencloud/csp.yaml index e78ab47414..c0ae0be7de 100644 --- a/dev/docker/opencloud/csp.yaml +++ b/dev/docker/opencloud/csp.yaml @@ -21,6 +21,7 @@ directives: # In contrast to bash and docker the default is given after the | character - 'https://${ONLYOFFICE_DOMAIN|host.docker.internal:9981}/' - 'https://${COLLABORA_DOMAIN|host.docker.internal:9980}/' + - 'https://host.docker.internal:9443/' img-src: - '''self''' - 'data:' diff --git a/dev/docker/roundcube/autologin.php b/dev/docker/roundcube/autologin.php new file mode 100644 index 0000000000..b6625c041a --- /dev/null +++ b/dev/docker/roundcube/autologin.php @@ -0,0 +1,100 @@ + MAX_TOKEN_AGE) { + http_response_code(403); + die('Token expired (timestamp)'); +} + +// Verify HMAC-SHA256 signature +$message = $data . '.' . $ts; +$expectedSig = base64url_decode($sig); +$calculatedSig = hash_hmac('sha256', $message, SHARED_SECRET, true); + +if (!$expectedSig || !hash_equals($calculatedSig, $expectedSig)) { + http_response_code(403); + die('Invalid signature'); +} + +// Decode and validate payload +$payloadJson = base64url_decode($data); +if (!$payloadJson) { + http_response_code(400); + die('Invalid payload encoding'); +} + +$payload = json_decode($payloadJson, true); +if (!$payload) { + http_response_code(400); + die('Invalid payload JSON'); +} + +// Check payload expiration +if (!isset($payload['exp']) || $payload['exp'] < $now) { + http_response_code(403); + die('Token expired (payload)'); +} + +$imapUser = $payload['email'] ?? null; +$imapPass = $payload['imapPass'] ?? null; + +if (!$imapUser || !$imapPass) { + http_response_code(400); + die('Missing credentials in payload'); +} + +// --- Bootstrap Roundcube and authenticate --- + +define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/'); +require_once INSTALL_PATH . 'program/include/iniset.php'; + +$rcmail = rcmail::get_instance(0, 'xhr'); + +// Authenticate against IMAP +$auth = $rcmail->login($imapUser, $imapPass, $rcmail->config->get('default_host'), false); + +if (!$auth) { + http_response_code(401); + die('IMAP authentication failed'); +} + +// Set session cookie and redirect to inbox +$rcmail->session->set_auth_cookie(); + +header('Location: ./'); +exit; diff --git a/dev/docker/roundcube/config.inc.php b/dev/docker/roundcube/config.inc.php new file mode 100644 index 0000000000..4b0af90169 --- /dev/null +++ b/dev/docker/roundcube/config.inc.php @@ -0,0 +1,39 @@ +