Skip to content

Commit 208928c

Browse files
rhtottsdicloud
authored andcommitted
Combine the check for API calls as from MagentaCLOUD prod and NC E2E test
1 parent fbc4a4a commit 208928c

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

lib/base.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
use OCP\EventDispatcher\IEventDispatcher;
6767
use OCP\Group\Events\UserRemovedEvent;
6868
use OCP\ILogger;
69+
use OCP\IRequest;
6970
use OCP\Server;
7071
use OCP\Share;
7172
use OC\Encryption\HookManager;
@@ -414,8 +415,22 @@ private static function printUpgradePage(\OC\SystemConfig $systemConfig) {
414415
$tmpl->printPage();
415416
}
416417

417-
public static function initSession() {
418-
if (self::$server->getRequest()->getServerProtocol() === 'https') {
418+
public static function initSession(): void {
419+
$request = Server::get(IRequest::class);
420+
421+
// TODO: Temporary disabled again to solve issues with CalDAV/CardDAV clients like DAVx5 that use cookies
422+
// TODO: See https://github.com/nextcloud/server/issues/37277#issuecomment-1476366147 and the other comments
423+
// TODO: for further information.
424+
// MagentaCLOUD stays with original version of the solution from production
425+
$isDavRequest = strpos($request->getRequestUri(), '/remote.php/dav') === 0 ||
426+
strpos($request->getRequestUri(), '/remote.php/webdav') === 0;
427+
if ($request->getHeader('Authorization') !== '' && $isDavRequest && !isset($_COOKIE['nc_session_id'])) {
428+
// Do not initialize the session if a request is authenticated directly
429+
// unless there is a session cookie already sent along
430+
return;
431+
}
432+
433+
if ($request->getServerProtocol() === 'https') {
419434
ini_set('session.cookie_secure', 'true');
420435
}
421436

0 commit comments

Comments
 (0)