From 8b26383d00e245de2b54640baf1ba89adf245298 Mon Sep 17 00:00:00 2001 From: Christopher Ng Date: Mon, 16 Dec 2024 15:53:12 -0800 Subject: [PATCH] feat(sharing): Add `shareapi_allow_custom_tokens` config Signed-off-by: Christopher Ng --- lib/private/Share20/Manager.php | 6 ++++++ lib/public/Share/IManager.php | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index 4138819f6b1..3300a5d2e67 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -21,6 +21,7 @@ use OCP\Files\Mount\IShareOwnerlessMount; use OCP\Files\Node; use OCP\Files\NotFoundException; use OCP\HintException; +use OCP\IAppConfig; use OCP\IConfig; use OCP\IDateTimeZone; use OCP\IGroupManager; @@ -79,6 +80,7 @@ class Manager implements IManager { private KnownUserService $knownUserService, private ShareDisableChecker $shareDisableChecker, private IDateTimeZone $dateTimeZone, + private IAppConfig $appConfig, ) { $this->l = $this->l10nFactory->get('lib'); // The constructor of LegacyHooks registers the listeners of share events @@ -1906,6 +1908,10 @@ class Manager implements IManager { return $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_full_match_ignore_second_dn', 'no') === 'yes'; } + public function allowCustomTokens(): bool { + return $this->appConfig->getValueBool('core', 'shareapi_allow_custom_tokens', false); + } + public function currentUserCanEnumerateTargetUser(?IUser $currentUser, IUser $targetUser): bool { if ($this->allowEnumerationFullMatch()) { return true; diff --git a/lib/public/Share/IManager.php b/lib/public/Share/IManager.php index 85b421c04f6..23713f2e462 100644 --- a/lib/public/Share/IManager.php +++ b/lib/public/Share/IManager.php @@ -464,6 +464,14 @@ interface IManager { */ public function ignoreSecondDisplayName(): bool; + + /** + * Check if custom tokens are allowed + * + * @since 31.0.0 + */ + public function allowCustomTokens(): bool; + /** * Check if the current user can enumerate the target user *