Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[15] Add interface to allow storages from opting out of encryption #12692

Merged
merged 3 commits into from
Nov 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/files_external/lib/Lib/Storage/OwnCloud.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/

namespace OCA\Files_External\Lib\Storage;
use OCP\Files\Storage\IDisableEncryptionStorage;
use Sabre\DAV\Client;

/**
Expand All @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion apps/files_sharing/lib/External/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
3 changes: 2 additions & 1 deletion apps/files_sharing/lib/SharedStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@
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;

/**
* 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;
Expand Down
1 change: 1 addition & 0 deletions lib/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions lib/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 1 addition & 3 deletions lib/private/Encryption/EncryptionWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
31 changes: 31 additions & 0 deletions lib/public/Files/Storage/IDisableEncryptionStorage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/**
* @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl>
*
* @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 <http://www.gnu.org/licenses/>.
*
*/

namespace OCP\Files\Storage;

/**
* Marks that a storage does not support server side encryption
*
* @since 15.0.0
*/
interface IDisableEncryptionStorage {

}
8 changes: 1 addition & 7 deletions tests/lib/Encryption/EncryptionWrapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]],
];
}

Expand Down