Skip to content

Commit

Permalink
Merge pull request #3869 from nextcloud/verify-personal-data
Browse files Browse the repository at this point in the history
Verify personal data
  • Loading branch information
MorrisJobke authored Apr 29, 2017
2 parents 2a77331 + a0bf706 commit 1307800
Show file tree
Hide file tree
Showing 23 changed files with 957 additions and 56 deletions.
3 changes: 3 additions & 0 deletions apps/federatedfilesharing/js/settings-personal.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ $(document).ready(function() {
}
});

/* Verification icon tooltip */
$('#personal-settings-container .verify img').tooltip({placement: 'bottom', trigger: 'hover'});

$('#fileSharingSettings .clipboardButton').tooltip({placement: 'bottom', title: t('core', 'Copy'), trigger: 'hover'});

// Clipboard!
Expand Down
4 changes: 3 additions & 1 deletion apps/files_sharing/lib/Controller/ShareesAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -654,13 +654,15 @@ protected function getEmail($search) {

protected function getLookup($search) {
$isEnabled = $this->config->getAppValue('files_sharing', 'lookupServerEnabled', 'no');
$lookupServerUrl = $this->config->getSystemValue('lookup_server', 'https://lookup.nextcloud.com');
$lookupServerUrl = rtrim($lookupServerUrl, '/');
$result = [];

if($isEnabled === 'yes') {
try {
$client = $this->clientService->newClient();
$response = $client->get(
'https://lookup.nextcloud.com/users?search=' . urlencode($search),
$lookupServerUrl . '/users?search=' . urlencode($search),
[
'timeout' => 10,
'connect_timeout' => 3,
Expand Down
16 changes: 11 additions & 5 deletions apps/lookup_server_connector/appinfo/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,24 @@
\OC::$server->getAppDataDir('identityproof'),
\OC::$server->getCrypto()
);

$config = \OC::$server->getConfig();
$lookupServer = $config->getSystemValue('lookup_server', '');

$updateLookupServer = new \OCA\LookupServerConnector\UpdateLookupServer(
new \OC\Accounts\AccountManager(\OC::$server->getDatabaseConnection(), \OC::$server->getEventDispatcher()),
\OC::$server->getConfig(),
\OC::$server->getSecureRandom(),
new \OC\Accounts\AccountManager(
\OC::$server->getDatabaseConnection(),
\OC::$server->getEventDispatcher(),
\OC::$server->getJobList()
),
\OC::$server->getHTTPClientService(),
$keyManager,
new \OC\Security\IdentityProof\Signer(
$keyManager,
new \OC\AppFramework\Utility\TimeFactory(),
\OC::$server->getUserManager()
),
\OC::$server->getJobList()
\OC::$server->getJobList(),
$lookupServer
);
$updateLookupServer->userUpdated($user);
});
34 changes: 21 additions & 13 deletions apps/lookup_server_connector/lib/BackgroundJobs/RetryJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use OC\BackgroundJob\Job;
use OCP\BackgroundJob\IJobList;
use OCP\Http\Client\IClientService;
use OCP\ILogger;

class RetryJob extends Job {
/** @var IClientService */
Expand All @@ -36,21 +37,28 @@ class RetryJob extends Job {
private $lookupServer = 'https://lookup.nextcloud.com/users';

/**
* @param IClientService|null $clientService
* @param IJobList|null $jobList
* @param IClientService $clientService
* @param IJobList $jobList
*/
public function __construct(IClientService $clientService = null,
IJobList $jobList = null) {
if($clientService !== null) {
$this->clientService = $clientService;
} else {
$this->clientService = \OC::$server->getHTTPClientService();
}
if($jobList !== null) {
$this->jobList = $jobList;
} else {
$this->jobList = \OC::$server->getJobList();
public function __construct(IClientService $clientService,
IJobList $jobList) {
$this->clientService = $clientService;
$this->jobList = $jobList;
}

/**
* run the job, then remove it from the jobList
*
* @param JobList $jobList
* @param ILogger $logger
*/
public function execute($jobList, ILogger $logger = null) {

if ($this->shouldRun($this->argument)) {
parent::execute($jobList, $logger);
$jobList->remove($this, $this->argument);
}

}

protected function run($argument) {
Expand Down
36 changes: 16 additions & 20 deletions apps/lookup_server_connector/lib/UpdateLookupServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,11 @@
namespace OCA\LookupServerConnector;

use OC\Accounts\AccountManager;
use OC\Security\IdentityProof\Manager;
use OC\Security\IdentityProof\Signer;
use OCA\LookupServerConnector\BackgroundJobs\RetryJob;
use OCP\BackgroundJob\IJobList;
use OCP\Http\Client\IClientService;
use OCP\IConfig;
use OCP\IUser;
use OCP\Security\ISecureRandom;

/**
* Class UpdateLookupServer
Expand All @@ -40,44 +37,36 @@
class UpdateLookupServer {
/** @var AccountManager */
private $accountManager;
/** @var IConfig */
private $config;
/** @var ISecureRandom */
private $secureRandom;
/** @var IClientService */
private $clientService;
/** @var Manager */
private $keyManager;
/** @var Signer */
private $signer;
/** @var IJobList */
private $jobList;
/** @var string URL point to lookup server */
private $lookupServer = 'https://lookup.nextcloud.com/users';
private $lookupServer = 'https://lookup.nextcloud.com';

/**
* @param AccountManager $accountManager
* @param IConfig $config
* @param ISecureRandom $secureRandom
* @param IClientService $clientService
* @param Manager $manager
* @param Signer $signer
* @param IJobList $jobList
* @param string $lookupServer if nothing is given we use the default lookup server
*/
public function __construct(AccountManager $accountManager,
IConfig $config,
ISecureRandom $secureRandom,
IClientService $clientService,
Manager $manager,
Signer $signer,
IJobList $jobList) {
IJobList $jobList,
$lookupServer = '') {
$this->accountManager = $accountManager;
$this->config = $config;
$this->secureRandom = $secureRandom;
$this->clientService = $clientService;
$this->keyManager = $manager;
$this->signer = $signer;
$this->jobList = $jobList;
if ($lookupServer !== '') {
$this->lookupServer = $lookupServer;
}
$this->lookupServer = rtrim($this->lookupServer, '/');
$this->lookupServer .= '/users';
}

/**
Expand Down Expand Up @@ -113,6 +102,13 @@ protected function sendToLookupServer(IUser $user, array $publicData) {
$dataArray['website'] = isset($publicData[AccountManager::PROPERTY_WEBSITE]) ? $publicData[AccountManager::PROPERTY_WEBSITE]['value'] : '';
$dataArray['twitter'] = isset($publicData[AccountManager::PROPERTY_TWITTER]) ? $publicData[AccountManager::PROPERTY_TWITTER]['value'] : '';
$dataArray['phone'] = isset($publicData[AccountManager::PROPERTY_PHONE]) ? $publicData[AccountManager::PROPERTY_PHONE]['value'] : '';
$dataArray['twitter_signature'] = isset($publicData[AccountManager::PROPERTY_TWITTER]['signature']) ? $publicData[AccountManager::PROPERTY_TWITTER]['signature'] : '';
$dataArray['website_signature'] = isset($publicData[AccountManager::PROPERTY_WEBSITE]['signature']) ? $publicData[AccountManager::PROPERTY_WEBSITE]['signature'] : '';
$dataArray['verificationStatus'] =
[
AccountManager::PROPERTY_WEBSITE => isset($publicData[AccountManager::PROPERTY_WEBSITE]) ? $publicData[AccountManager::PROPERTY_WEBSITE]['verified'] : '',
AccountManager::PROPERTY_TWITTER => isset($publicData[AccountManager::PROPERTY_TWITTER]) ? $publicData[AccountManager::PROPERTY_TWITTER]['verified'] : '',
];
}

$dataArray = $this->signer->sign('lookupserver', $dataArray, $user);
Expand Down
5 changes: 5 additions & 0 deletions config/config.sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -1515,4 +1515,9 @@
*/
'copied_sample_config' => true,

/**
* use a custom lookup server to publish user data
*/
'lookup_server' => 'https://lookup.nextcloud.com',

);
4 changes: 4 additions & 0 deletions core/img/actions/verified.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions core/img/actions/verify.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions core/img/actions/verifying.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions lib/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,7 @@
'OC\\Settings\\Admin\\Sharing' => $baseDir . '/lib/private/Settings/Admin/Sharing.php',
'OC\\Settings\\Admin\\TipsTricks' => $baseDir . '/lib/private/Settings/Admin/TipsTricks.php',
'OC\\Settings\\Application' => $baseDir . '/settings/Application.php',
'OC\\Settings\\BackgroundJobs\\VerifyUserData' => $baseDir . '/settings/BackgroundJobs/VerifyUserData.php',
'OC\\Settings\\Controller\\AdminSettingsController' => $baseDir . '/settings/Controller/AdminSettingsController.php',
'OC\\Settings\\Controller\\AppSettingsController' => $baseDir . '/settings/Controller/AppSettingsController.php',
'OC\\Settings\\Controller\\AuthSettingsController' => $baseDir . '/settings/Controller/AuthSettingsController.php',
Expand Down
1 change: 1 addition & 0 deletions lib/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OC\\Settings\\Admin\\Sharing' => __DIR__ . '/../../..' . '/lib/private/Settings/Admin/Sharing.php',
'OC\\Settings\\Admin\\TipsTricks' => __DIR__ . '/../../..' . '/lib/private/Settings/Admin/TipsTricks.php',
'OC\\Settings\\Application' => __DIR__ . '/../../..' . '/settings/Application.php',
'OC\\Settings\\BackgroundJobs\\VerifyUserData' => __DIR__ . '/../../..' . '/settings/BackgroundJobs/VerifyUserData.php',
'OC\\Settings\\Controller\\AdminSettingsController' => __DIR__ . '/../../..' . '/settings/Controller/AdminSettingsController.php',
'OC\\Settings\\Controller\\AppSettingsController' => __DIR__ . '/../../..' . '/settings/Controller/AppSettingsController.php',
'OC\\Settings\\Controller\\AuthSettingsController' => __DIR__ . '/../../..' . '/settings/Controller/AuthSettingsController.php',
Expand Down
Loading

0 comments on commit 1307800

Please sign in to comment.