|
|
|
|
@ -45,12 +45,19 @@ class AnonymousOptionsPlugin extends ServerPlugin { |
|
|
|
|
$this->server->on('beforeMethod', [$this, 'handleAnonymousOptions'], 9); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @return bool |
|
|
|
|
*/ |
|
|
|
|
public function isRequestInRoot($path) { |
|
|
|
|
return $path === '' || (is_string($path) && strpos($path, '/') === FALSE); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @throws \Sabre\DAV\Exception\Forbidden |
|
|
|
|
* @return bool |
|
|
|
|
*/ |
|
|
|
|
public function handleAnonymousOptions(RequestInterface $request, ResponseInterface $response) { |
|
|
|
|
if ($request->getHeader('Authorization') === null && $request->getMethod() === 'OPTIONS') { |
|
|
|
|
if ($request->getHeader('Authorization') === null && $request->getMethod() === 'OPTIONS' && $this->isRequestInRoot($request->getPath())) { |
|
|
|
|
/** @var CorePlugin $corePlugin */ |
|
|
|
|
$corePlugin = $this->server->getPlugin('core'); |
|
|
|
|
// setup a fake tree for anonymous access |
|
|
|
|
|