aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorkondou <kondou@ts.unde.re>2014-09-04 15:13:30 +0200
committerkondou <kondou@ts.unde.re>2014-09-04 15:24:33 +0200
commit3bf725d7e03e8995a9f54396a5ab817468718d30 (patch)
tree657ba17b070c41efb17c6a9e72d560669f69ffb4 /lib
parent2a4c51389c23ab1da47d52be9f2e76cd90f2df01 (diff)
downloadnextcloud-server-3bf725d7e03e8995a9f54396a5ab817468718d30.tar.gz
nextcloud-server-3bf725d7e03e8995a9f54396a5ab817468718d30.zip
Adapt token size to new generation and add an option for free length specification
Minimum size is 3 = 46656 tokens, maximum size is 64, which is what our DB allows.
Diffstat (limited to 'lib')
-rw-r--r--lib/private/share/share.php21
1 files changed, 5 insertions, 16 deletions
diff --git a/lib/private/share/share.php b/lib/private/share/share.php
index dfe0f65340b..5bebd16a9b4 100644
--- a/lib/private/share/share.php
+++ b/lib/private/share/share.php
@@ -640,22 +640,11 @@ class Share extends \OC\Share\Constants {
if (isset($oldToken)) {
$token = $oldToken;
} else {
- // 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;
+ $tokenLength = \OC_Config::getValue("sharing_token_length", 13);
+
+ // Enforce a limit on token length
+ if ($tokenLength < 3 || $tokenLength > 64) {
+ $tokenLength = 13;
}
$token = \OC::$server->getSecureRandom()->getLowStrengthGenerator()->generate($tokenLength,
\OCP\Security\ISecureRandom::CHAR_LOWER.\OCP\Security\ISecureRandom::CHAR_DIGITS