summaryrefslogtreecommitdiffstats
path: root/apps/twofactor_backupcodes/lib
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2017-01-16 11:24:03 +0100
committerChristoph Wurst <christoph@winzerhof-wurst.at>2017-01-16 11:24:03 +0100
commit3b76699c9c49f50268cc42ad7f0b5b9bba577663 (patch)
tree3b6fe72372995f268b4237a674f24cfb108b8f8f /apps/twofactor_backupcodes/lib
parent203436b16be40109131720f06ca39e393c373bae (diff)
downloadnextcloud-server-3b76699c9c49f50268cc42ad7f0b5b9bba577663.tar.gz
nextcloud-server-3b76699c9c49f50268cc42ad7f0b5b9bba577663.zip
Increase 2fa backup codes entropy
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'apps/twofactor_backupcodes/lib')
-rw-r--r--apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php11
1 files changed, 10 insertions, 1 deletions
diff --git a/apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php b/apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php
index ecb16305e92..487112c7c17 100644
--- a/apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php
+++ b/apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php
@@ -33,6 +33,8 @@ use OCP\Security\ISecureRandom;
class BackupCodeStorage {
+ private static $CODE_LENGTH = 16;
+
/** @var BackupCodeMapper */
private $mapper;
@@ -48,6 +50,13 @@ class BackupCodeStorage {
/** @var ILogger */
private $logger;
+ /**
+ * @param BackupCodeMapper $mapper
+ * @param ISecureRandom $random
+ * @param IHasher $hasher
+ * @param IManager $activityManager
+ * @param ILogger $logger
+ */
public function __construct(BackupCodeMapper $mapper, ISecureRandom $random, IHasher $hasher,
IManager $activityManager, ILogger $logger) {
$this->mapper = $mapper;
@@ -69,7 +78,7 @@ class BackupCodeStorage {
$uid = $user->getUID();
foreach (range(1, min([$number, 20])) as $i) {
- $code = $this->random->generate(10, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789');
+ $code = $this->random->generate(self::$CODE_LENGTH, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789');
$dbCode = new BackupCode();
$dbCode->setUserId($uid);