]> source.dussan.org Git - nextcloud-server.git/commitdiff
Adapt token size to new generation and add an option for free length specification
authorkondou <kondou@ts.unde.re>
Thu, 4 Sep 2014 13:13:30 +0000 (15:13 +0200)
committerkondou <kondou@ts.unde.re>
Thu, 4 Sep 2014 13:24:33 +0000 (15:24 +0200)
Minimum size is 3 = 46656 tokens, maximum size is 64, which is what our DB allows.

lib/private/share/share.php

index dfe0f65340b389b62ea4dc72b649e2d8270cb2b8..5bebd16a9b4d12cac1c4409e5da33704407681f0 100644 (file)
@@ -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