Skip to content
Snippets Groups Projects
Unverified Commit d7161b4e authored by Julius Härtl's avatar Julius Härtl
Browse files

Only catch anonymous OPTIONS for Office


Signed-off-by: default avatarJulius Härtl <jus@bitgrid.net>
parent 84a35361
No related branches found
No related tags found
No related merge requests found
...@@ -67,9 +67,9 @@ class AnonymousOptionsPlugin extends ServerPlugin { ...@@ -67,9 +67,9 @@ class AnonymousOptionsPlugin extends ServerPlugin {
$emptyAuth = $request->getHeader('Authorization') === null $emptyAuth = $request->getHeader('Authorization') === null
|| $request->getHeader('Authorization') === '' || $request->getHeader('Authorization') === ''
|| trim($request->getHeader('Authorization')) === 'Bearer'; || trim($request->getHeader('Authorization')) === 'Bearer';
$isAnonymousOption = $request->getMethod() === 'OPTIONS' && $emptyAuth; $isAnonymousOfficeOption = $request->getMethod() === 'OPTIONS' && $isOffice && $emptyAuth;
$isOfficeHead = $request->getMethod() === 'HEAD' && $isOffice && $emptyAuth; $isOfficeHead = $request->getMethod() === 'HEAD' && $isOffice && $emptyAuth;
if ($isAnonymousOption || $isOfficeHead) { if ($isAnonymousOfficeOption || $isOfficeHead) {
/** @var CorePlugin $corePlugin */ /** @var CorePlugin $corePlugin */
$corePlugin = $this->server->getPlugin('core'); $corePlugin = $this->server->getPlugin('core');
// setup a fake tree for anonymous access // setup a fake tree for anonymous access
......
...@@ -53,18 +53,36 @@ class AnonymousOptionsTest extends TestCase { ...@@ -53,18 +53,36 @@ class AnonymousOptionsTest extends TestCase {
public function testAnonymousOptionsRoot() { public function testAnonymousOptionsRoot() {
$response = $this->sendRequest('OPTIONS', ''); $response = $this->sendRequest('OPTIONS', '');
$this->assertEquals(200, $response->getStatus()); $this->assertEquals(401, $response->getStatus());
} }
public function testAnonymousOptionsNonRoot() { public function testAnonymousOptionsNonRoot() {
$response = $this->sendRequest('OPTIONS', 'foo'); $response = $this->sendRequest('OPTIONS', 'foo');
$this->assertEquals(200, $response->getStatus()); $this->assertEquals(401, $response->getStatus());
} }
public function testAnonymousOptionsNonRootSubDir() { public function testAnonymousOptionsNonRootSubDir() {
$response = $this->sendRequest('OPTIONS', 'foo/bar'); $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()); $this->assertEquals(200, $response->getStatus());
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment