diff options
author | Björn Schießle <bjoern@schiessle.org> | 2015-11-10 10:50:59 +0100 |
---|---|---|
committer | Björn Schießle <bjoern@schiessle.org> | 2015-11-19 18:06:51 +0100 |
commit | 698100d279fdd8c8bc086e729833705d1a31c018 (patch) | |
tree | 3e38110373da82a5a89dbbe1a84708b6208b7d51 /apps/federation/appinfo | |
parent | ed039ee5ebdba6778b245f249fe206d2423a6a36 (diff) | |
download | nextcloud-server-698100d279fdd8c8bc086e729833705d1a31c018.tar.gz nextcloud-server-698100d279fdd8c8bc086e729833705d1a31c018.zip |
exchange shared secret
Diffstat (limited to 'apps/federation/appinfo')
-rw-r--r-- | apps/federation/appinfo/application.php | 56 | ||||
-rw-r--r-- | apps/federation/appinfo/database.xml | 22 | ||||
-rw-r--r-- | apps/federation/appinfo/routes.php | 35 |
3 files changed, 95 insertions, 18 deletions
diff --git a/apps/federation/appinfo/application.php b/apps/federation/appinfo/application.php index 46a791c25d0..e91506a30bd 100644 --- a/apps/federation/appinfo/application.php +++ b/apps/federation/appinfo/application.php @@ -21,13 +21,15 @@ namespace OCA\Federation\AppInfo; +use OCA\Federation\API\OCSAuthAPI; +use OCA\Federation\Controller\AuthController; use OCA\Federation\Controller\SettingsController; use OCA\Federation\DbHandler; use OCA\Federation\Middleware\AddServerMiddleware; use OCA\Federation\TrustedServers; +use OCP\API; use OCP\App; use OCP\AppFramework\IAppContainer; -use OCP\IAppConfig; class Application extends \OCP\AppFramework\App { @@ -38,7 +40,6 @@ class Application extends \OCP\AppFramework\App { parent::__construct('federation', $urlParams); $this->registerService(); $this->registerMiddleware(); - } /** @@ -70,7 +71,9 @@ class Application extends \OCP\AppFramework\App { return new TrustedServers( $c->query('DbHandler'), \OC::$server->getHTTPClientService(), - \OC::$server->getLogger() + \OC::$server->getLogger(), + \OC::$server->getJobList(), + \OC::$server->getSecureRandom() ); }); @@ -83,10 +86,57 @@ class Application extends \OCP\AppFramework\App { $c->query('TrustedServers') ); }); + + + $container->registerService('AuthController', function (IAppContainer $c) { + $server = $c->getServer(); + return new AuthController( + $c->getAppName(), + $server->getRequest(), + $server->getSecureRandom(), + $server->getJobList(), + $c->query('TrustedServers'), + $c->query('DbHandler') + ); + }); } private function registerMiddleware() { $container = $this->getContainer(); $container->registerMiddleware('addServerMiddleware'); } + + /** + * register OCS API Calls + */ + public function registerOCSApi() { + + $container = $this->getContainer(); + $server = $container->getServer(); + + $auth = new OCSAuthAPI( + $server->getRequest(), + $server->getSecureRandom(), + $server->getJobList(), + $container->query('TrustedServers'), + $container->query('DbHandler') + + ); + + API::register('get', + '/apps/federation/api/v1/shared-secret', + array($auth, 'getSharedSecret'), + 'federation', + API::GUEST_AUTH + ); + + API::register('post', + '/apps/federation/api/v1/request-shared-secret', + array($auth, 'requestSharedSecret'), + 'federation', + API::GUEST_AUTH + ); + + } + } diff --git a/apps/federation/appinfo/database.xml b/apps/federation/appinfo/database.xml index da16212ca19..e0bb241918e 100644 --- a/apps/federation/appinfo/database.xml +++ b/apps/federation/appinfo/database.xml @@ -28,7 +28,27 @@ <default></default> <notnull>true</notnull> <length>32</length> - <comments>md5 hash of the url</comments> + <comments>md5 hash of the url without the protocol</comments> + </field> + <field> + <name>token</name> + <type>text</type> + <length>128</length> + <comments>toke used to exchange the shared secret</comments> + </field> + <field> + <name>shared_secret</name> + <type>text</type> + <length>256</length> + <comments>shared secret used to authenticate</comments> + </field> + <field> + <name>status</name> + <type>integer</type> + <length>4</length> + <notnull>true</notnull> + <default>2</default> + <comments>current status of the connection</comments> </field> <index> <name>url_hash</name> diff --git a/apps/federation/appinfo/routes.php b/apps/federation/appinfo/routes.php index 43ccc4ed504..f45db43e4e7 100644 --- a/apps/federation/appinfo/routes.php +++ b/apps/federation/appinfo/routes.php @@ -19,17 +19,24 @@ * */ -return [ - 'routes' => [ - [ - 'name' => 'Settings#addServer', - 'url' => '/trusted-servers', - 'verb' => 'POST' - ], - [ - 'name' => 'Settings#removeServer', - 'url' => '/trusted-servers/{id}', - 'verb' => 'DELETE' - ], - ] -]; +$application = new \OCA\Federation\AppInfo\Application(); + +$application->registerRoutes( + $this, + [ + 'routes' => [ + [ + 'name' => 'Settings#addServer', + 'url' => '/trusted-servers', + 'verb' => 'POST' + ], + [ + 'name' => 'Settings#removeServer', + 'url' => '/trusted-servers/{id}', + 'verb' => 'DELETE' + ], + ] + ] +); + +$application->registerOCSApi(); |