Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F1880214
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Size
3 KB
Subscribers
None
View Options
diff --git a/auth.php b/auth.php
--- a/auth.php
+++ b/auth.php
@@ -1,61 +1,68 @@
<?php
// must be run within Dokuwiki
if(!defined('DOKU_INC')) die();
//Load the PHPGangsta_GoogleAuthenticator Class
require_once(dirname(__FILE__).'/GoogleAuthenticator.php');
require_once(dirname(__FILE__).'/TokenHelper.php');
/**
* Google Authenticator Two Factor Authentication
*
+ * @author Andreas Böhler <dev@aboehler.at>
* @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 @@
<?php
$lang['g2fa'] = "Google Authenticator Token";
$lang['menu'] = "Google 2Factor Token Manager";
-$lang['force'] = "Google 2Factor Authentication is enabled, but not activated for your accoung. Contact your admin.";
+$lang['force'] = "Google 2Factor Authentication is enabled, but not activated for your account. Contact your admin.";
$lang['hint'] = "Google 2Factor Authentication hasn't been activated for your account. Update your profile.";
$lang['g2fa_fieldset'] = "Google 2Factor Configuration";
$lang['g2fa_created'] = "Created and saved new Secret";
$lang['g2fa_updated'] = "Saved new secret.";
$lang['g2fa_notchanged'] = "Error updating secret.";
$lang['g2fa_removed'] = "Removed token for your account";
$lang['secret'] = "Secret";
$lang['showqr'] = "Show Secret/QR Code";
$lang['generate'] = "Generate Secret";
$lang['delete'] = "Delete Secret";
$lang['update'] = "Update Secret";
?>
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
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Fri, Jan 24, 3:13 AM (1 d, 13 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
533761
Default Alt Text
(3 KB)
Attached To
rGTFA authg2fa
Event Timeline
Log In to Comment