Use base62 and remove configuration options for link length

This commit is contained in:
kondou 2014-09-04 16:20:20 +02:00
parent c2d8eabd71
commit 226b203e20
2 changed files with 2 additions and 21 deletions

View File

@ -201,20 +201,6 @@ $CONFIG = array(
/* Whether ownCloud should log the last successfull cron exec */ /* Whether ownCloud should log the last successfull cron exec */
"cron_log" => true, "cron_log" => true,
/*
* Length of sharing tokens and the resulting links.
* This value defines how many possible sharing links there are, choosing a low value like 3 will make it easy to guess
* sharing links and will also limit the maximum number of shares. Behaviour after all tokens are used is undefined and
* may result in breakage. The minimum value is 3, the maximum value is 64. Default is 13. Some example values:
* Length of 3 (This value is not recommended). Maximum of 46656 tokens. Links may look like this: example.com/s/1ek
* Length of 8. Maximum of 2.8*10^12 tokens. Links may look like this: example.com/s/1z1a41z3
* Length of 13 (Default). Maximum of 1.7*10^20 tokens. Links may look like this: example.com/s/3w5e11264sgsf
* Length of 25 (Near old default). Maximum of 8*10^38 tokens. Links may look like this: example.com/s/f5lxx1zz5pnorynqglhzmsp33
* Length of 40. Maximum of 1.8*10^62 tokens. Links may look like this: example.com/s/8rnpuh6h4mnepp1hrnlicj80yxhyw8lq49gtid4n
* Length of 64. Maximum of 4*10^99 tokens. Links may look like this: example.com/s/i5yli3xmet7crsf2frc1o12ygsb824im9dmyikg45fvo3vym9tswzr0r4wmtgx7i
*/
"sharing_token_length" => 13,
/* /*
* Configure the size in bytes log rotation should happen, 0 or false disables the rotation. * Configure the size in bytes log rotation should happen, 0 or false disables the rotation.
* This rotates the current owncloud logfile to a new name, this way the total log usage * This rotates the current owncloud logfile to a new name, this way the total log usage

View File

@ -640,14 +640,9 @@ class Share extends \OC\Share\Constants {
if (isset($oldToken)) { if (isset($oldToken)) {
$token = $oldToken; $token = $oldToken;
} else { } else {
$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()->getMediumStrengthGenerator()->generate($tokenLength, $token = \OC::$server->getSecureRandom()->getMediumStrengthGenerator()->generate($tokenLength,
\OCP\Security\ISecureRandom::CHAR_LOWER.\OCP\Security\ISecureRandom::CHAR_DIGITS \OCP\Security\ISecureRandom::CHAR_LOWER.\OCP\Security\ISecureRandom::CHAR_UPPER.
\OCP\Security\ISecureRandom::CHAR_DIGITS
); );
} }
$result = self::put($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $permissions, $result = self::put($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $permissions,