From 3dc6f0671a6b085dd902d2f1c637d18e410f144a Mon Sep 17 00:00:00 2001 From: Tobias Assmann Date: Fri, 9 Jul 2021 09:35:12 +0200 Subject: [PATCH 1/2] 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 9d90f09b29626..d158545d22ceb 100644 --- a/lib/private/Authentication/Listeners/UserLoggedInListener.php +++ b/lib/private/Authentication/Listeners/UserLoggedInListener.php @@ -48,6 +48,11 @@ public function handle(Event $event): void { 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 a6498ca99232e..c5e7c0601b4b2 100644 --- a/lib/private/Authentication/Token/PublicKeyTokenProvider.php +++ b/lib/private/Authentication/Token/PublicKeyTokenProvider.php @@ -419,6 +419,11 @@ public function updatePasswords(string $uid, string $password) { return; } + // 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) { From b52ebf5224ce3dcecfb605b68c88c73eed075a55 Mon Sep 17 00:00:00 2001 From: Tobias Assmann Date: Fri, 16 Jul 2021 13:33:29 +0200 Subject: [PATCH 2/2] add spaces around operators Signed-off-by: Tobias Assmann --- lib/private/Authentication/Listeners/UserLoggedInListener.php | 2 +- lib/private/Authentication/Token/PublicKeyTokenProvider.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/private/Authentication/Listeners/UserLoggedInListener.php b/lib/private/Authentication/Listeners/UserLoggedInListener.php index d158545d22ceb..faf2edd54f7ec 100644 --- a/lib/private/Authentication/Listeners/UserLoggedInListener.php +++ b/lib/private/Authentication/Listeners/UserLoggedInListener.php @@ -49,7 +49,7 @@ public function handle(Event $event): void { } // prevent setting an empty pw as result of pw-less-login - if ($event->getPassword()==='') { + if ($event->getPassword() === '') { return; } diff --git a/lib/private/Authentication/Token/PublicKeyTokenProvider.php b/lib/private/Authentication/Token/PublicKeyTokenProvider.php index c5e7c0601b4b2..81dc3164ec141 100644 --- a/lib/private/Authentication/Token/PublicKeyTokenProvider.php +++ b/lib/private/Authentication/Token/PublicKeyTokenProvider.php @@ -420,7 +420,7 @@ public function updatePasswords(string $uid, string $password) { } // prevent setting an empty pw as result of pw-less-login - if ($password==='') { + if ($password === '') { return; }