diff options
Diffstat (limited to 'apps/files_sharing/lib')
-rw-r--r-- | apps/files_sharing/lib/AppInfo/Application.php | 6 | ||||
-rw-r--r-- | apps/files_sharing/lib/Controller/ShareController.php | 2 | ||||
-rw-r--r-- | apps/files_sharing/lib/External/Manager.php | 35 | ||||
-rw-r--r-- | apps/files_sharing/lib/External/Storage.php | 16 | ||||
-rw-r--r-- | apps/files_sharing/lib/Hooks.php | 6 | ||||
-rw-r--r-- | apps/files_sharing/lib/Scanner.php | 2 | ||||
-rw-r--r-- | apps/files_sharing/lib/SharedStorage.php | 10 |
7 files changed, 38 insertions, 39 deletions
diff --git a/apps/files_sharing/lib/AppInfo/Application.php b/apps/files_sharing/lib/AppInfo/Application.php index f9540df3ff2..f502d905fe8 100644 --- a/apps/files_sharing/lib/AppInfo/Application.php +++ b/apps/files_sharing/lib/AppInfo/Application.php @@ -92,17 +92,13 @@ class Application extends App { $container->registerService('ExternalManager', function (SimpleContainer $c) use ($server) { $user = $server->getUserSession()->getUser(); $uid = $user ? $user->getUID() : null; - $discoveryManager = new DiscoveryManager( - \OC::$server->getMemCacheFactory(), - \OC::$server->getHTTPClientService() - ); return new \OCA\Files_Sharing\External\Manager( $server->getDatabaseConnection(), \OC\Files\Filesystem::getMountManager(), \OC\Files\Filesystem::getLoader(), $server->getHTTPClientService(), $server->getNotificationManager(), - $discoveryManager, + $server->query(\OCP\OCS\IDiscoveryService::class), $uid ); }); diff --git a/apps/files_sharing/lib/Controller/ShareController.php b/apps/files_sharing/lib/Controller/ShareController.php index 2c6e953a0f5..732a1d32ee7 100644 --- a/apps/files_sharing/lib/Controller/ShareController.php +++ b/apps/files_sharing/lib/Controller/ShareController.php @@ -160,7 +160,7 @@ class ShareController extends Controller { /** * @PublicPage * @UseSession - * @BruteForceProtection publicLinkAuth + * @BruteForceProtection(action=publicLinkAuth) * * Authenticates against password-protected shares * @param string $token diff --git a/apps/files_sharing/lib/External/Manager.php b/apps/files_sharing/lib/External/Manager.php index 0a57324c32f..2c348907384 100644 --- a/apps/files_sharing/lib/External/Manager.php +++ b/apps/files_sharing/lib/External/Manager.php @@ -32,8 +32,11 @@ namespace OCA\Files_Sharing\External; use OC\Files\Filesystem; use OCA\FederatedFileSharing\DiscoveryManager; use OCP\Files; +use OCP\Files\Storage\IStorageFactory; use OCP\Http\Client\IClientService; +use OCP\IDBConnection; use OCP\Notification\IManager; +use OCP\OCS\IDiscoveryService; class Manager { const STORAGE = '\OCA\Files_Sharing\External\Storage'; @@ -44,7 +47,7 @@ class Manager { private $uid; /** - * @var \OCP\IDBConnection + * @var IDBConnection */ private $connection; @@ -54,7 +57,7 @@ class Manager { private $mountManager; /** - * @var \OCP\Files\Storage\IStorageFactory + * @var IStorageFactory */ private $storageLoader; @@ -67,24 +70,27 @@ class Manager { * @var IManager */ private $notificationManager; - /** @var DiscoveryManager */ - private $discoveryManager; /** - * @param \OCP\IDBConnection $connection + * @var IDiscoveryService + */ + private $discoveryService; + + /** + * @param IDBConnection $connection * @param \OC\Files\Mount\Manager $mountManager - * @param \OCP\Files\Storage\IStorageFactory $storageLoader + * @param IStorageFactory $storageLoader * @param IClientService $clientService * @param IManager $notificationManager - * @param DiscoveryManager $discoveryManager + * @param IDiscoveryService $discoveryService * @param string $uid */ - public function __construct(\OCP\IDBConnection $connection, + public function __construct(IDBConnection $connection, \OC\Files\Mount\Manager $mountManager, - \OCP\Files\Storage\IStorageFactory $storageLoader, + IStorageFactory $storageLoader, IClientService $clientService, IManager $notificationManager, - DiscoveryManager $discoveryManager, + IDiscoveryService $discoveryService, $uid) { $this->connection = $connection; $this->mountManager = $mountManager; @@ -92,7 +98,7 @@ class Manager { $this->clientService = $clientService; $this->uid = $uid; $this->notificationManager = $notificationManager; - $this->discoveryManager = $discoveryManager; + $this->discoveryService = $discoveryService; } /** @@ -260,7 +266,10 @@ class Manager { */ private function sendFeedbackToRemote($remote, $token, $remoteId, $feedback) { - $url = rtrim($remote, '/') . $this->discoveryManager->getShareEndpoint($remote) . '/' . $remoteId . '/' . $feedback . '?format=' . \OCP\Share::RESPONSE_FORMAT; + $federationEndpoints = $this->discoveryService->discover($remote, 'FEDERATED_SHARING'); + $endpoint = isset($federationEndpoints['share']) ? $federationEndpoints['share'] : '/ocs/v2.php/cloud/shares'; + + $url = rtrim($remote, '/') . $endpoint . '/' . $remoteId . '/' . $feedback . '?format=' . \OCP\Share::RESPONSE_FORMAT; $fields = array('token' => $token); $client = $this->clientService->newClient(); @@ -376,7 +385,7 @@ class Manager { /** * remove re-shares from share table and mapping in the federated_reshares table - * + * * @param $mountPointId */ protected function removeReShares($mountPointId) { diff --git a/apps/files_sharing/lib/External/Storage.php b/apps/files_sharing/lib/External/Storage.php index 319735dcaf5..b84ba5d96ab 100644 --- a/apps/files_sharing/lib/External/Storage.php +++ b/apps/files_sharing/lib/External/Storage.php @@ -51,8 +51,6 @@ class Storage extends DAV implements ISharedStorage { private $memcacheFactory; /** @var \OCP\Http\Client\IClientService */ private $httpClient; - /** @var \OCP\ICertificateManager */ - private $certificateManager; /** @var bool */ private $updateChecked = false; @@ -64,14 +62,11 @@ class Storage extends DAV implements ISharedStorage { public function __construct($options) { $this->memcacheFactory = \OC::$server->getMemCacheFactory(); $this->httpClient = $options['HttpClientService']; - $discoveryManager = new DiscoveryManager( - $this->memcacheFactory, - $this->httpClient - ); $this->manager = $options['manager']; - $this->certificateManager = $options['certificateManager']; $this->cloudId = $options['cloudId']; + $discoveryService = \OC::$server->query(\OCP\OCS\IDiscoveryService::class); + list($protocol, $remote) = explode('://', $this->cloudId->getRemote()); if (strpos($remote, '/')) { list($host, $root) = explode('/', $remote, 2); @@ -80,9 +75,12 @@ class Storage extends DAV implements ISharedStorage { $root = ''; } $secure = $protocol === 'https'; - $root = rtrim($root, '/') . $discoveryManager->getWebDavEndpoint($this->cloudId->getRemote()); + $federatedSharingEndpoints = $discoveryService->discover($this->cloudId->getRemote(), 'FEDERATED_SHARING'); + $webDavEndpoint = isset($federatedSharingEndpoints['webdav']) ? $federatedSharingEndpoints['webdav'] : '/public.php/webdav'; + $root = rtrim($root, '/') . $webDavEndpoint; $this->mountPoint = $options['mountpoint']; $this->token = $options['token']; + parent::__construct(array( 'secure' => $secure, 'host' => $host, @@ -350,7 +348,7 @@ class Storage extends DAV implements ISharedStorage { } return ($this->getPermissions($path) & \OCP\Constants::PERMISSION_SHARE); } - + public function getPermissions($path) { $response = $this->propfind($path); if (isset($response['{http://open-collaboration-services.org/ns}share-permissions'])) { diff --git a/apps/files_sharing/lib/Hooks.php b/apps/files_sharing/lib/Hooks.php index 2029e97d08b..821c3046595 100644 --- a/apps/files_sharing/lib/Hooks.php +++ b/apps/files_sharing/lib/Hooks.php @@ -32,17 +32,13 @@ use OCA\FederatedFileSharing\DiscoveryManager; class Hooks { public static function deleteUser($params) { - $discoveryManager = new DiscoveryManager( - \OC::$server->getMemCacheFactory(), - \OC::$server->getHTTPClientService() - ); $manager = new External\Manager( \OC::$server->getDatabaseConnection(), \OC\Files\Filesystem::getMountManager(), \OC\Files\Filesystem::getLoader(), \OC::$server->getHTTPClientService(), \OC::$server->getNotificationManager(), - $discoveryManager, + \OC::$server->query(\OCP\OCS\IDiscoveryService::class), $params['uid']); $manager->removeUserShares($params['uid']); diff --git a/apps/files_sharing/lib/Scanner.php b/apps/files_sharing/lib/Scanner.php index cab04fa9309..8540d296cd6 100644 --- a/apps/files_sharing/lib/Scanner.php +++ b/apps/files_sharing/lib/Scanner.php @@ -51,7 +51,7 @@ class Scanner extends \OC\Files\Cache\Scanner { if ($data === null) { return null; } - $internalPath = $this->storage->getSourcePath($path); + $internalPath = $this->storage->getUnjailedPath($path); $data['permissions'] = $this->storage->getSourceStorage()->getPermissions($internalPath); return $data; } diff --git a/apps/files_sharing/lib/SharedStorage.php b/apps/files_sharing/lib/SharedStorage.php index 3293e095590..df613bf86bb 100644 --- a/apps/files_sharing/lib/SharedStorage.php +++ b/apps/files_sharing/lib/SharedStorage.php @@ -232,7 +232,7 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedSto } public function fopen($path, $mode) { - if ($source = $this->getSourcePath($path)) { + if ($source = $this->getUnjailedPath($path)) { switch ($mode) { case 'r+': case 'rb+': @@ -274,7 +274,7 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedSto 'mode' => $mode, ); \OCP\Util::emitHook('\OC\Files\Storage\Shared', 'fopen', $info); - return $this->nonMaskedStorage->fopen($this->getSourcePath($path), $mode); + return $this->nonMaskedStorage->fopen($this->getUnjailedPath($path), $mode); } return false; } @@ -302,7 +302,7 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedSto } } - return $this->nonMaskedStorage->rename($this->getSourcePath($path1), $this->getSourcePath($path2)); + return $this->nonMaskedStorage->rename($this->getUnjailedPath($path1), $this->getUnjailedPath($path2)); } /** @@ -479,7 +479,7 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedSto public function file_get_contents($path) { $info = [ 'target' => $this->getMountPoint() . '/' . $path, - 'source' => $this->getSourcePath($path), + 'source' => $this->getUnjailedPath($path), ]; \OCP\Util::emitHook('\OC\Files\Storage\Shared', 'file_get_contents', $info); return parent::file_get_contents($path); @@ -488,7 +488,7 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedSto public function file_put_contents($path, $data) { $info = [ 'target' => $this->getMountPoint() . '/' . $path, - 'source' => $this->getSourcePath($path), + 'source' => $this->getUnjailedPath($path), ]; \OCP\Util::emitHook('\OC\Files\Storage\Shared', 'file_put_contents', $info); return parent::file_put_contents($path, $data); |