Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/dav/lib/Connector/Sabre/AnonymousOptionsPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ public function handleAnonymousOptions(RequestInterface $request, ResponseInterf
$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
Expand Down
22 changes: 20 additions & 2 deletions apps/dav/tests/unit/DAV/AnonymousOptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,36 @@ private function sendRequest($method, $path, $userAgent = '') {
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());
}

Expand Down