aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Share/Helper.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/Share/Helper.php')
-rw-r--r--lib/private/Share/Helper.php35
1 files changed, 13 insertions, 22 deletions
diff --git a/lib/private/Share/Helper.php b/lib/private/Share/Helper.php
index f1b9ae2b9fa..d53f9d6ed94 100644
--- a/lib/private/Share/Helper.php
+++ b/lib/private/Share/Helper.php
@@ -1,27 +1,9 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Björn Schießle <bjoern@schiessle.org>
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Miguel Prokop <miguel.prokop@vtu.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OC\Share;
@@ -144,4 +126,13 @@ class Helper extends \OC\Share\Constants {
return false;
}
+
+ public static function getTokenLength(): int {
+ $config = \OCP\Server::get(\OCP\IAppConfig::class);
+ $tokenLength = $config->getValueInt('core', 'shareapi_token_length', self::DEFAULT_TOKEN_LENGTH);
+ $tokenLength = $tokenLength ?: self::DEFAULT_TOKEN_LENGTH;
+
+ // Token length should be within the defined min and max limits
+ return max(self::MIN_TOKEN_LENGTH, min($tokenLength, self::MAX_TOKEN_LENGTH));
+ }
}