feat(preset): add lexicon entry for custom share token

Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
pull/54064/head
Maxence Lange 5 months ago
parent 9380375cc6
commit 3ceffe9f5b
  1. 13
      core/AppInfo/ConfigLexicon.php
  2. 3
      lib/private/Share20/Manager.php

@ -10,6 +10,7 @@ namespace OC\Core\AppInfo;
use OCP\Config\Lexicon\Entry;
use OCP\Config\Lexicon\ILexicon;
use OCP\Config\Lexicon\Preset;
use OCP\Config\Lexicon\Strictness;
use OCP\Config\ValueType;
@ -20,6 +21,7 @@ use OCP\Config\ValueType;
*/
class ConfigLexicon implements ILexicon {
public const SHAREAPI_ALLOW_FEDERATION_ON_PUBLIC_SHARES = 'shareapi_allow_federation_on_public_shares';
public const SHARE_CUSTOM_TOKEN = 'shareapi_allow_custom_tokens';
public function getStrictness(): Strictness {
return Strictness::IGNORE;
@ -34,6 +36,17 @@ class ConfigLexicon implements ILexicon {
definition: 'adds share permission to public shares to allow adding them to your Nextcloud (federation)',
lazy: true,
),
new Entry(
key: self::SHARE_CUSTOM_TOKEN,
type: ValueType::BOOL,
defaultRaw: fn (Preset $p): bool => match ($p) {
Preset::FAMILY, Preset::PRIVATE => true,
default => false,
},
definition: 'Allow users to set custom share link tokens',
lazy: true,
note: 'Shares with guessable tokens may be accessed easily. Shares with custom tokens will continue to be accessible after this setting has been disabled.',
),
];
}

@ -7,6 +7,7 @@
*/
namespace OC\Share20;
use OC\Core\AppInfo\ConfigLexicon;
use OC\Files\Mount\MoveableMount;
use OC\KnownUser\KnownUserService;
use OC\Share20\Exception\ProviderException;
@ -1939,7 +1940,7 @@ class Manager implements IManager {
}
public function allowCustomTokens(): bool {
return $this->appConfig->getValueBool('core', 'shareapi_allow_custom_tokens', false);
return $this->appConfig->getValueBool('core', ConfigLexicon::SHARE_CUSTOM_TOKEN);
}
public function allowViewWithoutDownload(): bool {

Loading…
Cancel
Save