File tree 3 files changed +20
-3
lines changed
apps/files/lib/Controller
private/Authentication/TwoFactorAuth
3 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -158,6 +158,7 @@ protected function getStorageInfo() {
158
158
/**
159
159
* @NoCSRFRequired
160
160
* @NoAdminRequired
161
+ * @UseSession
161
162
*
162
163
* @param string $fileid
163
164
* @return TemplateResponse|RedirectResponse
Original file line number Diff line number Diff line change 66
66
use OCP \EventDispatcher \IEventDispatcher ;
67
67
use OCP \Group \Events \UserRemovedEvent ;
68
68
use OCP \ILogger ;
69
+ use OCP \IRequest ;
69
70
use OCP \Server ;
70
71
use OCP \Share ;
71
72
use OC \Encryption \HookManager ;
@@ -414,8 +415,22 @@ private static function printUpgradePage(\OC\SystemConfig $systemConfig) {
414
415
$ tmpl ->printPage ();
415
416
}
416
417
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 ' ) {
419
434
ini_set ('session.cookie_secure ' , 'true ' );
420
435
}
421
436
Original file line number Diff line number Diff line change 42
42
use OCP \IConfig ;
43
43
use OCP \ISession ;
44
44
use OCP \IUser ;
45
+ use OCP \Session \Exceptions \SessionNotAvailableException ;
45
46
use Psr \Log \LoggerInterface ;
46
47
use Symfony \Component \EventDispatcher \EventDispatcherInterface ;
47
48
use Symfony \Component \EventDispatcher \GenericEvent ;
@@ -362,7 +363,7 @@ public function needsSecondFactor(IUser $user = null): bool {
362
363
$ this ->session ->set (self ::SESSION_UID_DONE , $ user ->getUID ());
363
364
return false ;
364
365
}
365
- } catch (InvalidTokenException $ e ) {
366
+ } catch (InvalidTokenException | SessionNotAvailableException $ e ) {
366
367
}
367
368
}
368
369
You can’t perform that action at this time.
0 commit comments