diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-10-21 15:06:48 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-10-26 13:00:00 +0100 |
commit | c79496b5a3ac05f607e4ac0d4036da42e120d28f (patch) | |
tree | c320268a73df4747bf5554fa84a634031fffa59e /apps/dav/lib/server.php | |
parent | 9a7a45bc37ff07dcb3d57f91ab8014fd21c4a40e (diff) | |
download | nextcloud-server-c79496b5a3ac05f607e4ac0d4036da42e120d28f.tar.gz nextcloud-server-c79496b5a3ac05f607e4ac0d4036da42e120d28f.zip |
Introduced the new webdav endpoint remote.php/dav holding the principals and the files collection
Diffstat (limited to 'apps/dav/lib/server.php')
-rw-r--r-- | apps/dav/lib/server.php | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/apps/dav/lib/server.php b/apps/dav/lib/server.php new file mode 100644 index 00000000000..fa572eb30d1 --- /dev/null +++ b/apps/dav/lib/server.php @@ -0,0 +1,54 @@ +<?php + +namespace OCA\DAV; + +use OCA\DAV\Connector\Sabre\Auth; +use OCA\DAV\Connector\Sabre\BlockLegacyClientPlugin; +use OCA\DAV\Files\CustomPropertiesBackend; +use OCP\IRequest; +use Sabre\DAV\Auth\Plugin; +use Sabre\HTTP\Util; + +class Server { + + /** @var IRequest */ + private $request; + + public function __construct(IRequest $request, $baseUri) { + $this->request = $request; + $this->baseUri = $baseUri; + $root = new RootCollection(); + $this->server = new \OCA\DAV\Connector\Sabre\Server($root); + + // Backends + $authBackend = new Auth(); + + // Set URL explicitly due to reverse-proxy situations + $this->server->httpRequest->setUrl($this->request->getRequestUri()); + $this->server->setBaseUri($this->baseUri); + + $this->server->addPlugin(new BlockLegacyClientPlugin(\OC::$server->getConfig())); + $this->server->addPlugin(new Plugin($authBackend, 'ownCloud')); + + // wait with registering these until auth is handled and the filesystem is setup + $this->server->on('beforeMethod', function () { + // custom properties plugin must be the last one + $user = \OC::$server->getUserSession()->getUser(); + if (!is_null($user)) { + $this->server->addPlugin( + new \Sabre\DAV\PropertyStorage\Plugin( + new CustomPropertiesBackend( + $this->server->tree, + \OC::$server->getDatabaseConnection(), + \OC::$server->getUserSession()->getUser() + ) + ) + ); + } + }); + } + + public function exec() { + $this->server->exec(); + } +} |