summaryrefslogtreecommitdiffstats
path: root/apps/dav
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2020-04-29 10:09:49 +0200
committerGitHub <noreply@github.com>2020-04-29 10:09:49 +0200
commitb569f3c2c6190197d13077c1d1fa79ce6d508d47 (patch)
treebf3025398d45a6915b236fc527e5d1fb5a2a659c /apps/dav
parent988c562fe46cb582e999a7bc7aa691c8baa890e0 (diff)
parent4f44e39718fc722b2ee64bf033256fe0958be7bb (diff)
downloadnextcloud-server-b569f3c2c6190197d13077c1d1fa79ce6d508d47.tar.gz
nextcloud-server-b569f3c2c6190197d13077c1d1fa79ce6d508d47.zip
Merge pull request #20680 from nextcloud/backport/20632/stable18
[stable18] Only catch anonymous OPTIONS for Office
Diffstat (limited to 'apps/dav')
-rw-r--r--apps/dav/lib/Connector/Sabre/AnonymousOptionsPlugin.php4
-rw-r--r--apps/dav/tests/unit/DAV/AnonymousOptionsTest.php22
2 files changed, 22 insertions, 4 deletions
diff --git a/apps/dav/lib/Connector/Sabre/AnonymousOptionsPlugin.php b/apps/dav/lib/Connector/Sabre/AnonymousOptionsPlugin.php
index e0aa19c50b3..a4f80515f70 100644
--- a/apps/dav/lib/Connector/Sabre/AnonymousOptionsPlugin.php
+++ b/apps/dav/lib/Connector/Sabre/AnonymousOptionsPlugin.php
@@ -65,9 +65,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
diff --git a/apps/dav/tests/unit/DAV/AnonymousOptionsTest.php b/apps/dav/tests/unit/DAV/AnonymousOptionsTest.php
index a61c8e1e550..57f59aa2e45 100644
--- a/apps/dav/tests/unit/DAV/AnonymousOptionsTest.php
+++ b/apps/dav/tests/unit/DAV/AnonymousOptionsTest.php
@@ -52,18 +52,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());
}