Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2016-12-19 13:42:57 +0300
committerRoeland Jago Douma <roeland@famdouma.nl>2017-01-11 21:20:11 +0300
commite4abb9cb6e6b87dcd5c248aefee393c952d257f5 (patch)
treef0732478d59c9bf604e88cb772e6c3e44a6a3d04 /apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php
parent3316a9d2940f2fe134bcf4c5fc9193861d23fc90 (diff)
migrate 'password::sessioncredentials' extern storage auth to credential store
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php')
-rw-r--r--apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php56
1 files 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 @@
<?php
+
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@@ -23,16 +24,17 @@
namespace OCA\Files_External\Lib\Auth\Password;
-use \OCP\IUser;
-use \OCP\IL10N;
-use \OCA\Files_External\Lib\DefinitionParameter;
-use \OCA\Files_External\Lib\Auth\AuthMechanism;
-use \OCA\Files_External\Lib\StorageConfig;
-use \OCP\ISession;
-use \OCP\Security\ICrypto;
-use \OCP\Files\Storage;
-use \OCA\Files_External\Lib\SessionStorageWrapper;
-use \OCA\Files_External\Lib\InsufficientDataForMeaningfulAnswerException;
+use OCA\Files_External\Lib\Auth\AuthMechanism;
+use OCA\Files_External\Lib\InsufficientDataForMeaningfulAnswerException;
+use OCA\Files_External\Lib\SessionStorageWrapper;
+use OCA\Files_External\Lib\StorageConfig;
+use OCP\Authentication\Exceptions\CredentialsUnavailableException;
+use OCP\Authentication\LoginCredentials\IStore as CredentialsStore;
+use OCP\Files\Storage;
+use OCP\IL10N;
+use OCP\ISession;
+use OCP\IUser;
+use OCP\Security\ICrypto;
/**
* Username and password from login credentials, saved in session
@@ -45,39 +47,29 @@ class SessionCredentials extends AuthMechanism {
/** @var ICrypto */
protected $crypto;
- public function __construct(IL10N $l, ISession $session, ICrypto $crypto) {
+ /** @var CredentialsStore */
+ private $credentialsStore;
+
+ public function __construct(IL10N $l, ISession $session, ICrypto $crypto, CredentialsStore $credentialsStore) {
$this->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) {