Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
feat(preset): add lexicon entry for custom share token
Signed-off-by: Maxence Lange <[email protected]>
  • Loading branch information
ArtificialOwl committed Jul 29, 2025
commit 3ceffe9f5beb23f7049203e08efdf8fa8ecd1b35
13 changes: 13 additions & 0 deletions core/AppInfo/ConfigLexicon.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

use OCP\Config\Lexicon\Entry;
use OCP\Config\Lexicon\ILexicon;
use OCP\Config\Lexicon\Preset;
use OCP\Config\Lexicon\Strictness;
use OCP\Config\ValueType;

Expand All @@ -20,6 +21,7 @@
*/
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;
Expand All @@ -34,6 +36,17 @@ public function getAppConfigs(): array {
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.',
),
];
}

Expand Down
3 changes: 2 additions & 1 deletion lib/private/Share20/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1939,7 +1940,7 @@ public function ignoreSecondDisplayName(): bool {
}

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 {
Expand Down
Loading