2015-08-30 17:13:01 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2016-07-21 14:49:16 +00:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
|
|
|
*
|
2017-11-06 14:56:42 +00:00
|
|
|
* @author Bjoern Schiessle <bjoern@schiessle.org>
|
2016-07-21 14:49:16 +00:00
|
|
|
* @author Christoph Wurst <christoph@owncloud.com>
|
2017-11-06 14:56:42 +00:00
|
|
|
* @author Ko- <k.stoffelen@cs.ru.nl>
|
2016-05-26 17:56:05 +00:00
|
|
|
* @author Lukas Reschke <lukas@statuscode.ch>
|
2017-11-06 14:56:42 +00:00
|
|
|
* @author Robin Appelman <robin@icewind.nl>
|
2016-07-21 14:49:16 +00:00
|
|
|
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
2015-08-30 17:13:01 +00:00
|
|
|
* @author Thomas Müller <thomas.mueller@tmit.eu>
|
2017-11-06 14:56:42 +00:00
|
|
|
* @author Vincent Petry <pvince81@owncloud.com>
|
2015-08-30 17:13:01 +00:00
|
|
|
*
|
|
|
|
* @license AGPL-3.0
|
|
|
|
*
|
|
|
|
* This code is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3,
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3,
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
// no php execution timeout for webdav
|
2017-03-11 16:04:21 +00:00
|
|
|
if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) {
|
|
|
|
@set_time_limit(0);
|
|
|
|
}
|
2017-01-13 11:55:08 +00:00
|
|
|
ignore_user_abort(true);
|
2015-08-30 17:13:01 +00:00
|
|
|
|
|
|
|
// Turn off output buffering to prevent memory problems
|
|
|
|
\OC_Util::obEnd();
|
|
|
|
|
|
|
|
$serverFactory = new \OCA\DAV\Connector\Sabre\ServerFactory(
|
|
|
|
\OC::$server->getConfig(),
|
|
|
|
\OC::$server->getLogger(),
|
|
|
|
\OC::$server->getDatabaseConnection(),
|
|
|
|
\OC::$server->getUserSession(),
|
|
|
|
\OC::$server->getMountManager(),
|
2015-10-15 12:46:31 +00:00
|
|
|
\OC::$server->getTagManager(),
|
2016-07-26 11:15:12 +00:00
|
|
|
\OC::$server->getRequest(),
|
|
|
|
\OC::$server->getPreviewManager()
|
2015-08-30 17:13:01 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// Backends
|
2015-10-23 15:26:54 +00:00
|
|
|
$authBackend = new \OCA\DAV\Connector\Sabre\Auth(
|
|
|
|
\OC::$server->getSession(),
|
2016-01-20 20:08:23 +00:00
|
|
|
\OC::$server->getUserSession(),
|
2016-02-16 12:16:52 +00:00
|
|
|
\OC::$server->getRequest(),
|
2016-06-01 08:42:38 +00:00
|
|
|
\OC::$server->getTwoFactorAuthManager(),
|
2016-07-20 16:36:15 +00:00
|
|
|
\OC::$server->getBruteForceThrottler(),
|
2016-01-20 20:08:23 +00:00
|
|
|
'principals/'
|
2015-10-23 15:26:54 +00:00
|
|
|
);
|
2017-05-18 19:19:39 +00:00
|
|
|
$authPlugin = new \Sabre\DAV\Auth\Plugin($authBackend);
|
|
|
|
$bearerAuthPlugin = new \OCA\DAV\Connector\Sabre\BearerAuth(
|
|
|
|
\OC::$server->getUserSession(),
|
|
|
|
\OC::$server->getSession(),
|
|
|
|
\OC::$server->getRequest()
|
|
|
|
);
|
|
|
|
$authPlugin->addBackend($bearerAuthPlugin);
|
|
|
|
|
2015-08-30 17:13:01 +00:00
|
|
|
$requestUri = \OC::$server->getRequest()->getRequestUri();
|
|
|
|
|
2017-05-18 19:19:39 +00:00
|
|
|
$server = $serverFactory->createServer($baseuri, $requestUri, $authPlugin, function() {
|
2015-08-30 17:13:01 +00:00
|
|
|
// use the view for the logged in user
|
|
|
|
return \OC\Files\Filesystem::getView();
|
|
|
|
});
|
|
|
|
|
2017-08-30 10:32:52 +00:00
|
|
|
$dispatcher = \OC::$server->getEventDispatcher();
|
|
|
|
// allow setup of additional plugins
|
|
|
|
$event = new \OCP\SabrePluginEvent($server);
|
|
|
|
$dispatcher->dispatch('OCA\DAV\Connector\Sabre::addPlugin', $event);
|
|
|
|
|
2015-08-30 17:13:01 +00:00
|
|
|
// And off we go!
|
|
|
|
$server->exec();
|