diff options
Diffstat (limited to 'lib/private/Share/Helper.php')
-rw-r--r-- | lib/private/Share/Helper.php | 48 |
1 files changed, 19 insertions, 29 deletions
diff --git a/lib/private/Share/Helper.php b/lib/private/Share/Helper.php index 8f2cfa4e197..d53f9d6ed94 100644 --- a/lib/private/Share/Helper.php +++ b/lib/private/Share/Helper.php @@ -1,32 +1,13 @@ <?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; class Helper extends \OC\Share\Constants { - /** * get default expire settings defined by the admin * @return array contains 'defaultExpireDateSet', 'enforceExpireDate', 'expireAfterDays' @@ -128,14 +109,14 @@ class Helper extends \OC\Share\Constants { if (rtrim($normalizedServer1, '/') === rtrim($normalizedServer2, '/')) { // FIXME this should be a method in the user management instead \OCP\Util::emitHook( - '\OCA\Files_Sharing\API\Server2Server', - 'preLoginNameUsedAsUserName', - ['uid' => &$user1] + '\OCA\Files_Sharing\API\Server2Server', + 'preLoginNameUsedAsUserName', + ['uid' => &$user1] ); \OCP\Util::emitHook( - '\OCA\Files_Sharing\API\Server2Server', - 'preLoginNameUsedAsUserName', - ['uid' => &$user2] + '\OCA\Files_Sharing\API\Server2Server', + 'preLoginNameUsedAsUserName', + ['uid' => &$user2] ); if ($user1 === $user2) { @@ -145,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)); + } } |