]> source.dussan.org Git - nextcloud-server.git/commitdiff
check the username when doing external storage session auth 38286/head
authorRobin Appelman <robin@icewind.nl>
Thu, 11 May 2023 15:45:16 +0000 (17:45 +0200)
committerRobin Appelman <robin@icewind.nl>
Mon, 15 May 2023 15:08:14 +0000 (17:08 +0200)
Signed-off-by: Robin Appelman <robin@icewind.nl>
apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php

index d6f2d3f844fa20a61fecfcd826d167683e8bafde..960971694a3a333537d0dabfbdbc02c30bb3fd20 100644 (file)
@@ -31,6 +31,7 @@ use OCA\Files_External\Lib\StorageConfig;
 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;
 
@@ -58,6 +59,10 @@ class SessionCredentials extends AuthMechanism {
                        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());
        }