|
8 | 8 | use OC\Files\Filesystem; |
9 | 9 | use OC\Files\Storage\Wrapper\DirPermissionsMask; |
10 | 10 | use OC\Files\View; |
| 11 | +use OCA\DAV\Connector\Sabre\BearerAuth; |
11 | 12 | use OCA\DAV\Connector\Sabre\PublicAuth; |
12 | 13 | use OCA\DAV\Connector\Sabre\ServerFactory; |
13 | 14 | use OCA\DAV\Files\Sharing\FilesDropPlugin; |
|
65 | 66 | Server::get(LoggerInterface::class), |
66 | 67 | Server::get(IURLGenerator::class), |
67 | 68 | ); |
| 69 | +$bearerAuthBackend = new BearerAuth( |
| 70 | + Server::get(IUserSession::class), |
| 71 | + $session, |
| 72 | + $request, |
| 73 | + Server::get(IConfig::class), |
| 74 | +); |
68 | 75 | $authPlugin = new \Sabre\DAV\Auth\Plugin($authBackend); |
| 76 | +$authPlugin->addBackend($bearerAuthBackend); |
69 | 77 |
|
70 | 78 | $l10nFactory = Server::get(IFactory::class); |
71 | 79 | $serverFactory = new ServerFactory( |
|
86 | 94 | $filesDropPlugin = new FilesDropPlugin(); |
87 | 95 |
|
88 | 96 | /** @var string $baseuri defined in public.php */ |
89 | | -$server = $serverFactory->createServer(true, $baseuri, $requestUri, $authPlugin, function (\Sabre\DAV\Server $server) use ($baseuri, $requestUri, $authBackend, $linkCheckPlugin, $filesDropPlugin) { |
| 97 | +$server = $serverFactory->createServer(true, $baseuri, $requestUri, $authPlugin, function (\Sabre\DAV\Server $server) use ($baseuri, $requestUri, $authBackend, $bearerAuthBackend, $linkCheckPlugin, $filesDropPlugin) { |
90 | 98 | // GET must be allowed for e.g. showing images and allowing Zip downloads |
91 | 99 | if ($server->httpRequest->getMethod() !== 'GET') { |
92 | 100 | // If this is *not* a GET request we only allow access to public DAV from AJAX or when Server2Server is allowed |
|
98 | 106 | } |
99 | 107 | } |
100 | 108 |
|
101 | | - $share = $authBackend->getShare(); |
| 109 | + try { |
| 110 | + $share = $authBackend->getShare(); |
| 111 | + } catch (NotFound $e) { |
| 112 | + $share = $bearerAuthBackend->getShare(); |
| 113 | + } |
102 | 114 | $isReadable = $share->getPermissions() & Constants::PERMISSION_READ; |
103 | 115 | $fileId = $share->getNodeId(); |
104 | 116 |
|
|
0 commit comments