]> source.dussan.org Git - nextcloud-server.git/commitdiff
Only catch anonymous OPTIONS for Office 20632/head
authorJulius Härtl <jus@bitgrid.net>
Fri, 24 Apr 2020 11:31:17 +0000 (13:31 +0200)
committerJulius Härtl <jus@bitgrid.net>
Fri, 24 Apr 2020 12:46:07 +0000 (14:46 +0200)
Signed-off-by: Julius Härtl <jus@bitgrid.net>
apps/dav/lib/Connector/Sabre/AnonymousOptionsPlugin.php
apps/dav/tests/unit/DAV/AnonymousOptionsTest.php

index 63e577359725550ff64b86c705c4c5d92dbfc3de..e209f7f1af6bd04b563f1a5e65a2ddf3dbd4deed 100644 (file)
@@ -67,9 +67,9 @@ class AnonymousOptionsPlugin extends ServerPlugin {
                $emptyAuth = $request->getHeader('Authorization') === null
                        || $request->getHeader('Authorization') === ''
                        || trim($request->getHeader('Authorization')) === 'Bearer';
-               $isAnonymousOption = $request->getMethod() === 'OPTIONS' && $emptyAuth;
+               $isAnonymousOfficeOption = $request->getMethod() === 'OPTIONS' && $isOffice && $emptyAuth;
                $isOfficeHead = $request->getMethod() === 'HEAD' && $isOffice && $emptyAuth;
-               if ($isAnonymousOption || $isOfficeHead) {
+               if ($isAnonymousOfficeOption || $isOfficeHead) {
                        /** @var CorePlugin $corePlugin */
                        $corePlugin = $this->server->getPlugin('core');
                        // setup a fake tree for anonymous access
index 6aabb4845fe854cdc68ac53652862b6ef8e45018..c8940533ab01c8e7143f4439cdc8833196b447e0 100644 (file)
@@ -53,18 +53,36 @@ class AnonymousOptionsTest extends TestCase {
        public function testAnonymousOptionsRoot() {
                $response = $this->sendRequest('OPTIONS', '');
 
-               $this->assertEquals(200, $response->getStatus());
+               $this->assertEquals(401, $response->getStatus());
        }
 
        public function testAnonymousOptionsNonRoot() {
                $response = $this->sendRequest('OPTIONS', 'foo');
 
-               $this->assertEquals(200, $response->getStatus());
+               $this->assertEquals(401, $response->getStatus());
        }
 
        public function testAnonymousOptionsNonRootSubDir() {
                $response = $this->sendRequest('OPTIONS', 'foo/bar');
 
+               $this->assertEquals(401, $response->getStatus());
+       }
+
+       public function testAnonymousOptionsRootOffice() {
+               $response = $this->sendRequest('OPTIONS', '', 'Microsoft Office does strange things');
+
+               $this->assertEquals(200, $response->getStatus());
+       }
+
+       public function testAnonymousOptionsNonRootOffice() {
+               $response = $this->sendRequest('OPTIONS', 'foo', 'Microsoft Office does strange things');
+
+               $this->assertEquals(200, $response->getStatus());
+       }
+
+       public function testAnonymousOptionsNonRootSubDirOffice() {
+               $response = $this->sendRequest('OPTIONS', 'foo/bar', 'Microsoft Office does strange things');
+
                $this->assertEquals(200, $response->getStatus());
        }