2015-08-30 20:13:01 +03:00
|
|
|
<?php
|
|
|
|
/**
|
2016-07-21 17:49:16 +03:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
|
|
|
*
|
2017-11-06 17:56:42 +03:00
|
|
|
* @author Bjoern Schiessle <bjoern@schiessle.org>
|
2019-12-03 21:57:53 +03:00
|
|
|
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
|
2019-12-19 15:16:31 +03:00
|
|
|
* @author Julius Härtl <jus@bitgrid.net>
|
2017-11-06 17:56:42 +03:00
|
|
|
* @author Ko- <k.stoffelen@cs.ru.nl>
|
2016-05-26 20:56:05 +03:00
|
|
|
* @author Lukas Reschke <lukas@statuscode.ch>
|
2017-11-06 17:56:42 +03:00
|
|
|
* @author Robin Appelman <robin@icewind.nl>
|
2016-07-21 17:49:16 +03:00
|
|
|
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
2015-08-30 20:13:01 +03:00
|
|
|
* @author Thomas Müller <thomas.mueller@tmit.eu>
|
2017-11-06 17:56:42 +03:00
|
|
|
* @author Vincent Petry <pvince81@owncloud.com>
|
2015-08-30 20:13:01 +03: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,
|
2019-12-03 21:57:53 +03:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
2015-08-30 20:13:01 +03:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
// no php execution timeout for webdav
|
2017-03-11 19:04:21 +03:00
|
|
|
if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) {
|
|
|
|
@set_time_limit(0);
|
|
|
|
}
|
2017-01-13 14:55:08 +03:00
|
|
|
ignore_user_abort(true);
|
2015-08-30 20:13:01 +03: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 15:46:31 +03:00
|
|
|
\OC::$server->getTagManager(),
|
2016-07-26 14:15:12 +03:00
|
|
|
\OC::$server->getRequest(),
|
2019-11-21 17:47:11 +03:00
|
|
|
\OC::$server->getPreviewManager(),
|
2020-05-06 19:11:54 +03:00
|
|
|
\OC::$server->getEventDispatcher(),
|
|
|
|
\OC::$server->getL10N('dav')
|
2015-08-30 20:13:01 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
// Backends
|
2015-10-23 18:26:54 +03:00
|
|
|
$authBackend = new \OCA\DAV\Connector\Sabre\Auth(
|
|
|
|
\OC::$server->getSession(),
|
2016-01-20 23:08:23 +03:00
|
|
|
\OC::$server->getUserSession(),
|
2016-02-16 15:16:52 +03:00
|
|
|
\OC::$server->getRequest(),
|
2016-06-01 11:42:38 +03:00
|
|
|
\OC::$server->getTwoFactorAuthManager(),
|
2016-07-20 19:36:15 +03:00
|
|
|
\OC::$server->getBruteForceThrottler(),
|
2016-01-20 23:08:23 +03:00
|
|
|
'principals/'
|
2015-10-23 18:26:54 +03:00
|
|
|
);
|
2017-05-18 22:19:39 +03: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 20:13:01 +03:00
|
|
|
$requestUri = \OC::$server->getRequest()->getRequestUri();
|
|
|
|
|
2020-04-09 14:53:40 +03:00
|
|
|
$server = $serverFactory->createServer($baseuri, $requestUri, $authPlugin, function () {
|
2015-08-30 20:13:01 +03:00
|
|
|
// use the view for the logged in user
|
|
|
|
return \OC\Files\Filesystem::getView();
|
|
|
|
});
|
|
|
|
|
2017-08-30 13:32:52 +03: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 20:13:01 +03:00
|
|
|
// And off we go!
|
|
|
|
$server->exec();
|