From e4abb9cb6e6b87dcd5c248aefee393c952d257f5 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Mon, 19 Dec 2016 11:42:57 +0100 Subject: [PATCH] migrate 'password::sessioncredentials' extern storage auth to credential store Signed-off-by: Christoph Wurst --- .../Lib/Auth/Password/SessionCredentials.php | 56 ++++++++----------- 1 file changed, 24 insertions(+), 32 deletions(-) diff --git a/apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php b/apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php index 2fa939764d7..196be05e528 100644 --- a/apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php +++ b/apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php @@ -1,4 +1,5 @@ session = $session; $this->crypto = $crypto; + $this->credentialsStore = $credentialsStore; - $this - ->setIdentifier('password::sessioncredentials') + $this->setIdentifier('password::sessioncredentials') ->setScheme(self::SCHEME_PASSWORD) ->setText($l->t('Log-in credentials, save in session')) - ->addParameters([ - ]) - ; - - \OCP\Util::connectHook('OC_User', 'post_login', $this, 'authenticate'); - } - - /** - * Hook listener on post login - * - * @param array $params - */ - public function authenticate(array $params) { - $this->session->set('password::sessioncredentials/credentials', $this->crypto->encrypt(json_encode($params))); + ->addParameters([]); } public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) { - $encrypted = $this->session->get('password::sessioncredentials/credentials'); - if (!isset($encrypted)) { + try { + $credentials = $this->credentialsStore->getLoginCredentials(); + } catch (CredentialsUnavailableException $e) { throw new InsufficientDataForMeaningfulAnswerException('No session credentials saved'); } - $credentials = json_decode($this->crypto->decrypt($encrypted), true); - $storage->setBackendOption('user', $this->session->get('loginname')); - $storage->setBackendOption('password', $credentials['password']); + $storage->setBackendOption('user', $credentials->getLoginName()); + $storage->setBackendOption('password', $credentials->getPassword()); } public function wrapStorage(Storage $storage) {