aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2016-11-17 17:35:14 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2016-11-21 11:30:00 +0100
commit6f4cb12be2d026c45237359e2b0eea2266b86bdf (patch)
treea8832d88f2f4a7c47ed3411bb90023c0168e28c0 /core
parent53c8391e9691ac9eb92adf5b80436f5065944a1f (diff)
downloadnextcloud-server-6f4cb12be2d026c45237359e2b0eea2266b86bdf.tar.gz
nextcloud-server-6f4cb12be2d026c45237359e2b0eea2266b86bdf.zip
Add identity proof
Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
Diffstat (limited to 'core')
-rw-r--r--core/Application.php11
-rw-r--r--core/Controller/OCSController.php32
-rw-r--r--core/routes.php1
3 files changed, 38 insertions, 6 deletions
diff --git a/core/Application.php b/core/Application.php
index f68f7929e6a..545b5fe420b 100644
--- a/core/Application.php
+++ b/core/Application.php
@@ -30,7 +30,10 @@
namespace OC\Core;
+use OC\AppFramework\Utility\SimpleContainer;
+use OC\Security\IdentityProof\Manager;
use OCP\AppFramework\App;
+use OCP\Files\IAppData;
use OCP\Util;
/**
@@ -45,8 +48,14 @@ class Application extends App {
$container = $this->getContainer();
- $container->registerService('defaultMailAddress', function() {
+ $container->registerService('defaultMailAddress', function () {
return Util::getDefaultEmailAddress('lostpassword-noreply');
});
+ $container->registerService(Manager::class, function () {
+ return new Manager(
+ \OC::$server->getAppDataDir('identityproof'),
+ \OC::$server->getCrypto()
+ );
+ });
}
}
diff --git a/core/Controller/OCSController.php b/core/Controller/OCSController.php
index 27ab9deb08a..b1c4f377a14 100644
--- a/core/Controller/OCSController.php
+++ b/core/Controller/OCSController.php
@@ -23,6 +23,7 @@ namespace OC\Core\Controller;
use OC\CapabilitiesManager;
use OC\Security\Bruteforce\Throttler;
+use OC\Security\IdentityProof\Manager;
use OCP\AppFramework\Http\DataResponse;
use OCP\IRequest;
use OCP\IUserManager;
@@ -32,13 +33,12 @@ class OCSController extends \OCP\AppFramework\OCSController {
/** @var CapabilitiesManager */
private $capabilitiesManager;
-
/** @var IUserSession */
private $userSession;
-
/** @var IUserManager */
private $userManager;
-
+ /** @var Manager */
+ private $keyManager;
/** @var Throttler */
private $throttler;
@@ -51,19 +51,21 @@ class OCSController extends \OCP\AppFramework\OCSController {
* @param IUserSession $userSession
* @param IUserManager $userManager
* @param Throttler $throttler
+ * @param Manager $keyManager
*/
public function __construct($appName,
IRequest $request,
CapabilitiesManager $capabilitiesManager,
IUserSession $userSession,
IUserManager $userManager,
- Throttler $throttler) {
+ Throttler $throttler,
+ Manager $keyManager) {
parent::__construct($appName, $request);
-
$this->capabilitiesManager = $capabilitiesManager;
$this->userSession = $userSession;
$this->userManager = $userManager;
$this->throttler = $throttler;
+ $this->keyManager = $keyManager;
}
/**
@@ -139,4 +141,24 @@ class OCSController extends \OCP\AppFramework\OCSController {
}
return new DataResponse(null, 101);
}
+
+ /**
+ * @PublicPage
+ *
+ * @param string $cloudId
+ * @return DataResponse
+ */
+ public function getIdentityProof($cloudId) {
+ $userObject = $this->userManager->get($cloudId);
+
+ if($cloudId !== null) {
+ $key = $this->keyManager->getKey($userObject);
+ $data = [
+ 'public' => $key->getPublic(),
+ ];
+ return new DataResponse($data);
+ }
+
+ return new DataResponse(101);
+ }
}
diff --git a/core/routes.php b/core/routes.php
index e5636ff6c00..2b8080a3b7b 100644
--- a/core/routes.php
+++ b/core/routes.php
@@ -61,6 +61,7 @@ $application->registerRoutes($this, [
['root' => '/cloud', 'name' => 'OCS#getCurrentUser', 'url' => '/user', 'verb' => 'GET'],
['root' => '', 'name' => 'OCS#getConfig', 'url' => '/config', 'verb' => 'GET'],
['root' => '/person', 'name' => 'OCS#personCheck', 'url' => '/check', 'verb' => 'POST'],
+ ['root' => '/identityproof', 'name' => 'OCS#getIdentityProof', 'url' => '/key/{cloudId}', 'verb' => 'GET'],
],
]);