summaryrefslogtreecommitdiffstats
path: root/apps/files_external
diff options
context:
space:
mode:
authorRobin McCorkell <rmccorkell@owncloud.com>2015-08-12 22:10:30 +0100
committerRobin McCorkell <rmccorkell@owncloud.com>2015-08-28 12:58:47 +0100
commit19bc5a452a97788c9153c05523cf6dd61d9c111c (patch)
tree0fe4de3af43236efff067702c0503769b12fc9c8 /apps/files_external
parent59cf326831fdd255c284a52d20b73d49ee287216 (diff)
downloadnextcloud-server-19bc5a452a97788c9153c05523cf6dd61d9c111c.tar.gz
nextcloud-server-19bc5a452a97788c9153c05523cf6dd61d9c111c.zip
Migrate Swift external storage to new API
The Rackspace/OpenStack differences have been split into separate auth mechanisms, with correct legacy migration
Diffstat (limited to 'apps/files_external')
-rw-r--r--apps/files_external/appinfo/app.php18
-rw-r--r--apps/files_external/appinfo/application.php5
-rw-r--r--apps/files_external/lib/auth/openstack/openstack.php48
-rw-r--r--apps/files_external/lib/auth/openstack/rackspace.php46
-rw-r--r--apps/files_external/lib/backend/swift.php60
5 files changed, 159 insertions, 18 deletions
diff --git a/apps/files_external/appinfo/app.php b/apps/files_external/appinfo/app.php
index 9db4b0a6330..da24dfd819a 100644
--- a/apps/files_external/appinfo/app.php
+++ b/apps/files_external/appinfo/app.php
@@ -70,24 +70,6 @@ if (OCP\Config::getAppValue('files_external', 'allow_user_mounting', 'yes') == '
OCP\Util::connectHook('OC_Filesystem', 'post_initMountPoints', '\OC_Mount_Config', 'initMountPointsHook');
OCP\Util::connectHook('OC_User', 'post_login', 'OC\Files\Storage\SMB_OC', 'login');
-OC_Mount_Config::registerBackend('\OC\Files\Storage\Swift', [
- 'backend' => (string)$l->t('OpenStack Object Storage'),
- 'priority' => 100,
- 'configuration' => [
- 'user' => (string)$l->t('Username'),
- 'bucket' => (string)$l->t('Bucket'),
- 'region' => '&'.$l->t('Region (optional for OpenStack Object Storage)'),
- 'key' => '&*'.$l->t('API Key (required for Rackspace Cloud Files)'),
- 'tenant' => '&'.$l->t('Tenantname (required for OpenStack Object Storage)'),
- 'password' => '&*'.$l->t('Password (required for OpenStack Object Storage)'),
- 'service_name' => '&'.$l->t('Service Name (required for OpenStack Object Storage)'),
- 'url' => '&'.$l->t('URL of identity endpoint (required for OpenStack Object Storage)'),
- 'timeout' => '&'.$l->t('Timeout of HTTP requests in seconds'),
- ],
- 'has_dependencies' => true,
-]);
-
-
if (!OC_Util::runningOnWindows()) {
OC_Mount_Config::registerBackend('\OC\Files\Storage\SMB_OC', [
'backend' => (string)$l->t('SMB / CIFS using OC login'),
diff --git a/apps/files_external/appinfo/application.php b/apps/files_external/appinfo/application.php
index 1e43c737408..81e60658c8c 100644
--- a/apps/files_external/appinfo/application.php
+++ b/apps/files_external/appinfo/application.php
@@ -68,6 +68,7 @@ class Application extends App {
$container->query('OCA\Files_External\Lib\Backend\AmazonS3'),
$container->query('OCA\Files_External\Lib\Backend\Dropbox'),
$container->query('OCA\Files_External\Lib\Backend\Google'),
+ $container->query('OCA\Files_External\Lib\Backend\Swift'),
]);
if (!\OC_Util::runningOnWindows()) {
@@ -101,6 +102,10 @@ class Application extends App {
// AuthMechanism::SCHEME_OAUTH2 mechanisms
$container->query('OCA\Files_External\Lib\Auth\OAuth2\OAuth2'),
+ // AuthMechanism::SCHEME_OPENSTACK mechanisms
+ $container->query('OCA\Files_External\Lib\Auth\OpenStack\OpenStack'),
+ $container->query('OCA\Files_External\Lib\Auth\OpenStack\Rackspace'),
+
// Specialized mechanisms
$container->query('OCA\Files_External\Lib\Auth\AmazonS3\AccessKey'),
]);
diff --git a/apps/files_external/lib/auth/openstack/openstack.php b/apps/files_external/lib/auth/openstack/openstack.php
new file mode 100644
index 00000000000..faf356bcf2e
--- /dev/null
+++ b/apps/files_external/lib/auth/openstack/openstack.php
@@ -0,0 +1,48 @@
+<?php
+/**
+ * @author Robin McCorkell <rmccorkell@owncloud.com>
+ *
+ * @copyright Copyright (c) 2015, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OCA\Files_External\Lib\Auth\OpenStack;
+
+use \OCP\IL10N;
+use \OCA\Files_External\Lib\DefinitionParameter;
+use \OCA\Files_External\Lib\Auth\AuthMechanism;
+
+/**
+ * OpenStack Keystone authentication
+ */
+class OpenStack extends AuthMechanism {
+
+ public function __construct(IL10N $l) {
+ $this
+ ->setIdentifier('openstack::openstack')
+ ->setScheme(self::SCHEME_OPENSTACK)
+ ->setText($l->t('OpenStack'))
+ ->addParameters([
+ (new DefinitionParameter('user', $l->t('Username'))),
+ (new DefinitionParameter('password', $l->t('Password')))
+ ->setType(DefinitionParameter::VALUE_PASSWORD),
+ (new DefinitionParameter('tenant', $l->t('Tenant name'))),
+ (new DefinitionParameter('url', $l->t('Identity endpoint URL'))),
+ ])
+ ;
+ }
+
+}
diff --git a/apps/files_external/lib/auth/openstack/rackspace.php b/apps/files_external/lib/auth/openstack/rackspace.php
new file mode 100644
index 00000000000..9268f3aad87
--- /dev/null
+++ b/apps/files_external/lib/auth/openstack/rackspace.php
@@ -0,0 +1,46 @@
+<?php
+/**
+ * @author Robin McCorkell <rmccorkell@owncloud.com>
+ *
+ * @copyright Copyright (c) 2015, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OCA\Files_External\Lib\Auth\OpenStack;
+
+use \OCP\IL10N;
+use \OCA\Files_External\Lib\DefinitionParameter;
+use \OCA\Files_External\Lib\Auth\AuthMechanism;
+
+/**
+ * Rackspace authentication
+ */
+class Rackspace extends AuthMechanism {
+
+ public function __construct(IL10N $l) {
+ $this
+ ->setIdentifier('openstack::rackspace')
+ ->setScheme(self::SCHEME_OPENSTACK)
+ ->setText($l->t('Rackspace'))
+ ->addParameters([
+ (new DefinitionParameter('user', $l->t('Username'))),
+ (new DefinitionParameter('key', $l->t('API key')))
+ ->setType(DefinitionParameter::VALUE_PASSWORD),
+ ])
+ ;
+ }
+
+}
diff --git a/apps/files_external/lib/backend/swift.php b/apps/files_external/lib/backend/swift.php
new file mode 100644
index 00000000000..9f01a923638
--- /dev/null
+++ b/apps/files_external/lib/backend/swift.php
@@ -0,0 +1,60 @@
+<?php
+/**
+ * @author Robin McCorkell <rmccorkell@owncloud.com>
+ *
+ * @copyright Copyright (c) 2015, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OCA\Files_External\Lib\Backend;
+
+use \OCP\IL10N;
+use \OCA\Files_External\Lib\Backend\Backend;
+use \OCA\Files_External\Lib\DefinitionParameter;
+use \OCA\Files_External\Lib\Auth\AuthMechanism;
+use \OCA\Files_External\Service\BackendService;
+use \OCA\Files_External\Lib\Auth\OpenStack\OpenStack;
+use \OCA\Files_External\Lib\Auth\OpenStack\Rackspace;
+
+class Swift extends Backend {
+
+ public function __construct(IL10N $l, OpenStack $openstackAuth, Rackspace $rackspaceAuth) {
+ $this
+ ->setIdentifier('swift')
+ ->addIdentifierAlias('\OC\Files\Storage\Swift') // legacy compat
+ ->setStorageClass('\OC\Files\Storage\Swift')
+ ->setText($l->t('OpenStack Object Storage'))
+ ->addParameters([
+ (new DefinitionParameter('service_name', $l->t('Service name')))
+ ->setFlag(DefinitionParameter::FLAG_OPTIONAL),
+ (new DefinitionParameter('region', $l->t('Region')))
+ ->setFlag(DefinitionParameter::FLAG_OPTIONAL),
+ (new DefinitionParameter('bucket', $l->t('Bucket'))),
+ (new DefinitionParameter('timeout', $l->t('Request timeout (seconds)')))
+ ->setFlag(DefinitionParameter::FLAG_OPTIONAL),
+ ])
+ ->setDependencyCheck('\OC\Files\Storage\Swift::checkDependencies')
+ ->addAuthScheme(AuthMechanism::SCHEME_OPENSTACK)
+ ->setLegacyAuthMechanismCallback(function(array $params) use ($openstackAuth, $rackspaceAuth) {
+ if (isset($params['key'])) {
+ return $rackspaceAuth;
+ }
+ return $openstackAuth;
+ })
+ ;
+ }
+
+}