summaryrefslogtreecommitdiffstats
path: root/lib/private/Authentication/Token
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2023-01-09 15:13:08 +0100
committerJoas Schilling <coding@schilljs.com>2023-01-09 15:13:08 +0100
commitc5bb19641c12757e2b11376ee431d2a941e98e3f (patch)
treec11005801883378deb4fe33797c41cf474130e00 /lib/private/Authentication/Token
parent55d8aec7597ab29031abda47da9afa15a16b0a4a (diff)
downloadnextcloud-server-c5bb19641c12757e2b11376ee431d2a941e98e3f.tar.gz
nextcloud-server-c5bb19641c12757e2b11376ee431d2a941e98e3f.zip
fix(authentication): Invert the logic to the original intention
We need to store the new authentication details when the hash did **not** verify the old password. Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/Authentication/Token')
-rw-r--r--lib/private/Authentication/Token/PublicKeyTokenProvider.php5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/private/Authentication/Token/PublicKeyTokenProvider.php b/lib/private/Authentication/Token/PublicKeyTokenProvider.php
index 651540f934a..adac86dd073 100644
--- a/lib/private/Authentication/Token/PublicKeyTokenProvider.php
+++ b/lib/private/Authentication/Token/PublicKeyTokenProvider.php
@@ -450,13 +450,14 @@ class PublicKeyTokenProvider implements IProvider {
$passwordHash = $this->hashPassword($password);
$verifiedHashes = [];
foreach ($tokens as $t) {
- if ($t->getPasswordHash() === null || isset($verifiedHashes[$t->getPasswordHash()]) || $this->hasher->verify(sha1($password) . $password, $t->getPasswordHash())) {
- $verifiedHashes[$t->getPasswordHash() ?: ''] = true;
+ if ($t->getPasswordHash() === null || !isset($verifiedHashes[$t->getPasswordHash()]) || !$this->hasher->verify(sha1($password) . $password, $t->getPasswordHash())) {
$publicKey = $t->getPublicKey();
$t->setPassword($this->encryptPassword($password, $publicKey));
$t->setPasswordHash($passwordHash);
$t->setPasswordInvalid(false);
$this->updateToken($t);
+ } else {
+ $verifiedHashes[$t->getPasswordHash() ?: ''] = true;
}
}
}