From 502d6c603d83d2d783655bb7b35680806532d1b4 Mon Sep 17 00:00:00 2001 From: fenn-cs Date: Mon, 22 Jan 2024 14:49:57 +0100 Subject: [PATCH] Consider admin defaults when creating shares The current share logic always uses the default `BUNDLED_PERMISSIONS.ALL` which includes everything. This commit updates share creation logic to use `defaultPermissions` if set by admin for the creation of new shares. Signed-off-by: fenn-cs --- .../lib/Listener/LoadSidebarListener.php | 1 + apps/files_sharing/src/services/ConfigService.js | 11 +++++++++++ lib/public/Share/IManager.php | 8 ++++++++ 3 files changed, 20 insertions(+) diff --git a/apps/files_sharing/lib/Listener/LoadSidebarListener.php b/apps/files_sharing/lib/Listener/LoadSidebarListener.php index b88c3ccf0d8ba..489f15705d24d 100644 --- a/apps/files_sharing/lib/Listener/LoadSidebarListener.php +++ b/apps/files_sharing/lib/Listener/LoadSidebarListener.php @@ -51,6 +51,7 @@ public function handle(Event $event): void { $shareConfig = [ 'allowPublicUploads' => $this->shareManager->shareApiLinkAllowPublicUpload(), + 'defaultPermissions' => $this->shareManager->shareApiDefaultPermissions() ]; $this->initialState->provideInitialState('shareConfig', $shareConfig); diff --git a/apps/files_sharing/src/services/ConfigService.js b/apps/files_sharing/src/services/ConfigService.js index d1d99e7be7a5c..8afa41e80e5c3 100644 --- a/apps/files_sharing/src/services/ConfigService.js +++ b/apps/files_sharing/src/services/ConfigService.js @@ -31,6 +31,17 @@ export default class Config { this._shareConfig = loadState('files_sharing', 'shareConfig', {}) } + /** + * Get default share permissions, if any + * + * @return {boolean} + * @readonly + * @memberof Config + */ + get defaultPermissions() { + return this._shareConfig.defaultPermissions + } + /** * Is public upload allowed on link shares ? * diff --git a/lib/public/Share/IManager.php b/lib/public/Share/IManager.php index 9ac224ed7ef30..dcf8788098dd3 100644 --- a/lib/public/Share/IManager.php +++ b/lib/public/Share/IManager.php @@ -310,6 +310,14 @@ public function newShare(); */ public function shareApiEnabled(); + /** + * Get default share permissions set by admin + * + * @return int + * @since 9.0.0 + */ + public function shareApidefaultPermissions(): int; + /** * Is public link sharing enabled *