File tree Expand file tree Collapse file tree 3 files changed +20
-3
lines changed
apps/files/lib/Controller
private/Authentication/TwoFactorAuth Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -158,6 +158,7 @@ protected function getStorageInfo() {
158158 /**
159159 * @NoCSRFRequired
160160 * @NoAdminRequired
161+ * @UseSession
161162 *
162163 * @param string $fileid
163164 * @return TemplateResponse|RedirectResponse
Original file line number Diff line number Diff line change 6666use OCP \EventDispatcher \IEventDispatcher ;
6767use OCP \Group \Events \UserRemovedEvent ;
6868use OCP \ILogger ;
69+ use OCP \IRequest ;
6970use OCP \Server ;
7071use OCP \Share ;
7172use 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
Original file line number Diff line number Diff line change 4242use OCP \IConfig ;
4343use OCP \ISession ;
4444use OCP \IUser ;
45+ use OCP \Session \Exceptions \SessionNotAvailableException ;
4546use Psr \Log \LoggerInterface ;
4647use Symfony \Component \EventDispatcher \EventDispatcherInterface ;
4748use Symfony \Component \EventDispatcher \GenericEvent ;
@@ -362,7 +363,7 @@ public function needsSecondFactor(IUser $user = null): bool {
362363 $ this ->session ->set (self ::SESSION_UID_DONE , $ user ->getUID ());
363364 return false ;
364365 }
365- } catch (InvalidTokenException $ e ) {
366+ } catch (InvalidTokenException | SessionNotAvailableException $ e ) {
366367 }
367368 }
368369
You can’t perform that action at this time.
0 commit comments