summaryrefslogtreecommitdiffstats
path: root/apps/files_external/lib/backend
diff options
context:
space:
mode:
authorRobin McCorkell <rmccorkell@owncloud.com>2015-09-13 19:38:22 +0100
committerRobin McCorkell <rmccorkell@owncloud.com>2015-09-13 19:38:22 +0100
commit0dc71813354407fad8fa1db113d75cad78dfc12f (patch)
treeb34b739c2035808f08b8d92dac5ff1a40977b6ea /apps/files_external/lib/backend
parent2e7d50b7233dd812a0cca8bdc433fbfa41b8b31e (diff)
parent442f5269ef229afa09cbe1e06b2a73bb9656e8c4 (diff)
downloadnextcloud-server-0dc71813354407fad8fa1db113d75cad78dfc12f.tar.gz
nextcloud-server-0dc71813354407fad8fa1db113d75cad78dfc12f.zip
Merge pull request #18441 from owncloud/ext-backends.advanced
Migrate advanced external storage backends to new registration API [part 3]
Diffstat (limited to 'apps/files_external/lib/backend')
-rw-r--r--apps/files_external/lib/backend/backend.php6
-rw-r--r--apps/files_external/lib/backend/local.php2
-rw-r--r--apps/files_external/lib/backend/sftp.php1
-rw-r--r--apps/files_external/lib/backend/sftp_key.php50
-rw-r--r--apps/files_external/lib/backend/smb_oc.php69
-rw-r--r--apps/files_external/lib/backend/swift.php60
6 files changed, 184 insertions, 4 deletions
diff --git a/apps/files_external/lib/backend/backend.php b/apps/files_external/lib/backend/backend.php
index 90d5d38ed94..2a2add3ac59 100644
--- a/apps/files_external/lib/backend/backend.php
+++ b/apps/files_external/lib/backend/backend.php
@@ -22,7 +22,7 @@
namespace OCA\Files_External\Lib\Backend;
use \OCA\Files_External\Lib\StorageConfig;
-use \OCA\Files_External\Lib\VisibilityTrait;
+use \OCA\Files_External\Lib\PermissionsTrait;
use \OCA\Files_External\Lib\FrontendDefinitionTrait;
use \OCA\Files_External\Lib\PriorityTrait;
use \OCA\Files_External\Lib\DependencyTrait;
@@ -43,7 +43,7 @@ use \OCA\Files_External\Lib\Auth\AuthMechanism;
* scheme, which are provided from the authentication mechanism.
*
* This class uses the following traits:
- * - VisibilityTrait
+ * - PermissionsTrait
* Restrict usage to admin-only/none
* - FrontendDefinitionTrait
* Specify configuration parameters and other definitions
@@ -56,7 +56,7 @@ use \OCA\Files_External\Lib\Auth\AuthMechanism;
*/
class Backend implements \JsonSerializable {
- use VisibilityTrait;
+ use PermissionsTrait;
use FrontendDefinitionTrait;
use PriorityTrait;
use DependencyTrait;
diff --git a/apps/files_external/lib/backend/local.php b/apps/files_external/lib/backend/local.php
index a80b437fab7..a6635491b6e 100644
--- a/apps/files_external/lib/backend/local.php
+++ b/apps/files_external/lib/backend/local.php
@@ -39,7 +39,7 @@ class Local extends Backend {
->addParameters([
(new DefinitionParameter('datadir', $l->t('Location'))),
])
- ->setAllowedVisibility(BackendService::VISIBILITY_ADMIN)
+ ->setAllowedPermissions(BackendService::USER_PERSONAL, BackendService::PERMISSION_NONE)
->setPriority(BackendService::PRIORITY_DEFAULT + 50)
->addAuthScheme(AuthMechanism::SCHEME_NULL)
->setLegacyAuthMechanism($legacyAuth)
diff --git a/apps/files_external/lib/backend/sftp.php b/apps/files_external/lib/backend/sftp.php
index dd0f5d8e2e0..c0bcd27c54b 100644
--- a/apps/files_external/lib/backend/sftp.php
+++ b/apps/files_external/lib/backend/sftp.php
@@ -43,6 +43,7 @@ class SFTP extends Backend {
->setFlag(DefinitionParameter::FLAG_OPTIONAL),
])
->addAuthScheme(AuthMechanism::SCHEME_PASSWORD)
+ ->addAuthScheme(AuthMechanism::SCHEME_PUBLICKEY)
->setLegacyAuthMechanism($legacyAuth)
;
}
diff --git a/apps/files_external/lib/backend/sftp_key.php b/apps/files_external/lib/backend/sftp_key.php
new file mode 100644
index 00000000000..6a75172026d
--- /dev/null
+++ b/apps/files_external/lib/backend/sftp_key.php
@@ -0,0 +1,50 @@
+<?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\PublicKey\RSA;
+
+class SFTP_Key extends Backend {
+
+ public function __construct(IL10N $l, RSA $legacyAuth) {
+ $this
+ ->setIdentifier('\OC\Files\Storage\SFTP_Key')
+ ->setStorageClass('\OC\Files\Storage\SFTP')
+ ->setText($l->t('SFTP with secret key login [DEPRECATED]'))
+ ->addParameters([
+ (new DefinitionParameter('host', $l->t('Host'))),
+ (new DefinitionParameter('root', $l->t('Remote subfolder')))
+ ->setFlag(DefinitionParameter::FLAG_OPTIONAL),
+ ])
+ ->removeAllowedPermission(BackendService::USER_PERSONAL, BackendService::PERMISSION_CREATE)
+ ->removeAllowedPermission(BackendService::USER_ADMIN, BackendService::PERMISSION_CREATE)
+ ->addAuthScheme(AuthMechanism::SCHEME_PUBLICKEY)
+ ->setLegacyAuthMechanism($legacyAuth)
+ ;
+ }
+
+}
diff --git a/apps/files_external/lib/backend/smb_oc.php b/apps/files_external/lib/backend/smb_oc.php
new file mode 100644
index 00000000000..3621682fb8f
--- /dev/null
+++ b/apps/files_external/lib/backend/smb_oc.php
@@ -0,0 +1,69 @@
+<?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\Password\SessionCredentials;
+use \OCA\Files_External\Lib\StorageConfig;
+
+/**
+ * Deprecated SMB_OC class - use SMB with the password::sessioncredentials auth mechanism
+ */
+class SMB_OC extends Backend {
+
+ public function __construct(IL10N $l, SessionCredentials $legacyAuth) {
+ $this
+ ->setIdentifier('\OC\Files\Storage\SMB_OC')
+ ->setStorageClass('\OC\Files\Storage\SMB')
+ ->setText($l->t('SMB / CIFS using OC login [DEPRECATED]'))
+ ->addParameters([
+ (new DefinitionParameter('host', $l->t('Host'))),
+ (new DefinitionParameter('username_as_share', $l->t('Username as share')))
+ ->setType(DefinitionParameter::VALUE_BOOLEAN),
+ (new DefinitionParameter('share', $l->t('Share')))
+ ->setFlag(DefinitionParameter::FLAG_OPTIONAL),
+ (new DefinitionParameter('root', $l->t('Remote subfolder')))
+ ->setFlag(DefinitionParameter::FLAG_OPTIONAL),
+ ])
+ ->setDependencyCheck('\OC\Files\Storage\SMB::checkDependencies')
+ ->removeAllowedPermission(BackendService::USER_PERSONAL, BackendService::PERMISSION_CREATE)
+ ->removeAllowedPermission(BackendService::USER_ADMIN, BackendService::PERMISSION_CREATE)
+ ->setPriority(BackendService::PRIORITY_DEFAULT - 10)
+ ->addAuthScheme(AuthMechanism::SCHEME_PASSWORD)
+ ->setLegacyAuthMechanism($legacyAuth)
+ ;
+ }
+
+ public function manipulateStorageConfig(StorageConfig &$storage) {
+ $username_as_share = ($storage->getBackendOption('username_as_share') === true);
+
+ if ($username_as_share) {
+ $share = '/' . $storage->getBackendOption('user');
+ $storage->setBackendOption('share', $share);
+ }
+ }
+
+}
diff --git a/apps/files_external/lib/backend/swift.php b/apps/files_external/lib/backend/swift.php
new file mode 100644
index 00000000000..c0ac7c08345
--- /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['options']['key']) && $params['options']['key']) {
+ return $rackspaceAuth;
+ }
+ return $openstackAuth;
+ })
+ ;
+ }
+
+}