mirror of
https://github.com/nextcloud/server.git
synced 2026-02-13 15:54:59 -05:00
Only catch anonymous OPTIONS for Office
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
parent
4e98587e05
commit
4f44e39718
2 changed files with 22 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue