summaryrefslogtreecommitdiffstats
path: root/apps/files_external/appinfo
diff options
context:
space:
mode:
authorRoss Nicoll <jrn@jrn.me.uk>2014-12-19 17:23:24 +0000
committerRoss Nicoll <jrn@jrn.me.uk>2015-01-14 17:00:34 +0000
commit64f4f8fc84fd8fc27f0e9e316a2c4c2500c7134f (patch)
tree52ea57272b9dfd18d8a21b33a42be2627c661d37 /apps/files_external/appinfo
parentc8fa85451c2481b6afb438f41f12144b2929d320 (diff)
downloadnextcloud-server-64f4f8fc84fd8fc27f0e9e316a2c4c2500c7134f.tar.gz
nextcloud-server-64f4f8fc84fd8fc27f0e9e316a2c4c2500c7134f.zip
Add support for SFTP key authentication
Add support for external files accessed via SFTP using public key exchange authentication. Keys are generated automatically when the configuration is added, or can be regenerated on demand if a key is compromised. Creation of a new configuration row now triggers focus on that row. This is used to trigger auto-configuration for SFTP keys. Generated public keys are saved in user's data directory for easy retrieval by an external application. Add controller for SFTP key generation AJAX SFTP class initialisation no longer produces a warning if the password field is missing. Add unit tests for SFTP with key authentication backend
Diffstat (limited to 'apps/files_external/appinfo')
-rw-r--r--apps/files_external/appinfo/app.php13
-rw-r--r--apps/files_external/appinfo/application.php33
-rw-r--r--apps/files_external/appinfo/routes.php20
3 files changed, 65 insertions, 1 deletions
diff --git a/apps/files_external/appinfo/app.php b/apps/files_external/appinfo/app.php
index 0aafcad559a..74f0e337a12 100644
--- a/apps/files_external/appinfo/app.php
+++ b/apps/files_external/appinfo/app.php
@@ -18,6 +18,7 @@ OC::$CLASSPATH['OC\Files\Storage\SMB_OC'] = 'files_external/lib/smb_oc.php';
OC::$CLASSPATH['OC\Files\Storage\AmazonS3'] = 'files_external/lib/amazons3.php';
OC::$CLASSPATH['OC\Files\Storage\Dropbox'] = 'files_external/lib/dropbox.php';
OC::$CLASSPATH['OC\Files\Storage\SFTP'] = 'files_external/lib/sftp.php';
+OC::$CLASSPATH['OC\Files\Storage\SFTP_Key'] = 'files_external/lib/sftp_key.php';
OC::$CLASSPATH['OC_Mount_Config'] = 'files_external/lib/config.php';
OC::$CLASSPATH['OCA\Files\External\Api'] = 'files_external/lib/api.php';
@@ -177,5 +178,17 @@ OC_Mount_Config::registerBackend('\OC\Files\Storage\SFTP', array(
'password' => '*'.$l->t('Password'),
'root' => '&'.$l->t('Remote subfolder'))));
+OC_Mount_Config::registerBackend('\OC\Files\Storage\SFTP_Key', [
+ 'backend' => 'SFTP with secret key login',
+ 'priority' => 100,
+ 'configuration' => array(
+ 'host' => (string)$l->t('Host'),
+ 'user' => (string)$l->t('Username'),
+ 'public_key' => (string)$l->t('Public key'),
+ 'private_key' => '#private_key',
+ 'root' => '&'.$l->t('Remote subfolder')),
+ 'custom' => 'sftp_key',
+ ]
+);
$mountProvider = new \OCA\Files_External\Config\ConfigAdapter();
\OC::$server->getMountProviderCollection()->registerProvider($mountProvider);
diff --git a/apps/files_external/appinfo/application.php b/apps/files_external/appinfo/application.php
new file mode 100644
index 00000000000..b1605bb98a8
--- /dev/null
+++ b/apps/files_external/appinfo/application.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ * Copyright (c) 2015 University of Edinburgh <Ross.Nicoll@ed.ac.uk>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OCA\Files_External\Appinfo;
+
+use \OCA\Files_External\Controller\AjaxController;
+use \OCP\AppFramework\App;
+use \OCP\IContainer;
+
+ /**
+ * @package OCA\Files_External\Appinfo
+ */
+class Application extends App {
+ public function __construct(array $urlParams=array()) {
+ parent::__construct('files_external', $urlParams);
+ $container = $this->getContainer();
+
+ /**
+ * Controllers
+ */
+ $container->registerService('AjaxController', function (IContainer $c) {
+ return new AjaxController(
+ $c->query('AppName'),
+ $c->query('Request')
+ );
+ });
+ }
+}
diff --git a/apps/files_external/appinfo/routes.php b/apps/files_external/appinfo/routes.php
index b852b34c5d3..5c7c4eca909 100644
--- a/apps/files_external/appinfo/routes.php
+++ b/apps/files_external/appinfo/routes.php
@@ -20,6 +20,23 @@
*
*/
+namespace OCA\Files_External\Appinfo;
+
+$application = new Application();
+$application->registerRoutes(
+ $this,
+ array(
+ 'routes' => array(
+ array(
+ 'name' => 'Ajax#getSshKeys',
+ 'url' => '/ajax/sftp_key.php',
+ 'verb' => 'POST',
+ 'requirements' => array()
+ )
+ )
+ )
+);
+
/** @var $this OC\Route\Router */
$this->create('files_external_add_mountpoint', 'ajax/addMountPoint.php')
@@ -37,10 +54,11 @@ $this->create('files_external_dropbox', 'ajax/dropbox.php')
$this->create('files_external_google', 'ajax/google.php')
->actionInclude('files_external/ajax/google.php');
+
$this->create('files_external_list_applicable', '/applicable')
->actionInclude('files_external/ajax/applicable.php');
-OC_API::register('get',
+\OC_API::register('get',
'/apps/files_external/api/v1/mounts',
array('\OCA\Files\External\Api', 'getUserMounts'),
'files_external');