diff options
author | Robin Appelman <icewind@owncloud.com> | 2016-02-29 15:17:06 +0100 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2016-03-01 07:01:51 +0100 |
commit | 080a62231e6575d7963d5c251275cca741133d2f (patch) | |
tree | 955b68ce2c9ae76ccba6b3a14530491784f9934b | |
parent | 52d217d77519ed95a18237b09a351f83a0ae7f47 (diff) | |
download | nextcloud-server-080a62231e6575d7963d5c251275cca741133d2f.tar.gz nextcloud-server-080a62231e6575d7963d5c251275cca741133d2f.zip |
use ocs discover endpoint to test remote
-rw-r--r-- | apps/files_sharing/lib/controllers/externalsharescontroller.php | 21 | ||||
-rw-r--r-- | apps/files_sharing/lib/external/storage.php | 14 |
2 files changed, 27 insertions, 8 deletions
diff --git a/apps/files_sharing/lib/controllers/externalsharescontroller.php b/apps/files_sharing/lib/controllers/externalsharescontroller.php index 7ac2ef781a8..4b921f6fae8 100644 --- a/apps/files_sharing/lib/controllers/externalsharescontroller.php +++ b/apps/files_sharing/lib/controllers/externalsharescontroller.php @@ -96,9 +96,10 @@ class ExternalSharesController extends Controller { * Test whether the specified remote is accessible * * @param string $remote + * @param bool $checkVersion * @return bool */ - protected function testUrl($remote) { + protected function testUrl($remote, $checkVersion = false) { try { $client = $this->clientService->newClient(); $response = json_decode($client->get( @@ -109,7 +110,11 @@ class ExternalSharesController extends Controller { ] )->getBody()); - return !empty($response->version) && version_compare($response->version, '7.0.0', '>='); + if ($checkVersion) { + return !empty($response->version) && version_compare($response->version, '7.0.0', '>='); + } else { + return is_object($response); + } } catch (\Exception $e) { return false; } @@ -124,9 +129,17 @@ class ExternalSharesController extends Controller { * @return DataResponse */ public function testRemote($remote) { - if ($this->testUrl('https://' . $remote . '/status.php')) { + if ( + $this->testUrl('https://' . $remote . '/ocs-provider') || + $this->testUrl('https://' . $remote . '/ocs-provider/index.php') || + $this->testUrl('https://' . $remote . '/status.php', true) + ) { return new DataResponse('https'); - } elseif ($this->testUrl('http://' . $remote . '/status.php')) { + } elseif ( + $this->testUrl('http://' . $remote . '/ocs-provider') || + $this->testUrl('http://' . $remote . '/ocs-provider/index.php') || + $this->testUrl('http://' . $remote . '/status.php', true) + ) { return new DataResponse('http'); } else { return new DataResponse(false); diff --git a/apps/files_sharing/lib/external/storage.php b/apps/files_sharing/lib/external/storage.php index ba7fba654a9..7f54a955da2 100644 --- a/apps/files_sharing/lib/external/storage.php +++ b/apps/files_sharing/lib/external/storage.php @@ -218,20 +218,26 @@ class Storage extends DAV implements ISharedStorage { } /** - * check if the configured remote is a valid ownCloud instance + * check if the configured remote is a valid federated share provider * * @return bool */ protected function testRemote() { try { - $result = file_get_contents($this->remote . '/status.php'); - $data = json_decode($result); - return is_object($data) and !empty($data->version); + return $this->testRemoteUrl($this->remote . '/ocs-provider/index.php') + || $this->testRemoteUrl($this->remote . '/ocs-provider') + || $this->testRemoteUrl($this->remote . '/status.php'); } catch (\Exception $e) { return false; } } + private function testRemoteUrl($url) { + $result = file_get_contents($url); + $data = json_decode($result); + return (is_object($data) and !empty($data->version)); + } + /** * @return mixed * @throws ForbiddenException |