]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix: Use hashed password in files_external settings artonge/feat/compare_hashed_password_when_updating_global_cred_in_files_external 48359/head
authorLouis Chemineau <louis@chmn.me>
Tue, 24 Sep 2024 14:20:04 +0000 (16:20 +0200)
committerLouis Chemineau <louis@chmn.me>
Wed, 25 Sep 2024 15:50:17 +0000 (17:50 +0200)
Signed-off-by: Louis Chemineau <louis@chmn.me>
apps/files_external/lib/Lib/Auth/Password/GlobalAuth.php

index ca1c9ca2beeef120c504eb41118ebba5781c64c7..f11dab2785f3b9f912c9e1d8c0bcc7f0ed3ff5c1 100644 (file)
@@ -19,6 +19,7 @@ use OCP\Security\ICredentialsManager;
  */
 class GlobalAuth extends AuthMechanism {
        public const CREDENTIALS_IDENTIFIER = 'password::global';
+       private const PWD_PLACEHOLDER = '************************';
 
        /** @var ICredentialsManager */
        protected $credentialsManager;
@@ -41,11 +42,18 @@ class GlobalAuth extends AuthMechanism {
                                'password' => ''
                        ];
                } else {
+                       $auth['password'] = self::PWD_PLACEHOLDER;
                        return $auth;
                }
        }
 
        public function saveAuth($uid, $user, $password) {
+               // Use old password if it has not changed.
+               if ($password === self::PWD_PLACEHOLDER) {
+                       $auth = $this->credentialsManager->retrieve($uid, self::CREDENTIALS_IDENTIFIER);
+                       $password = $auth['password'];
+               }
+
                $this->credentialsManager->store($uid, self::CREDENTIALS_IDENTIFIER, [
                        'user' => $user,
                        'password' => $password