mirror of
https://github.com/ChristophWurst/twofactor_test
synced 2025-10-05 01:59:24 +02:00
initial commit
This commit is contained in:
commit
ad8a9d51b9
4 changed files with 123 additions and 0 deletions
92
lib/Provider/TwoFactorTestProvider.php
Normal file
92
lib/Provider/TwoFactorTestProvider.php
Normal file
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @author Christoph Wurst <christoph@owncloud.com>
|
||||
*
|
||||
* @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 <http://www.gnu.org/licenses/>
|
||||
*
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue