]> source.dussan.org Git - nextcloud-server.git/commitdiff
WebDAV Auth Connector: Check if already logged in
authorMarkus Goetz <markus@woboq.com>
Fri, 12 Jul 2013 11:42:01 +0000 (13:42 +0200)
committerMarkus Goetz <markus@woboq.com>
Wed, 17 Jul 2013 11:51:15 +0000 (13:51 +0200)
lib/connector/sabre/auth.php

index 6990d928cffee9d462e08cb8d2c6de2c615fc571..bf3a49593cbc23419ed2dd404f589bb5b1dd24e8 100644 (file)
@@ -60,4 +60,25 @@ class OC_Connector_Sabre_Auth extends Sabre_DAV_Auth_Backend_AbstractBasic {
                }
                return $user;
        }
+
+       /**
+         * Override function here. We want to cache authentication cookies
+         * in the syncing client to avoid HTTP-401 roundtrips.
+         * If the sync client supplies the cookies, then OC_User::isLoggedIn()
+         * will return true and we can see this WebDAV request as already authenticated,
+         * even if there are no HTTP Basic Auth headers.
+         * In other case, just fallback to the parent implementation.
+         *
+         * @return bool
+         */
+       public function authenticate(Sabre_DAV_Server $server, $realm) {
+               if (OC_User::isLoggedIn()) {
+                       $user = OC_User::getUser();
+                       OC_Util::setupFS($user);
+                       $this->currentUser = $user;
+                       return true;
+               }
+
+               return parent::authenticate($server, $realm);
+    }
 }