diff --git a/auth.php b/auth.php --- a/auth.php +++ b/auth.php @@ -1,61 +1,68 @@ * @author Daniel Popp dan@danpopp.net */ class auth_plugin_authg2fa extends auth_plugin_authplain { function __construct() { parent::__construct(); } function __destruct() { //parent::__destruct(); } function checkPass($user,$pass) { $th = new TokenHelper(); $secret = $th->getSecret($user); if($secret != "") { define('GOOGLE_AUTH_SECRET', $secret); $twofactor = true; } else { $twofactor = false; } $tslack = $this->getConf("g2fa_timeout_slack"); $enable = $this->getConf("g2fa_enable"); $force = $this->getConf("g2fa_force"); $hint = $this->getConf("g2fa_hint"); if($enable == 1) { // The plugin is at least enabled! if(!$twofactor) { // There is no secret for the given user.. if($force) { msg($this->getLang('force')); + $log = array('message' => 'authg2fa: login failed. No token found for the current user', 'user' => $user); + trigger_event('PLUGIN_LOGLOG_LOG', $log); return false; } else if($hint) { + $log = array('message' => 'authg2fa: passing login to parent. No token found for the current user', 'user' => $user); + trigger_event('PLUGIN_LOGLOG_LOG', $log); msg($this->getLang('hint')); } } else { // 2FA is enabled AND we have a secret, so let's check it if(isset($_POST['p'])) { $ga = new PHPGangsta_GoogleAuthenticator(); $twofa = $_POST['t']; $checkResult = $ga->verifyCode($secret, $twofa, $tslack); } else { $checkResult = false; } if(!$checkResult) { // 2FA code didn't match OR no password supplied + $log = array('message' => 'authg2fa: login failed. Token did not match or no token supplied', 'user' => $user); + trigger_event('PLUGIN_LOGLOG_LOG', $log); return false; } } } return parent::checkPass($user,$pass); } } ?> diff --git a/lang/en/lang.php b/lang/en/lang.php --- a/lang/en/lang.php +++ b/lang/en/lang.php @@ -1,18 +1,18 @@ diff --git a/plugin.info.txt b/plugin.info.txt --- a/plugin.info.txt +++ b/plugin.info.txt @@ -1,7 +1,7 @@ base authg2fa author Andreas Boehler email dev@aboehler.at -date 2016-11-04 +date 2017-03-08 name 2Factor Google Authenticator Plugin desc Adds Google 2Factor Authentication to DokuWiki local password storage. url https://www.dokuwiki.org/plugin:authg2fa