commit ad8a9d51b98a4cdb5eea3e76b81184fed73f0e16 Author: Christoph Wurst Date: Wed Jun 1 15:01:43 2016 +0200 initial commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..082bf89 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# twofactor_test + +Dummy 2FA provider to test ownCloud's 2FA \ No newline at end of file diff --git a/appinfo/info.xml b/appinfo/info.xml new file mode 100644 index 0000000..2397a8d --- /dev/null +++ b/appinfo/info.xml @@ -0,0 +1,23 @@ + + + twofactor_test + Two Factor Test Provider + An Two-Factor-Auth Test Provider for ownCloud 9.1 + AGPL + Christoph Wurst + 0.0.1 + TwoFactor_Test + other + + + + + + + OCA\TwoFactor_Test\Provider\TwoFactorTestProvider + + + + + + diff --git a/lib/Provider/TwoFactorTestProvider.php b/lib/Provider/TwoFactorTestProvider.php new file mode 100644 index 0000000..e0320d5 --- /dev/null +++ b/lib/Provider/TwoFactorTestProvider.php @@ -0,0 +1,92 @@ + + * + * @copyright Copyright (c) 2016, 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 + * + */ + +namespace OCA\TwoFactor_Test\Provider; + +use OCP\Authentication\TwoFactorAuth\IProvider; +use OCP\IUser; +use OCP\Template; + +class TwoFactorTestProvider implements IProvider { + + /** + * Get unique identifier of this 2FA provider + * + * @return string + */ + public function getId() { + return 'test'; + } + + /** + * Get the display name for selecting the 2FA provider + * + * @return string + */ + public function getDisplayName() { + return 'Test'; + } + + /** + * Get the description for selecting the 2FA provider + * + * @return string + */ + public function getDescription() { + return 'Use a test provider'; + } + + /** + * Get the template for rending the 2FA provider view + * + * @param IUser $user + * @return Template + */ + public function getTemplate(IUser $user) { + return new Template('twofactor_test', 'challenge'); + } + + /** + * Verify the given challenge + * + * @param IUser $user + * @param string $challenge + */ + public function verifyChallenge(IUser $user, $challenge) { + if ($challenge === 'passme') { + return true; + } + return false; + } + + /** + * Decides whether 2FA is enabled for the given user + * + * @param IUser $user + * @return boolean + */ + public function isTwoFactorAuthEnabledForUser(IUser $user) { + // 2FA is enforced for all users + return true; + } + +} diff --git a/templates/challenge.php b/templates/challenge.php new file mode 100644 index 0000000..6ffae53 --- /dev/null +++ b/templates/challenge.php @@ -0,0 +1,5 @@ +
+ + + +