From ce834cbb5536fc7e42e78ef44f99015ee87a137b Mon Sep 17 00:00:00 2001 From: Tobias Assmann Date: Fri, 9 Jul 2021 09:35:12 +0200 Subject: [PATCH] draft to prevent the invalidation of pw based authn tokens on a pw less login Signed-off-by: Tobias Assmann --- .../Authentication/Listeners/UserLoggedInListener.php | 5 +++++ lib/private/Authentication/Token/PublicKeyTokenProvider.php | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/lib/private/Authentication/Listeners/UserLoggedInListener.php b/lib/private/Authentication/Listeners/UserLoggedInListener.php index e33f2bc04ca..5c1b289ad44 100644 --- a/lib/private/Authentication/Listeners/UserLoggedInListener.php +++ b/lib/private/Authentication/Listeners/UserLoggedInListener.php @@ -48,6 +48,11 @@ class UserLoggedInListener implements IEventListener { return; } + // prevent setting an empty pw as result of pw-less-login + if ($event->getPassword()==='') { + return; + } + // If this is already a token login there is nothing to do if ($event->isTokenLogin()) { return; diff --git a/lib/private/Authentication/Token/PublicKeyTokenProvider.php b/lib/private/Authentication/Token/PublicKeyTokenProvider.php index ab9ff23dfd1..009acf10aae 100644 --- a/lib/private/Authentication/Token/PublicKeyTokenProvider.php +++ b/lib/private/Authentication/Token/PublicKeyTokenProvider.php @@ -413,6 +413,11 @@ class PublicKeyTokenProvider implements IProvider { public function updatePasswords(string $uid, string $password) { $this->cache->clear(); + // prevent setting an empty pw as result of pw-less-login + if ($password==='') { + return; + } + // Update the password for all tokens $tokens = $this->mapper->getTokenByUser($uid); foreach ($tokens as $t) {