aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Authentication
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2023-01-09 15:58:26 +0100
committerJoas Schilling <coding@schilljs.com>2023-01-09 15:58:26 +0100
commit28b18d561cea2f77ca6cc70c4052001e41b57620 (patch)
tree6ae36b17844b0c631700e0ea8b723a37ee1461ca /lib/private/Authentication
parentc5bb19641c12757e2b11376ee431d2a941e98e3f (diff)
downloadnextcloud-server-28b18d561cea2f77ca6cc70c4052001e41b57620.tar.gz
nextcloud-server-28b18d561cea2f77ca6cc70c4052001e41b57620.zip
fix(authentication): Only hash the new password when needed
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/Authentication')
-rw-r--r--lib/private/Authentication/Token/PublicKeyTokenProvider.php8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/private/Authentication/Token/PublicKeyTokenProvider.php b/lib/private/Authentication/Token/PublicKeyTokenProvider.php
index adac86dd073..6cf6b8f858c 100644
--- a/lib/private/Authentication/Token/PublicKeyTokenProvider.php
+++ b/lib/private/Authentication/Token/PublicKeyTokenProvider.php
@@ -447,13 +447,17 @@ class PublicKeyTokenProvider implements IProvider {
// Update the password for all tokens
$tokens = $this->mapper->getTokenByUser($uid);
- $passwordHash = $this->hashPassword($password);
+ $newPasswordHash = null;
$verifiedHashes = [];
foreach ($tokens as $t) {
if ($t->getPasswordHash() === null || !isset($verifiedHashes[$t->getPasswordHash()]) || !$this->hasher->verify(sha1($password) . $password, $t->getPasswordHash())) {
+ if ($newPasswordHash === null) {
+ $newPasswordHash = $this->hashPassword($password);
+ }
+
$publicKey = $t->getPublicKey();
$t->setPassword($this->encryptPassword($password, $publicKey));
- $t->setPasswordHash($passwordHash);
+ $t->setPasswordHash($newPasswordHash);
$t->setPasswordInvalid(false);
$this->updateToken($t);
} else {