aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2025-07-23 15:22:51 -0100
committerMaxence Lange <maxence@artificial-owl.com>2025-07-25 11:40:57 -0100
commitecddfa9a26a2b8c1803cfc3151ece3d16950b80d (patch)
tree93194395f42ccecde1f945793f28baa96c54f505
parentde46e39405c4ea10eaa2cb7f46edeb6f29c8edbf (diff)
downloadnextcloud-server-feat/preset/custom-share-token.tar.gz
nextcloud-server-feat/preset/custom-share-token.zip
feat(preset): add lexicon entry for custom share tokensfeat/preset/custom-share-token
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
-rw-r--r--core/AppInfo/ConfigLexicon.php15
-rw-r--r--lib/private/Share20/Manager.php3
-rw-r--r--lib/public/Config/Lexicon/Entry.php30
-rw-r--r--lib/unstable/Config/Lexicon/ConfigLexiconEntry.php33
4 files changed, 73 insertions, 8 deletions
diff --git a/core/AppInfo/ConfigLexicon.php b/core/AppInfo/ConfigLexicon.php
index 5dad229267d..981ff6bb30f 100644
--- a/core/AppInfo/ConfigLexicon.php
+++ b/core/AppInfo/ConfigLexicon.php
@@ -20,6 +20,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 +35,20 @@ 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: [
+ 'definition' => 'Allow users to set custom share link tokens',
+ 'note' => 'Shares with custom tokens will continue to be accessible after this setting has been disabled',
+ 'warning' => 'Shares with guessable tokens may be accessed easily'
+ ],
+ lazy: true,
+ ),
];
}
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php
index 01664c6a0a3..d341826237a 100644
--- a/lib/private/Share20/Manager.php
+++ b/lib/private/Share20/Manager.php
@@ -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;
@@ -1937,7 +1938,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 {
diff --git a/lib/public/Config/Lexicon/Entry.php b/lib/public/Config/Lexicon/Entry.php
index 95dae44ed11..d7993487ef2 100644
--- a/lib/public/Config/Lexicon/Entry.php
+++ b/lib/public/Config/Lexicon/Entry.php
@@ -21,7 +21,7 @@ class Entry {
/** @since 32.0.0 */
public const RENAME_INVERT_BOOLEAN = 1;
- private string $definition = '';
+ private array|string $definition = '';
private ?string $default = null;
/**
@@ -41,7 +41,7 @@ class Entry {
private readonly string $key,
private readonly ValueType $type,
private null|string|int|float|bool|array|Closure $defaultRaw = null,
- string $definition = '',
+ string|array $definition = '',
private readonly bool $lazy = false,
private readonly int $flags = 0,
private readonly bool $deprecated = false,
@@ -183,7 +183,31 @@ class Entry {
* @since 32.0.0
*/
public function getDefinition(): string {
- return $this->definition;
+ if (is_string($this->definition)) {
+ return $this->definition;
+ }
+
+ return (string)($this->definition['definition'] ?? '');
+ }
+
+ /**
+ * returns eventual note
+ *
+ * @return string
+ * @since 32.0.0
+ */
+ public function getNote(): string {
+ return (string)($this->definition['note'] ?? '');
+ }
+
+ /**
+ * returns eventual warning
+ *
+ * @return string
+ * @since 32.0.0
+ */
+ public function getWarning(): string {
+ return (string)($this->definition['warning'] ?? '');
}
/**
diff --git a/lib/unstable/Config/Lexicon/ConfigLexiconEntry.php b/lib/unstable/Config/Lexicon/ConfigLexiconEntry.php
index 2587cd52c01..672100b05c5 100644
--- a/lib/unstable/Config/Lexicon/ConfigLexiconEntry.php
+++ b/lib/unstable/Config/Lexicon/ConfigLexiconEntry.php
@@ -28,13 +28,13 @@ class ConfigLexiconEntry {
*/
public const RENAME_INVERT_BOOLEAN = 1;
- private string $definition = '';
+ private array|string $definition = '';
private ?string $default = null;
/**
* @param string $key config key, can only contain alphanumerical chars and -._
* @param ValueType $type type of config value
- * @param string $definition optional description of config key available when using occ command
+ * @param array|string $definition optional description of config key available when using occ command
* @param bool $lazy set config value as lazy
* @param int $flags set flags
* @param string|null $rename previous config key to migrate config value from
@@ -50,7 +50,7 @@ class ConfigLexiconEntry {
private readonly string $key,
private readonly ValueType $type,
private null|string|int|float|bool|array|Closure $defaultRaw = null,
- string $definition = '',
+ string|array $definition = '',
private readonly bool $lazy = false,
private readonly int $flags = 0,
private readonly bool $deprecated = false,
@@ -218,10 +218,35 @@ class ConfigLexiconEntry {
* @see \OCP\Config\Lexicon\Entry
*/
public function getDefinition(): string {
- return $this->definition;
+ if (is_string($this->definition)) {
+ return $this->definition;
+ }
+
+ return (string)($this->definition['definition'] ?? '');
+ }
+
+ /**
+ * returns eventual note
+ *
+ * @return string
+ * @experimental 32.0.0
+ */
+ public function getNote(): string {
+ return (string)($this->definition['note'] ?? '');
}
/**
+ * returns eventual warning
+ *
+ * @return string
+ * @experimental 32.0.0
+ */
+ public function getWarning(): string {
+ return (string)($this->definition['warning'] ?? '');
+ }
+
+
+ /**
* returns if config key is set as lazy
*
* @see IAppConfig for details on lazy config values