diff options
Diffstat (limited to 'apps/files_external/lib/auth')
-rw-r--r-- | apps/files_external/lib/auth/iuserprovided.php | 36 | ||||
-rw-r--r-- | apps/files_external/lib/auth/password/userprovided.php | 9 |
2 files changed, 41 insertions, 4 deletions
diff --git a/apps/files_external/lib/auth/iuserprovided.php b/apps/files_external/lib/auth/iuserprovided.php new file mode 100644 index 00000000000..6b7eab4e2a7 --- /dev/null +++ b/apps/files_external/lib/auth/iuserprovided.php @@ -0,0 +1,36 @@ +<?php +/** + * @author Robin Appelman <icewind@owncloud.com> + * + * @copyright Copyright (c) 2015, ownCloud, Inc. + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see <http://www.gnu.org/licenses/> + * + */ + +namespace OCA\Files_External\Lib\Auth; + +use OCP\IUser; + +/** + * For auth mechanisms where the user needs to provide credentials + */ +interface IUserProvided { + /** + * @param IUser $user the user for which to save the user provided options + * @param int $mountId the mount id to save the options for + * @param array $options the user provided options + */ + public function saveBackendOptions(IUser $user, $mountId, array $options); +} diff --git a/apps/files_external/lib/auth/password/userprovided.php b/apps/files_external/lib/auth/password/userprovided.php index 1c2cc0a6d97..e1c1352022f 100644 --- a/apps/files_external/lib/auth/password/userprovided.php +++ b/apps/files_external/lib/auth/password/userprovided.php @@ -21,6 +21,7 @@ namespace OCA\Files_External\Lib\Auth\Password; +use OCA\Files_External\Lib\Auth\IUserProvided; use OCA\Files_External\Lib\DefinitionParameter; use OCA\Files_External\Service\BackendService; use OCP\IL10N; @@ -34,7 +35,7 @@ use OCA\Files_External\Lib\InsufficientDataForMeaningfulAnswerException; /** * User provided Username and Password */ -class UserProvided extends AuthMechanism { +class UserProvided extends AuthMechanism implements IUserProvided { const CREDENTIALS_IDENTIFIER_PREFIX = 'password::userprovided/'; @@ -62,10 +63,10 @@ class UserProvided extends AuthMechanism { return self::CREDENTIALS_IDENTIFIER_PREFIX . $storageId; } - public function saveCredentials(IUser $user, $id, $username, $password) { + public function saveBackendOptions(IUser $user, $id, array $options) { $this->credentialsManager->store($user->getUID(), $this->getCredentialsIdentifier($id), [ - 'user' => $username, - 'password' => $password + 'user' => $options['user'], // explicitly copy the fields we want instead of just passing the entire $options array + 'password' => $options['password'] // this way we prevent users from being able to modify any other field ]); } |