feat(sharing): Add shareapi_allow_custom_tokens config

Signed-off-by: Christopher Ng <chrng8@gmail.com>
This commit is contained in:
Christopher Ng 2024-12-16 15:53:12 -08:00
parent cdc65b6985
commit 8b26383d00
2 changed files with 14 additions and 0 deletions

View file

@ -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;

View file

@ -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
*