summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/encryption/appinfo/info.xml3
-rw-r--r--apps/files_external/appinfo/info.xml3
-rw-r--r--apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php60
-rw-r--r--apps/files_external/tests/Command/ListCommandTest.php15
4 files changed, 32 insertions, 49 deletions
diff --git a/apps/encryption/appinfo/info.xml b/apps/encryption/appinfo/info.xml
index 1e63ca5c471..307fef4ad8a 100644
--- a/apps/encryption/appinfo/info.xml
+++ b/apps/encryption/appinfo/info.xml
@@ -18,8 +18,7 @@
<user>user-encryption</user>
<admin>admin-encryption</admin>
</documentation>
- <rememberlogin>false</rememberlogin>
- <version>1.5.0</version>
+ <version>1.6.0</version>
<types>
<filesystem/>
</types>
diff --git a/apps/files_external/appinfo/info.xml b/apps/files_external/appinfo/info.xml
index 8482b8b25ed..3f6a48d2e22 100644
--- a/apps/files_external/appinfo/info.xml
+++ b/apps/files_external/appinfo/info.xml
@@ -12,8 +12,7 @@ External storage can be configured using the GUI or at the command line. This se
<documentation>
<admin>admin-external-storage</admin>
</documentation>
- <rememberlogin>false</rememberlogin>
- <version>1.2.0</version>
+ <version>1.3.0</version>
<types>
<filesystem/>
</types>
diff --git a/apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php b/apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php
index 2fa939764d7..30644206c26 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,61 +24,42 @@
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\IUser;
/**
* Username and password from login credentials, saved in session
*/
class SessionCredentials extends AuthMechanism {
- /** @var ISession */
- protected $session;
-
- /** @var ICrypto */
- protected $crypto;
+ /** @var CredentialsStore */
+ private $credentialsStore;
- public function __construct(IL10N $l, ISession $session, ICrypto $crypto) {
- $this->session = $session;
- $this->crypto = $crypto;
+ public function __construct(IL10N $l, CredentialsStore $credentialsStore) {
+ $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) {
diff --git a/apps/files_external/tests/Command/ListCommandTest.php b/apps/files_external/tests/Command/ListCommandTest.php
index 5563b19c7a8..76a8f98f520 100644
--- a/apps/files_external/tests/Command/ListCommandTest.php
+++ b/apps/files_external/tests/Command/ListCommandTest.php
@@ -31,25 +31,27 @@ use OCA\Files_External\Lib\Backend\Local;
use OCA\Files_External\Lib\StorageConfig;
use OCA\Files_External\Service\GlobalStoragesService;
use OCA\Files_External\Service\UserStoragesService;
+use OCP\Authentication\LoginCredentials\IStore;
use OCP\IL10N;
use OCP\ISession;
use OCP\IUserManager;
use OCP\IUserSession;
use OCP\Security\ICrypto;
+use PHPUnit_Framework_MockObject_MockObject;
use Symfony\Component\Console\Output\BufferedOutput;
class ListCommandTest extends CommandTest {
/**
- * @return \OCA\Files_External\Command\ListCommand|\PHPUnit_Framework_MockObject_MockObject
+ * @return ListCommand|PHPUnit_Framework_MockObject_MockObject
*/
private function getInstance() {
- /** @var \OCA\Files_External\Service\GlobalStoragesService|\PHPUnit_Framework_MockObject_MockObject $globalService */
+ /** @var GlobalStoragesService|PHPUnit_Framework_MockObject_MockObject $globalService */
$globalService = $this->createMock(GlobalStoragesService::class);
- /** @var \OCA\Files_External\Service\UserStoragesService|\PHPUnit_Framework_MockObject_MockObject $userService */
+ /** @var UserStoragesService|PHPUnit_Framework_MockObject_MockObject $userService */
$userService = $this->createMock(UserStoragesService::class);
- /** @var \OCP\IUserManager|\PHPUnit_Framework_MockObject_MockObject $userManager */
+ /** @var IUserManager|PHPUnit_Framework_MockObject_MockObject $userManager */
$userManager = $this->createMock(IUserManager::class);
- /** @var \OCP\IUserSession|\PHPUnit_Framework_MockObject_MockObject $userSession */
+ /** @var IUserSession|PHPUnit_Framework_MockObject_MockObject $userSession */
$userSession = $this->createMock(IUserSession::class);
return new ListCommand($globalService, $userService, $userSession, $userManager);
@@ -64,7 +66,8 @@ class ListCommandTest extends CommandTest {
$mount1->setAuthMechanism(new Password($l10n));
$mount1->setBackend(new Local($l10n, new NullMechanism($l10n)));
$mount2 = new StorageConfig();
- $mount2->setAuthMechanism(new SessionCredentials($l10n, $session, $crypto));
+ $credentialStore = $this->createMock(IStore::class);
+ $mount2->setAuthMechanism(new SessionCredentials($l10n, $credentialStore));
$mount2->setBackend(new Local($l10n, new NullMechanism($l10n)));
$input = $this->getInput($instance, [], [
'output' => 'json'