add option to auto add servers to the list of trusted servers once a federated share was created and accepted successfully

remotes/origin/fix-delete-homeidr-on-userdelete
Björn Schießle 9 years ago
parent 8f55b1a27d
commit 2754afc074
  1. 3
      apps/federation/appinfo/application.php
  2. 5
      apps/federation/appinfo/routes.php
  3. 3
      apps/federation/backgroundjob/getsharedsecret.php
  4. 3
      apps/federation/backgroundjob/requestsharedsecret.php
  5. 11
      apps/federation/controller/settingscontroller.php
  6. 9
      apps/federation/js/settings-admin.js
  7. 31
      apps/federation/lib/trustedservers.php
  8. 4
      apps/federation/settings/settings-admin.php
  9. 6
      apps/federation/templates/settings-admin.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()
);
});

@ -35,6 +35,11 @@ $application->registerRoutes(
'url' => '/trusted-servers/{id}',
'verb' => 'DELETE'
],
[
'name' => 'Settings#autoAddServers',
'url' => '/auto-add-servers',
'verb' => 'POST'
],
]
]
);

@ -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()
);
}
}

@ -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()
);
}
}

@ -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;
@ -86,6 +87,16 @@ class SettingsController extends Controller {
return new DataResponse();
}
/**
* 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
*

@ -70,4 +70,13 @@ $(document).ready(function () {
});
$("#ocFederationSettings #autoAddServers").change(function() {
$.post(
OC.generateUrl('/apps/federation/auto-add-servers'),
{
autoAddServers: $(this).is(":checked")
}
);
});
});

@ -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;
}
/**
@ -97,6 +104,28 @@ class TrustedServers {
return $result;
}
/**
* 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
*

@ -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();

@ -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>

Loading…
Cancel
Save