]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix: Use hashed password in files_external settings backport/48359/stable29 48387/head
authorLouis Chemineau <louis@chmn.me>
Tue, 24 Sep 2024 14:20:04 +0000 (16:20 +0200)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Thu, 26 Sep 2024 13:03:28 +0000 (13:03 +0000)
Signed-off-by: Louis Chemineau <louis@chmn.me>
apps/files_external/lib/Lib/Auth/Password/GlobalAuth.php

index 174efd96e3c293d9539826cc3a003b4fc2402b4d..278eab55cedb9b71f99a7016c070fe2fb9980628 100644 (file)
@@ -37,6 +37,7 @@ use OCP\Security\ICredentialsManager;
  */
 class GlobalAuth extends AuthMechanism {
        public const CREDENTIALS_IDENTIFIER = 'password::global';
+       private const PWD_PLACEHOLDER = '************************';
 
        /** @var ICredentialsManager */
        protected $credentialsManager;
@@ -59,11 +60,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