Skip to content

Commit 331f3b2

Browse files
authored
Merge pull request #12691 from nextcloud/storage-no-encryption-interface
Add interface to allow storages from opting out of encryption
2 parents a915594 + df32b7a commit 331f3b2

File tree

8 files changed

+41
-13
lines changed

8 files changed

+41
-13
lines changed

apps/files_external/lib/Lib/Storage/OwnCloud.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
*/
2626

2727
namespace OCA\Files_External\Lib\Storage;
28+
use OCP\Files\Storage\IDisableEncryptionStorage;
2829
use Sabre\DAV\Client;
2930

3031
/**
@@ -34,7 +35,7 @@
3435
* http://%host/%context/remote.php/webdav/%root
3536
*
3637
*/
37-
class OwnCloud extends \OC\Files\Storage\DAV{
38+
class OwnCloud extends \OC\Files\Storage\DAV implements IDisableEncryptionStorage {
3839
const OC_URL_SUFFIX = 'remote.php/webdav';
3940

4041
public function __construct($params) {

apps/files_sharing/lib/External/Storage.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@
3939
use OCP\Constants;
4040
use OCP\Federation\ICloudId;
4141
use OCP\Files\NotFoundException;
42+
use OCP\Files\Storage\IDisableEncryptionStorage;
4243
use OCP\Files\StorageInvalidException;
4344
use OCP\Files\StorageNotAvailableException;
4445

45-
class Storage extends DAV implements ISharedStorage {
46+
class Storage extends DAV implements ISharedStorage, IDisableEncryptionStorage {
4647
/** @var ICloudId */
4748
private $cloudId;
4849
/** @var string */

apps/files_sharing/lib/SharedStorage.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,15 @@
3939
use OCP\Constants;
4040
use OCP\Files\Cache\ICacheEntry;
4141
use OCP\Files\NotFoundException;
42+
use OCP\Files\Storage\IDisableEncryptionStorage;
4243
use OCP\Files\Storage\IStorage;
4344
use OCP\Lock\ILockingProvider;
4445
use OC\User\NoUserException;
4546

4647
/**
4748
* Convert target path to source path and pass the function call to the correct storage provider
4849
*/
49-
class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedStorage {
50+
class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedStorage, IDisableEncryptionStorage {
5051

5152
/** @var \OCP\Share\IShare */
5253
private $superShare;

lib/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@
227227
'OCP\\Files\\StorageInvalidException' => $baseDir . '/lib/public/Files/StorageInvalidException.php',
228228
'OCP\\Files\\StorageNotAvailableException' => $baseDir . '/lib/public/Files/StorageNotAvailableException.php',
229229
'OCP\\Files\\StorageTimeoutException' => $baseDir . '/lib/public/Files/StorageTimeoutException.php',
230+
'OCP\\Files\\Storage\\IDisableEncryptionStorage' => $baseDir . '/lib/public/Files/Storage/IDisableEncryptionStorage.php',
230231
'OCP\\Files\\Storage\\ILockingStorage' => $baseDir . '/lib/public/Files/Storage/ILockingStorage.php',
231232
'OCP\\Files\\Storage\\INotifyStorage' => $baseDir . '/lib/public/Files/Storage/INotifyStorage.php',
232233
'OCP\\Files\\Storage\\IStorage' => $baseDir . '/lib/public/Files/Storage/IStorage.php',

lib/composer/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
257257
'OCP\\Files\\StorageInvalidException' => __DIR__ . '/../../..' . '/lib/public/Files/StorageInvalidException.php',
258258
'OCP\\Files\\StorageNotAvailableException' => __DIR__ . '/../../..' . '/lib/public/Files/StorageNotAvailableException.php',
259259
'OCP\\Files\\StorageTimeoutException' => __DIR__ . '/../../..' . '/lib/public/Files/StorageTimeoutException.php',
260+
'OCP\\Files\\Storage\\IDisableEncryptionStorage' => __DIR__ . '/../../..' . '/lib/public/Files/Storage/IDisableEncryptionStorage.php',
260261
'OCP\\Files\\Storage\\ILockingStorage' => __DIR__ . '/../../..' . '/lib/public/Files/Storage/ILockingStorage.php',
261262
'OCP\\Files\\Storage\\INotifyStorage' => __DIR__ . '/../../..' . '/lib/public/Files/Storage/INotifyStorage.php',
262263
'OCP\\Files\\Storage\\IStorage' => __DIR__ . '/../../..' . '/lib/public/Files/Storage/IStorage.php',

lib/private/Encryption/EncryptionWrapper.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,7 @@ public function wrapStorage($mountPoint, Storage $storage, IMountPoint $mount) {
8282
'mount' => $mount
8383
];
8484

85-
if (!$storage->instanceOfStorage('OCA\Files_Sharing\SharedStorage')
86-
&& !$storage->instanceOfStorage('OCA\Files_Sharing\External\Storage')
87-
&& !$storage->instanceOfStorage('OC\Files\Storage\OwnCloud')) {
85+
if (!$storage->instanceOfStorage(Storage\IDisableEncryptionStorage::class)) {
8886

8987
$user = \OC::$server->getUserSession()->getUser();
9088
$mountManager = Filesystem::getMountManager();
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
/**
3+
* @copyright Copyright (c) 2018 Robin Appelman <[email protected]>
4+
*
5+
* @license GNU AGPL version 3 or any later version
6+
*
7+
* This program is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU Affero General Public License as
9+
* published by the Free Software Foundation, either version 3 of the
10+
* License, or (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU Affero General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Affero General Public License
18+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
*
20+
*/
21+
22+
namespace OCP\Files\Storage;
23+
24+
/**
25+
* Marks that a storage does not support server side encryption
26+
*
27+
* @since 16.0.0
28+
*/
29+
interface IDisableEncryptionStorage {
30+
31+
}

tests/lib/Encryption/EncryptionWrapperTest.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,7 @@ public function provideWrapStorage() {
9292
[true, ['OCA\Files_Trashbin\Storage']],
9393

9494
// Do not wrap shared storages
95-
[false, ['OCA\Files_Sharing\SharedStorage']],
96-
[false, ['OCA\Files_Sharing\External\Storage']],
97-
[false, ['OC\Files\Storage\OwnCloud']],
98-
[false, ['OCA\Files_Sharing\SharedStorage', 'OCA\Files_Sharing\External\Storage']],
99-
[false, ['OCA\Files_Sharing\SharedStorage', 'OC\Files\Storage\OwnCloud']],
100-
[false, ['OCA\Files_Sharing\External\Storage', 'OC\Files\Storage\OwnCloud']],
101-
[false, ['OCA\Files_Sharing\SharedStorage', 'OCA\Files_Sharing\External\Storage', 'OC\Files\Storage\OwnCloud']],
95+
[false, [Storage\IDisableEncryptionStorage::class]],
10296
];
10397
}
10498

0 commit comments

Comments
 (0)