Skip to content

Commit

Permalink
Merge pull request #38285 from nextcloud/session-auth-check-username-22
Browse files Browse the repository at this point in the history
[22] check the username when doing external storage session auth
  • Loading branch information
icewind1991 authored May 15, 2023
2 parents a50cfd6 + 9d81b0b commit 86e4f32
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use OCP\Authentication\Exceptions\CredentialsUnavailableException;
use OCP\Authentication\LoginCredentials\IStore as CredentialsStore;
use OCP\Files\Storage;
use OCP\Files\StorageAuthException;
use OCP\IL10N;
use OCP\IUser;

Expand Down Expand Up @@ -57,6 +58,10 @@ public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = n
throw new InsufficientDataForMeaningfulAnswerException('No session credentials saved');
}

if ($credentials->getUID() !== $user->getUID()) {
throw new StorageAuthException('Session credentials for storage owner not available');
}

$storage->setBackendOption('user', $credentials->getLoginName());
$storage->setBackendOption('password', $credentials->getPassword());
}
Expand Down

0 comments on commit 86e4f32

Please sign in to comment.