You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

webdav.php 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Bjoern Schiessle <bjoern@schiessle.org>
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Julius Härtl <jus@bitgrid.net>
  8. * @author Ko- <k.stoffelen@cs.ru.nl>
  9. * @author Lukas Reschke <lukas@statuscode.ch>
  10. * @author Robin Appelman <robin@icewind.nl>
  11. * @author Roeland Jago Douma <roeland@famdouma.nl>
  12. * @author Thomas Müller <thomas.mueller@tmit.eu>
  13. * @author Vincent Petry <pvince81@owncloud.com>
  14. *
  15. * @license AGPL-3.0
  16. *
  17. * This code is free software: you can redistribute it and/or modify
  18. * it under the terms of the GNU Affero General Public License, version 3,
  19. * as published by the Free Software Foundation.
  20. *
  21. * This program is distributed in the hope that it will be useful,
  22. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. * GNU Affero General Public License for more details.
  25. *
  26. * You should have received a copy of the GNU Affero General Public License, version 3,
  27. * along with this program. If not, see <http://www.gnu.org/licenses/>
  28. *
  29. */
  30. // no php execution timeout for webdav
  31. if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) {
  32. @set_time_limit(0);
  33. }
  34. ignore_user_abort(true);
  35. // Turn off output buffering to prevent memory problems
  36. \OC_Util::obEnd();
  37. $serverFactory = new \OCA\DAV\Connector\Sabre\ServerFactory(
  38. \OC::$server->getConfig(),
  39. \OC::$server->getLogger(),
  40. \OC::$server->getDatabaseConnection(),
  41. \OC::$server->getUserSession(),
  42. \OC::$server->getMountManager(),
  43. \OC::$server->getTagManager(),
  44. \OC::$server->getRequest(),
  45. \OC::$server->getPreviewManager(),
  46. \OC::$server->getEventDispatcher()
  47. );
  48. // Backends
  49. $authBackend = new \OCA\DAV\Connector\Sabre\Auth(
  50. \OC::$server->getSession(),
  51. \OC::$server->getUserSession(),
  52. \OC::$server->getRequest(),
  53. \OC::$server->getTwoFactorAuthManager(),
  54. \OC::$server->getBruteForceThrottler(),
  55. 'principals/'
  56. );
  57. $authPlugin = new \Sabre\DAV\Auth\Plugin($authBackend);
  58. $bearerAuthPlugin = new \OCA\DAV\Connector\Sabre\BearerAuth(
  59. \OC::$server->getUserSession(),
  60. \OC::$server->getSession(),
  61. \OC::$server->getRequest()
  62. );
  63. $authPlugin->addBackend($bearerAuthPlugin);
  64. $requestUri = \OC::$server->getRequest()->getRequestUri();
  65. $server = $serverFactory->createServer($baseuri, $requestUri, $authPlugin, function() {
  66. // use the view for the logged in user
  67. return \OC\Files\Filesystem::getView();
  68. });
  69. $dispatcher = \OC::$server->getEventDispatcher();
  70. // allow setup of additional plugins
  71. $event = new \OCP\SabrePluginEvent($server);
  72. $dispatcher->dispatch('OCA\DAV\Connector\Sabre::addPlugin', $event);
  73. // And off we go!
  74. $server->exec();