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 f3d60be
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 10 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

0 comments on commit f3d60be

Please sign in to comment.