summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorBjörn Schießle <bjoern@schiessle.org>2015-11-18 15:07:41 +0100
committerBjörn Schießle <bjoern@schiessle.org>2015-11-19 18:07:25 +0100
commit2754afc0747950591b3ddca37248d363c6ab64f3 (patch)
tree9bae88b29416ec6d9e3f58abdf26e98e0b7d42e8 /apps
parent8f55b1a27d97f24751542b6dc44a89eb03387a75 (diff)
downloadnextcloud-server-2754afc0747950591b3ddca37248d363c6ab64f3.tar.gz
nextcloud-server-2754afc0747950591b3ddca37248d363c6ab64f3.zip
add option to auto add servers to the list of trusted servers once a federated share was created and accepted successfully
Diffstat (limited to 'apps')
-rw-r--r--apps/federation/appinfo/application.php3
-rw-r--r--apps/federation/appinfo/routes.php5
-rw-r--r--apps/federation/backgroundjob/getsharedsecret.php3
-rw-r--r--apps/federation/backgroundjob/requestsharedsecret.php3
-rw-r--r--apps/federation/controller/settingscontroller.php11
-rw-r--r--apps/federation/js/settings-admin.js9
-rw-r--r--apps/federation/lib/trustedservers.php31
-rw-r--r--apps/federation/settings/settings-admin.php4
-rw-r--r--apps/federation/templates/settings-admin.php6
9 files changed, 67 insertions, 8 deletions
diff --git a/apps/federation/appinfo/application.php b/apps/federation/appinfo/application.php
index e91506a30bd..72a30f9ae0a 100644
--- a/apps/federation/appinfo/application.php
+++ b/apps/federation/appinfo/application.php
@@ -73,7 +73,8 @@ class Application extends \OCP\AppFramework\App {
\OC::$server->getHTTPClientService(),
\OC::$server->getLogger(),
\OC::$server->getJobList(),
- \OC::$server->getSecureRandom()
+ \OC::$server->getSecureRandom(),
+ \OC::$server->getConfig()
);
});
diff --git a/apps/federation/appinfo/routes.php b/apps/federation/appinfo/routes.php
index f45db43e4e7..8c1629a4fc6 100644
--- a/apps/federation/appinfo/routes.php
+++ b/apps/federation/appinfo/routes.php
@@ -35,6 +35,11 @@ $application->registerRoutes(
'url' => '/trusted-servers/{id}',
'verb' => 'DELETE'
],
+ [
+ 'name' => 'Settings#autoAddServers',
+ 'url' => '/auto-add-servers',
+ 'verb' => 'POST'
+ ],
]
]
);
diff --git a/apps/federation/backgroundjob/getsharedsecret.php b/apps/federation/backgroundjob/getsharedsecret.php
index 665c6ec6cce..3e8597cd78b 100644
--- a/apps/federation/backgroundjob/getsharedsecret.php
+++ b/apps/federation/backgroundjob/getsharedsecret.php
@@ -85,7 +85,8 @@ class GetSharedSecret extends QueuedJob{
\OC::$server->getHTTPClientService(),
\OC::$server->getLogger(),
$this->jobList,
- \OC::$server->getSecureRandom()
+ \OC::$server->getSecureRandom(),
+ \OC::$server->getConfig()
);
}
}
diff --git a/apps/federation/backgroundjob/requestsharedsecret.php b/apps/federation/backgroundjob/requestsharedsecret.php
index b61026a4d66..b73b620b4b7 100644
--- a/apps/federation/backgroundjob/requestsharedsecret.php
+++ b/apps/federation/backgroundjob/requestsharedsecret.php
@@ -77,7 +77,8 @@ class RequestSharedSecret extends QueuedJob {
\OC::$server->getHTTPClientService(),
\OC::$server->getLogger(),
$this->jobList,
- \OC::$server->getSecureRandom()
+ \OC::$server->getSecureRandom(),
+ \OC::$server->getConfig()
);
}
}
diff --git a/apps/federation/controller/settingscontroller.php b/apps/federation/controller/settingscontroller.php
index 8d522328120..2e28cd60cfa 100644
--- a/apps/federation/controller/settingscontroller.php
+++ b/apps/federation/controller/settingscontroller.php
@@ -26,6 +26,7 @@ use OCA\Federation\TrustedServers;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
+use OCP\IConfig;
use OCP\IL10N;
use OCP\IRequest;
@@ -87,6 +88,16 @@ class SettingsController extends Controller {
}
/**
+ * enable/disable to automatically add servers to the list of trusted servers
+ * once a federated share was created and accepted successfully
+ *
+ * @param bool $autoAddServers
+ */
+ public function autoAddServers($autoAddServers) {
+ $this->trustedServers->setAutoAddServers($autoAddServers);
+ }
+
+ /**
* check if the server should be added to the list of trusted servers or not
*
* @param string $url
diff --git a/apps/federation/js/settings-admin.js b/apps/federation/js/settings-admin.js
index 1bc7a8cc0aa..7d531b39d8c 100644
--- a/apps/federation/js/settings-admin.js
+++ b/apps/federation/js/settings-admin.js
@@ -70,4 +70,13 @@ $(document).ready(function () {
});
+ $("#ocFederationSettings #autoAddServers").change(function() {
+ $.post(
+ OC.generateUrl('/apps/federation/auto-add-servers'),
+ {
+ autoAddServers: $(this).is(":checked")
+ }
+ );
+ });
+
});
diff --git a/apps/federation/lib/trustedservers.php b/apps/federation/lib/trustedservers.php
index f3ac6e24fc6..96a29178076 100644
--- a/apps/federation/lib/trustedservers.php
+++ b/apps/federation/lib/trustedservers.php
@@ -25,6 +25,7 @@ namespace OCA\Federation;
use OCP\AppFramework\Http;
use OCP\BackgroundJob\IJobList;
use OCP\Http\Client\IClientService;
+use OCP\IConfig;
use OCP\ILogger;
use OCP\Security\ISecureRandom;
@@ -52,25 +53,31 @@ class TrustedServers {
/** @var ISecureRandom */
private $secureRandom;
+ /** @var IConfig */
+ private $config;
+
/**
* @param DbHandler $dbHandler
* @param IClientService $httpClientService
* @param ILogger $logger
* @param IJobList $jobList
* @param ISecureRandom $secureRandom
+ * @param IConfig $config
*/
public function __construct(
DbHandler $dbHandler,
IClientService $httpClientService,
ILogger $logger,
IJobList $jobList,
- ISecureRandom $secureRandom
+ ISecureRandom $secureRandom,
+ IConfig $config
) {
$this->dbHandler = $dbHandler;
$this->httpClientService = $httpClientService;
$this->logger = $logger;
$this->jobList = $jobList;
$this->secureRandom = $secureRandom;
+ $this->config = $config;
}
/**
@@ -98,6 +105,28 @@ class TrustedServers {
}
/**
+ * enable/disable to automatically add servers to the list of trusted servers
+ * once a federated share was created and accepted successfully
+ *
+ * @param bool $status
+ */
+ public function setAutoAddServers($status) {
+ $value = $status ? '1' : '0';
+ $this->config->setAppValue('federation', 'autoAddServers', $value);
+ }
+
+ /**
+ * return if we automatically add servers to the list of trusted servers
+ * once a federated share was created and accepted successfully
+ *
+ * @return bool
+ */
+ public function getAutoAddServers() {
+ $value = $this->config->getAppValue('federation', 'autoAddServers', '1');
+ return $value === '1';
+ }
+
+ /**
* get shared secret for the given server
*
* @param string $url
diff --git a/apps/federation/settings/settings-admin.php b/apps/federation/settings/settings-admin.php
index c160b7ee825..76ae0c3b6e0 100644
--- a/apps/federation/settings/settings-admin.php
+++ b/apps/federation/settings/settings-admin.php
@@ -33,9 +33,11 @@ $trustedServers = new \OCA\Federation\TrustedServers(
\OC::$server->getHTTPClientService(),
\OC::$server->getLogger(),
\OC::$server->getJobList(),
- \OC::$server->getSecureRandom()
+ \OC::$server->getSecureRandom(),
+ \OC::$server->getConfig()
);
$template->assign('trustedServers', $trustedServers->getServers());
+$template->assign('autoAddServers', $trustedServers->getAutoAddServers());
return $template->fetchPage();
diff --git a/apps/federation/templates/settings-admin.php b/apps/federation/templates/settings-admin.php
index f9087137d56..854bb744179 100644
--- a/apps/federation/templates/settings-admin.php
+++ b/apps/federation/templates/settings-admin.php
@@ -10,9 +10,9 @@ style('federation', 'settings-admin')
<h2><?php p($l->t('Federation')); ?></h2>
<em><?php p($l->t('ownCloud Federation allows you to connect with other trusted ownClouds to exchange the user directory. For example this will be used to auto-complete external users for federated sharing.')); ?></em>
- <p id="ocFederationShareUsers">
- <input type="checkbox" class="checkbox" id="shareUsers" />
- <label for="shareUsers">Share internal user list with other ownClouds</label>
+ <p>
+ <input id="autoAddServers" type="checkbox" class="checkbox" <?php if($_['autoAddServers']) p('checked'); ?> />
+ <label for="autoAddServers">Add server automatically once a federated share was created successfully</label>
</p>
<h3>Trusted ownCloud Servers</h3>