如何禁用TFA(双因素身份验证)

时间:2014-02-10 16:32:54

标签: joomla google-authenticator

我在Joomla 3.2中启用了TFA并且工作正常,但我的智能手机无法访问。

然后我不能进入后端,我试图在数据库中禁用插件plg_twofactorauth_totp但它保持启用状态。

通过重命名文件夹来禁用隐藏密钥输入,但我无法登录。

2 个答案:

答案 0 :(得分:3)

转到您的MySQL数据库以获取joomla,转到用户表。清除 otpKey 的值。你现在应该可以在没有钥匙的情况下登录。

答案 1 :(得分:-1)

https://gist.github.com/medigeek/28a047be0d0d527a95769130a6faf559

此代码将禁用Joomla的双因素身份验证插件和清除键!超级用户。

此脚本禁用Joomla!的双因素身份验证插件,并清除超级用户的otpKey和otep值。当您因任何原因无法使用Google身份验证器时,它允许您登录。<​​/ p>

<强>用法:

把它放在Joomla中! 3.x root dir(其中configuration.php和index.php是)并运行它。然后登录并将安全密钥字段留空。

警告:请谨慎使用。使用前备份

代码快照

<?php
/* This script disables Joomla!'s two factor authentication
 * plugin and clears the otpKey and otep values for Super 
 * Users. It allows you to login when you aren't able to
 * use Google authenticator for any reason.

 * Usage:
 * Place it in the Joomla! 3.x root dir (where configuration.php 
 * and index.php are) and run it. Then login and leave the 
 * security key field empty.

 * Warning: Use with caution. Backup before use.
*/
define('_JEXEC', 1);
define('JPATH_BASE', __DIR__);
error_reporting(E_ALL);
ini_set('display_errors', 1);
// Load system defines
if (file_exists(JPATH_BASE . '/defines.php')) { require_once JPATH_BASE . '/defines.php'; }
if (!defined('_JDEFINES')) { require_once JPATH_BASE . '/includes/defines.php'; }
require_once JPATH_LIBRARIES . '/import.legacy.php'; // Get the framework.
require_once JPATH_LIBRARIES . '/cms.php'; // Bootstrap the CMS libraries.
class Reset2FA extends JApplicationCli
{
    public function execute()
    {
        $this->out('Initialising');
        $db = JFactory::getDbo();
        $query = $db->getQuery(true);
        $query2 = $db->getQuery(true);
        //get users by group: (array of integers)
        $sadminids = JAccess::getUsersByGroup(8); // 8 = Super Users
        $strsadminids = implode(',', $sadminids);
        $this->out(sprintf('Super User IDs: %s', $strsadminids));
        $this->out('Disabling twofactorauth plugin (totp and yubikey)');
        // Fields to update.
        $fields = array(sprintf('%s = 0', $db->quoteName('enabled')));
        // Conditions for which records should be updated.
        // plg_twofactorauth_totp
        // plg_twofactorauth_yubikey
        $conditions = array(sprintf('%s LIKE %s', $db->quoteName('name'), $db->quote('plg_twofactorauth_%')));
        $query->update($db->quoteName('#__extensions'))->set($fields)->where($conditions);
        $db->setQuery($query);
        $result = $db->execute();

        $this->out('Disabling/clearing otpKey and otep for all Super Users');
        // UPDATE 2
        $fields2 = array(
            $db->quoteName('otpKey') . " = ''",
            $db->quoteName('otep') . " = ''",
            );
        // Conditions for which records should be updated.
        // otpKey
        // otep
        $conditions2 = array(
            $db->quoteName('otpKey') . " != ''",
            $db->quoteName('otep') . " != ''",
            sprintf('%s IN (%s)', $db->quoteName('id'), $strsadminids)
        );
        $query2->update($db->quoteName('#__users'))->set($fields2)->where($conditions2);
        $db->setQuery($query2);
        $result2 = $db->execute();
        $this->out('Done');
    }
}
JApplicationCli::getInstance('Reset2FA')->execute();
?>