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 <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2018-11-27 16:54:00 +01:00
parent 9f64149a38
commit 2c1f6331a4
No known key found for this signature in database
GPG Key ID: 42B69D8A64526EFB
5 changed files with 38 additions and 6 deletions

View File

@ -25,6 +25,7 @@
*/ */
namespace OCA\Files_External\Lib\Storage; namespace OCA\Files_External\Lib\Storage;
use OCP\Files\Storage\IDisableEncryptionStorage;
use Sabre\DAV\Client; use Sabre\DAV\Client;
/** /**
@ -34,7 +35,7 @@ use Sabre\DAV\Client;
* http://%host/%context/remote.php/webdav/%root * 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'; const OC_URL_SUFFIX = 'remote.php/webdav';
public function __construct($params) { public function __construct($params) {

View File

@ -39,10 +39,11 @@ use OCP\AppFramework\Http;
use OCP\Constants; use OCP\Constants;
use OCP\Federation\ICloudId; use OCP\Federation\ICloudId;
use OCP\Files\NotFoundException; use OCP\Files\NotFoundException;
use OCP\Files\Storage\IDisableEncryptionStorage;
use OCP\Files\StorageInvalidException; use OCP\Files\StorageInvalidException;
use OCP\Files\StorageNotAvailableException; use OCP\Files\StorageNotAvailableException;
class Storage extends DAV implements ISharedStorage { class Storage extends DAV implements ISharedStorage, IDisableEncryptionStorage {
/** @var ICloudId */ /** @var ICloudId */
private $cloudId; private $cloudId;
/** @var string */ /** @var string */

View File

@ -39,6 +39,7 @@ use OC\Files\Storage\FailedStorage;
use OCP\Constants; use OCP\Constants;
use OCP\Files\Cache\ICacheEntry; use OCP\Files\Cache\ICacheEntry;
use OCP\Files\NotFoundException; use OCP\Files\NotFoundException;
use OCP\Files\Storage\IDisableEncryptionStorage;
use OCP\Files\Storage\IStorage; use OCP\Files\Storage\IStorage;
use OCP\Lock\ILockingProvider; use OCP\Lock\ILockingProvider;
use OC\User\NoUserException; use OC\User\NoUserException;
@ -46,7 +47,7 @@ use OC\User\NoUserException;
/** /**
* Convert target path to source path and pass the function call to the correct storage provider * 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 */ /** @var \OCP\Share\IShare */
private $superShare; private $superShare;

View File

@ -82,9 +82,7 @@ class EncryptionWrapper {
'mount' => $mount 'mount' => $mount
]; ];
if (!$storage->instanceOfStorage('OCA\Files_Sharing\SharedStorage') if (!$storage->instanceOfStorage(Storage\IDisableEncryptionStorage::class)) {
&& !$storage->instanceOfStorage('OCA\Files_Sharing\External\Storage')
&& !$storage->instanceOfStorage('OC\Files\Storage\OwnCloud')) {
$user = \OC::$server->getUserSession()->getUser(); $user = \OC::$server->getUserSession()->getUser();
$mountManager = Filesystem::getMountManager(); $mountManager = Filesystem::getMountManager();

View File

@ -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 16.0.0
*/
interface IDisableEncryptionStorage {
}