Skip to content

Commit

Permalink
Merge pull request #48359 from nextcloud/artonge/feat/compare_hashed_…
Browse files Browse the repository at this point in the history
…password_when_updating_global_cred_in_files_external

fix: Use placeholder for external storage password
  • Loading branch information
artonge committed Sep 26, 2024
2 parents 0a568e5 + 20eb464 commit c45ed55
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions apps/files_external/lib/Lib/Auth/Password/GlobalAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/
class GlobalAuth extends AuthMechanism {
public const CREDENTIALS_IDENTIFIER = 'password::global';
private const PWD_PLACEHOLDER = '************************';

/** @var ICredentialsManager */
protected $credentialsManager;
Expand All @@ -41,11 +42,18 @@ public function getAuth($uid) {
'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
Expand Down

0 comments on commit c45ed55

Please sign in to comment.