Skip to content

Commit 3ceffe9

Browse files
committed
feat(preset): add lexicon entry for custom share token
Signed-off-by: Maxence Lange <[email protected]>
1 parent 9380375 commit 3ceffe9

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

core/AppInfo/ConfigLexicon.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use OCP\Config\Lexicon\Entry;
1212
use OCP\Config\Lexicon\ILexicon;
13+
use OCP\Config\Lexicon\Preset;
1314
use OCP\Config\Lexicon\Strictness;
1415
use OCP\Config\ValueType;
1516

@@ -20,6 +21,7 @@
2021
*/
2122
class ConfigLexicon implements ILexicon {
2223
public const SHAREAPI_ALLOW_FEDERATION_ON_PUBLIC_SHARES = 'shareapi_allow_federation_on_public_shares';
24+
public const SHARE_CUSTOM_TOKEN = 'shareapi_allow_custom_tokens';
2325

2426
public function getStrictness(): Strictness {
2527
return Strictness::IGNORE;
@@ -34,6 +36,17 @@ public function getAppConfigs(): array {
3436
definition: 'adds share permission to public shares to allow adding them to your Nextcloud (federation)',
3537
lazy: true,
3638
),
39+
new Entry(
40+
key: self::SHARE_CUSTOM_TOKEN,
41+
type: ValueType::BOOL,
42+
defaultRaw: fn (Preset $p): bool => match ($p) {
43+
Preset::FAMILY, Preset::PRIVATE => true,
44+
default => false,
45+
},
46+
definition: 'Allow users to set custom share link tokens',
47+
lazy: true,
48+
note: 'Shares with guessable tokens may be accessed easily. Shares with custom tokens will continue to be accessible after this setting has been disabled.',
49+
),
3750
];
3851
}
3952

lib/private/Share20/Manager.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88
namespace OC\Share20;
99

10+
use OC\Core\AppInfo\ConfigLexicon;
1011
use OC\Files\Mount\MoveableMount;
1112
use OC\KnownUser\KnownUserService;
1213
use OC\Share20\Exception\ProviderException;
@@ -1939,7 +1940,7 @@ public function ignoreSecondDisplayName(): bool {
19391940
}
19401941

19411942
public function allowCustomTokens(): bool {
1942-
return $this->appConfig->getValueBool('core', 'shareapi_allow_custom_tokens', false);
1943+
return $this->appConfig->getValueBool('core', ConfigLexicon::SHARE_CUSTOM_TOKEN);
19431944
}
19441945

19451946
public function allowViewWithoutDownload(): bool {

0 commit comments

Comments
 (0)