From f3798a7349c87faa6a301462665c82b209c219e5 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 27 Nov 2018 16:54:00 +0100 Subject: [PATCH 1/3] Add interface to allow storages from opting out of encryption As opposed to hard-coding a list of excluded storages Signed-off-by: Robin Appelman --- .../lib/Lib/Storage/OwnCloud.php | 3 +- apps/files_sharing/lib/External/Storage.php | 3 +- apps/files_sharing/lib/SharedStorage.php | 3 +- lib/private/Encryption/EncryptionWrapper.php | 4 +-- .../Storage/IDisableEncryptionStorage.php | 31 +++++++++++++++++++ 5 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 lib/public/Files/Storage/IDisableEncryptionStorage.php diff --git a/apps/files_external/lib/Lib/Storage/OwnCloud.php b/apps/files_external/lib/Lib/Storage/OwnCloud.php index 3ee2b70ef226d..04cd5ecf9aff4 100644 --- a/apps/files_external/lib/Lib/Storage/OwnCloud.php +++ b/apps/files_external/lib/Lib/Storage/OwnCloud.php @@ -25,6 +25,7 @@ */ namespace OCA\Files_External\Lib\Storage; +use OCP\Files\Storage\IDisableEncryptionStorage; use Sabre\DAV\Client; /** @@ -34,7 +35,7 @@ * http://%host/%context/remote.php/webdav/%root * */ -class OwnCloud extends \OC\Files\Storage\DAV{ +class OwnCloud extends \OC\Files\Storage\DAV implements IDisableEncryptionStorage { const OC_URL_SUFFIX = 'remote.php/webdav'; public function __construct($params) { diff --git a/apps/files_sharing/lib/External/Storage.php b/apps/files_sharing/lib/External/Storage.php index dadb1def702b3..7411d3c51b622 100644 --- a/apps/files_sharing/lib/External/Storage.php +++ b/apps/files_sharing/lib/External/Storage.php @@ -39,10 +39,11 @@ use OCP\Constants; use OCP\Federation\ICloudId; use OCP\Files\NotFoundException; +use OCP\Files\Storage\IDisableEncryptionStorage; use OCP\Files\StorageInvalidException; use OCP\Files\StorageNotAvailableException; -class Storage extends DAV implements ISharedStorage { +class Storage extends DAV implements ISharedStorage, IDisableEncryptionStorage { /** @var ICloudId */ private $cloudId; /** @var string */ diff --git a/apps/files_sharing/lib/SharedStorage.php b/apps/files_sharing/lib/SharedStorage.php index f9c4a85fac6ac..67868b512c3e1 100644 --- a/apps/files_sharing/lib/SharedStorage.php +++ b/apps/files_sharing/lib/SharedStorage.php @@ -39,6 +39,7 @@ use OCP\Constants; use OCP\Files\Cache\ICacheEntry; use OCP\Files\NotFoundException; +use OCP\Files\Storage\IDisableEncryptionStorage; use OCP\Files\Storage\IStorage; use OCP\Lock\ILockingProvider; use OC\User\NoUserException; @@ -46,7 +47,7 @@ /** * Convert target path to source path and pass the function call to the correct storage provider */ -class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedStorage { +class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedStorage, IDisableEncryptionStorage { /** @var \OCP\Share\IShare */ private $superShare; diff --git a/lib/private/Encryption/EncryptionWrapper.php b/lib/private/Encryption/EncryptionWrapper.php index d0f3ae79d4835..c4650d39ee3ca 100644 --- a/lib/private/Encryption/EncryptionWrapper.php +++ b/lib/private/Encryption/EncryptionWrapper.php @@ -82,9 +82,7 @@ public function wrapStorage($mountPoint, Storage $storage, IMountPoint $mount) { 'mount' => $mount ]; - if (!$storage->instanceOfStorage('OCA\Files_Sharing\SharedStorage') - && !$storage->instanceOfStorage('OCA\Files_Sharing\External\Storage') - && !$storage->instanceOfStorage('OC\Files\Storage\OwnCloud')) { + if (!$storage->instanceOfStorage(Storage\IDisableEncryptionStorage::class)) { $user = \OC::$server->getUserSession()->getUser(); $mountManager = Filesystem::getMountManager(); diff --git a/lib/public/Files/Storage/IDisableEncryptionStorage.php b/lib/public/Files/Storage/IDisableEncryptionStorage.php new file mode 100644 index 0000000000000..4941ecfb52cf2 --- /dev/null +++ b/lib/public/Files/Storage/IDisableEncryptionStorage.php @@ -0,0 +1,31 @@ + + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * 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 + * along with this program. If not, see . + * + */ + +namespace OCP\Files\Storage; + +/** + * Marks that a storage does not support server side encryption + * + * @since 15.0.0 + */ +interface IDisableEncryptionStorage { + +} \ No newline at end of file From d5e0292ba26efe759e5260a4a8ae6d10f9c11d38 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Thu, 29 Nov 2018 16:27:53 +0100 Subject: [PATCH 2/3] Update autoloader classmap Signed-off-by: Christoph Wurst --- lib/composer/composer/autoload_classmap.php | 1 + lib/composer/composer/autoload_static.php | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 3f391d51974e3..a365ae15c6786 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -227,6 +227,7 @@ 'OCP\\Files\\StorageInvalidException' => $baseDir . '/lib/public/Files/StorageInvalidException.php', 'OCP\\Files\\StorageNotAvailableException' => $baseDir . '/lib/public/Files/StorageNotAvailableException.php', 'OCP\\Files\\StorageTimeoutException' => $baseDir . '/lib/public/Files/StorageTimeoutException.php', + 'OCP\\Files\\Storage\\IDisableEncryptionStorage' => $baseDir . '/lib/public/Files/Storage/IDisableEncryptionStorage.php', 'OCP\\Files\\Storage\\ILockingStorage' => $baseDir . '/lib/public/Files/Storage/ILockingStorage.php', 'OCP\\Files\\Storage\\INotifyStorage' => $baseDir . '/lib/public/Files/Storage/INotifyStorage.php', 'OCP\\Files\\Storage\\IStorage' => $baseDir . '/lib/public/Files/Storage/IStorage.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 5b8c5b195e5f7..a85163c6dde14 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -257,6 +257,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OCP\\Files\\StorageInvalidException' => __DIR__ . '/../../..' . '/lib/public/Files/StorageInvalidException.php', 'OCP\\Files\\StorageNotAvailableException' => __DIR__ . '/../../..' . '/lib/public/Files/StorageNotAvailableException.php', 'OCP\\Files\\StorageTimeoutException' => __DIR__ . '/../../..' . '/lib/public/Files/StorageTimeoutException.php', + 'OCP\\Files\\Storage\\IDisableEncryptionStorage' => __DIR__ . '/../../..' . '/lib/public/Files/Storage/IDisableEncryptionStorage.php', 'OCP\\Files\\Storage\\ILockingStorage' => __DIR__ . '/../../..' . '/lib/public/Files/Storage/ILockingStorage.php', 'OCP\\Files\\Storage\\INotifyStorage' => __DIR__ . '/../../..' . '/lib/public/Files/Storage/INotifyStorage.php', 'OCP\\Files\\Storage\\IStorage' => __DIR__ . '/../../..' . '/lib/public/Files/Storage/IStorage.php', From 7cdc04a7932f45889fb72b3e29dd12708f1d091c Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 29 Nov 2018 16:34:49 +0100 Subject: [PATCH 3/3] update encryption wrapper tests Signed-off-by: Robin Appelman --- tests/lib/Encryption/EncryptionWrapperTest.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/tests/lib/Encryption/EncryptionWrapperTest.php b/tests/lib/Encryption/EncryptionWrapperTest.php index d20efa8821fe8..cff48d2cd6d8b 100644 --- a/tests/lib/Encryption/EncryptionWrapperTest.php +++ b/tests/lib/Encryption/EncryptionWrapperTest.php @@ -92,13 +92,7 @@ public function provideWrapStorage() { [true, ['OCA\Files_Trashbin\Storage']], // Do not wrap shared storages - [false, ['OCA\Files_Sharing\SharedStorage']], - [false, ['OCA\Files_Sharing\External\Storage']], - [false, ['OC\Files\Storage\OwnCloud']], - [false, ['OCA\Files_Sharing\SharedStorage', 'OCA\Files_Sharing\External\Storage']], - [false, ['OCA\Files_Sharing\SharedStorage', 'OC\Files\Storage\OwnCloud']], - [false, ['OCA\Files_Sharing\External\Storage', 'OC\Files\Storage\OwnCloud']], - [false, ['OCA\Files_Sharing\SharedStorage', 'OCA\Files_Sharing\External\Storage', 'OC\Files\Storage\OwnCloud']], + [false, [Storage\IDisableEncryptionStorage::class]], ]; }