summaryrefslogtreecommitdiffstats
path: root/lib/private/share/share.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/share/share.php')
-rw-r--r--lib/private/share/share.php21
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/private/share/share.php b/lib/private/share/share.php
index e2e9b94125e..dfe0f65340b 100644
--- a/lib/private/share/share.php
+++ b/lib/private/share/share.php
@@ -640,7 +640,26 @@ class Share extends \OC\Share\Constants {
if (isset($oldToken)) {
$token = $oldToken;
} else {
- $token = \OC_Util::generateRandomBytes(self::TOKEN_LENGTH);
+ // Determine how long the token should be
+ switch (\OC_Config::getValue("sharing_token_length", 3)) {
+ case 1:
+ $tokenLength = 4;
+ break;
+ case 2:
+ $tokenLength = 8;
+ break;
+ // Default is 3, so skip the 3 block
+ case 4:
+ $tokenLength = 32;
+ break;
+ // Anything other than 1-4 should be default 3
+ default:
+ $tokenLength = 16;
+ break;
+ }
+ $token = \OC::$server->getSecureRandom()->getLowStrengthGenerator()->generate($tokenLength,
+ \OCP\Security\ISecureRandom::CHAR_LOWER.\OCP\Security\ISecureRandom::CHAR_DIGITS
+ );
}
$result = self::put($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $permissions,
null, $token, $itemSourceName, $expirationDate);