Skip to content

Commit

Permalink
disable encryption by default
Browse files Browse the repository at this point in the history
Signed-off-by: Robin Appelman <robin@icewind.nl>
  • Loading branch information
icewind1991 committed Aug 25, 2022
1 parent ce47e8c commit 2df8760
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 29 deletions.
4 changes: 3 additions & 1 deletion lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public function register(IRegistrationContext $context): void {
};
$config = $c->get(IConfig::class);
$allowRootShare = $config->getAppValue('groupfolders', 'allow_root_share', 'true') === 'true';
$enableEncryption = $config->getAppValue('groupfolders', 'enable_encryption', 'false') === 'true';

return new MountProvider(
$c->getServer()->getGroupManager(),
Expand All @@ -90,7 +91,8 @@ public function register(IRegistrationContext $context): void {
$c->get(IMountProviderCollection::class),
$c->get(IDBConnection::class),
$c->get(ICacheFactory::class)->createLocal("groupfolders"),
$allowRootShare
$allowRootShare,
$enableEncryption
);
});

Expand Down
29 changes: 29 additions & 0 deletions lib/Mount/GroupFolderNoEncryptionStorage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);
/**
* @copyright Copyright (c) 2022 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 OCA\GroupFolders\Mount;

use OCP\Files\Storage\IDisableEncryptionStorage;

class GroupFolderNoEncryptionStorage extends GroupFolderStorage implements IDisableEncryptionStorage {
}
32 changes: 23 additions & 9 deletions lib/Mount/MountProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class MountProvider implements IMountProvider {
private ICache $cache;
private ?int $rootStorageId = null;
private bool $allowRootShare;
private bool $enableEncryption;

public function __construct(
IGroupManager $groupProvider,
Expand All @@ -83,7 +84,8 @@ public function __construct(
IMountProviderCollection $mountProviderCollection,
IDBConnection $connection,
ICache $cache,
bool $allowRootShare
bool $allowRootShare,
bool $enableEncryption
) {
$this->groupProvider = $groupProvider;
$this->folderManager = $folderManager;
Expand All @@ -96,6 +98,7 @@ public function __construct(
$this->connection = $connection;
$this->cache = $cache;
$this->allowRootShare = $allowRootShare;
$this->enableEncryption = $enableEncryption;
}

private function getRootStorageId(): int {
Expand Down Expand Up @@ -208,14 +211,25 @@ public function getMount(int $id, string $mountPoint, int $permissions, int $quo
'storage' => $storage,
'root' => $rootPath
]);
$quotaStorage = new GroupFolderStorage([
'storage' => $baseStorage,
'quota' => $quota,
'folder_id' => $id,
'rootCacheEntry' => $cacheEntry,
'userSession' => $this->userSession,
'mountOwner' => $user,
]);
if ($this->enableEncryption) {
$quotaStorage = new GroupFolderStorage([
'storage' => $baseStorage,
'quota' => $quota,
'folder_id' => $id,
'rootCacheEntry' => $cacheEntry,
'userSession' => $this->userSession,
'mountOwner' => $user,
]);
} else {
$quotaStorage = new GroupFolderNoEncryptionStorage([
'storage' => $baseStorage,
'quota' => $quota,
'folder_id' => $id,
'rootCacheEntry' => $cacheEntry,
'userSession' => $this->userSession,
'mountOwner' => $user,
]);
}
$maskedStore = new PermissionsMask([
'storage' => $quotaStorage,
'mask' => $permissions
Expand Down
42 changes: 23 additions & 19 deletions tests/stub.phpstub
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ namespace OCA\Files_Trashbin\Trash {

interface ITrashItem extends FileInfo {
public function getTrashBackend(): ITrashBackend;

public function getOriginalLocation(): string;

public function getDeletedTime(): int;

public function getTrashPath(): string;

public function isRootItem(): bool;

public function getUser(): IUser;

public function getTitle(): string;
Expand Down Expand Up @@ -603,10 +603,10 @@ namespace OC\Files\Mount {
protected $class;
protected $storageId;
protected $rootId = null;

/** @var int|null */
protected $mountId;

/**
* @param string|\OCP\Files\Storage\IStorage $storage
* @param string $mountpoint
Expand All @@ -619,7 +619,7 @@ namespace OC\Files\Mount {
public function __construct($storage, $mountpoint, $arguments = null, $loader = null, $mountOptions = null, $mountId = null) {
throw new \Exception('stub');
}

/**
* get complete path to the mount point, relative to data/
*
Expand All @@ -628,7 +628,7 @@ namespace OC\Files\Mount {
public function getMountPoint() {
throw new \Exception('stub');
}

/**
* Sets the mount point path, relative to data/
*
Expand All @@ -637,43 +637,43 @@ namespace OC\Files\Mount {
public function setMountPoint($mountPoint) {
throw new \Exception('stub');
}

/**
* @return \OCP\Files\Storage\IStorage
*/
public function getStorage() {
throw new \Exception('stub');
}

/**
* @return string
*/
public function getStorageId() {
throw new \Exception('stub');
}

/**
* @return int
*/
public function getNumericStorageId() {
throw new \Exception('stub');
}

/**
* @param string $path
* @return string
*/
public function getInternalPath($path) {
throw new \Exception('stub');
}

/**
* @param callable $wrapper
*/
public function wrapStorage($wrapper) {
throw new \Exception('stub');
}

/**
* Get a mount option
*
Expand All @@ -684,7 +684,7 @@ namespace OC\Files\Mount {
public function getOption($name, $default) {
throw new \Exception('stub');
}

/**
* Get all options for the mount
*
Expand All @@ -693,18 +693,18 @@ namespace OC\Files\Mount {
public function getOptions() {
throw new \Exception('stub');
}

/**
* @return int
*/
public function getStorageRootId() {
throw new \Exception('stub');
}

public function getMountId() {
throw new \Exception('stub');
}

public function getMountType() {
throw new \Exception('stub');
}
Expand Down Expand Up @@ -915,3 +915,7 @@ namespace OC\Files\Storage\Wrapper{
public function getQuota() {}
}
}

namespace OCP\Files\Mount {
interface ISystemMountPoint {}
}

0 comments on commit 2df8760

Please sign in to comment.