1
0

webdav.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 Morris Jobke <hey@morrisjobke.de>
  11. * @author Robin Appelman <robin@icewind.nl>
  12. * @author Roeland Jago Douma <roeland@famdouma.nl>
  13. * @author Thomas Müller <thomas.mueller@tmit.eu>
  14. * @author Vincent Petry <vincent@nextcloud.com>
  15. *
  16. * @license AGPL-3.0
  17. *
  18. * This code is free software: you can redistribute it and/or modify
  19. * it under the terms of the GNU Affero General Public License, version 3,
  20. * as published by the Free Software Foundation.
  21. *
  22. * This program is distributed in the hope that it will be useful,
  23. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. * GNU Affero General Public License for more details.
  26. *
  27. * You should have received a copy of the GNU Affero General Public License, version 3,
  28. * along with this program. If not, see <http://www.gnu.org/licenses/>
  29. *
  30. */
  31. use Psr\Log\LoggerInterface;
  32. // no php execution timeout for webdav
  33. if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) {
  34. @set_time_limit(0);
  35. }
  36. ignore_user_abort(true);
  37. // Turn off output buffering to prevent memory problems
  38. \OC_Util::obEnd();
  39. $serverFactory = new \OCA\DAV\Connector\Sabre\ServerFactory(
  40. \OC::$server->getConfig(),
  41. \OC::$server->get(LoggerInterface::class),
  42. \OC::$server->getDatabaseConnection(),
  43. \OC::$server->getUserSession(),
  44. \OC::$server->getMountManager(),
  45. \OC::$server->getTagManager(),
  46. \OC::$server->getRequest(),
  47. \OC::$server->getPreviewManager(),
  48. \OC::$server->getEventDispatcher(),
  49. \OC::$server->getL10N('dav')
  50. );
  51. // Backends
  52. $authBackend = new \OCA\DAV\Connector\Sabre\Auth(
  53. \OC::$server->getSession(),
  54. \OC::$server->getUserSession(),
  55. \OC::$server->getRequest(),
  56. \OC::$server->getTwoFactorAuthManager(),
  57. \OC::$server->getBruteForceThrottler(),
  58. 'principals/'
  59. );
  60. $authPlugin = new \Sabre\DAV\Auth\Plugin($authBackend);
  61. $bearerAuthPlugin = new \OCA\DAV\Connector\Sabre\BearerAuth(
  62. \OC::$server->getUserSession(),
  63. \OC::$server->getSession(),
  64. \OC::$server->getRequest()
  65. );
  66. $authPlugin->addBackend($bearerAuthPlugin);
  67. $requestUri = \OC::$server->getRequest()->getRequestUri();
  68. $server = $serverFactory->createServer($baseuri, $requestUri, $authPlugin, function () {
  69. // use the view for the logged in user
  70. return \OC\Files\Filesystem::getView();
  71. });
  72. $dispatcher = \OC::$server->getEventDispatcher();
  73. // allow setup of additional plugins
  74. $event = new \OCP\SabrePluginEvent($server);
  75. $dispatcher->dispatch('OCA\DAV\Connector\Sabre::addPlugin', $event);
  76. // And off we go!
  77. $server->exec();