Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F1726519
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Size
6 KB
Subscribers
None
View Options
diff --git a/action.php b/action.php
--- a/action.php
+++ b/action.php
@@ -1,101 +1,113 @@
<?php
// must be run within Dokuwiki
if (!defined('DOKU_INC')) die();
require_once(dirname(__FILE__).'/TokenHelper.php');
require_once(dirname(__FILE__).'/GoogleAuthenticator.php');
/**
* Google Authenticator Two Factor Form Action Plugin
*
* @autho Andreas Boehler dev@aboehler.at
* @author Daniel Popp dan@danpopp.net
*/
class action_plugin_authg2fa extends DokuWiki_Action_Plugin {
/**
* Registers the event handlers.
*/
function register(&$controller)
{
$enable = $this->getConf("g2fa_enable");
if($enable===1) {
$controller->register_hook('HTML_LOGINFORM_OUTPUT', 'BEFORE', $this, 'two_fa_login_form', array());
$controller->register_hook('HTML_UPDATEPROFILEFORM_OUTPUT', 'AFTER', $this, 'handle_profile_form', array());
}
}
/**
* Handles the login form rendering.
*/
function two_fa_login_form(&$event, $param) {
global $conf;
// Show login form above submit button (and above remember me option, if enabled)
$pos = $event->data->findElementByAttribute('type', 'submit');
if($conf["rememberme"])
$pos = $pos-1;
$event->data->insertElement($pos, form_makePasswordField('t', $this->getLang('g2fa'), '', 'block'));
}
function handle_profile_form(&$event, $param) {
global $ID;
global $INPUT;
$fn = $INPUT->param('fn');
if(is_array($fn)) {
$cmd = key($fn);
$param = is_array($fn[$cmd]) ? key($fn[$cmd]) : null;
} else {
$cmd = $fn;
$param = null;
}
$th = new TokenHelper();
$secret = $th->getSecret($_SERVER['REMOTE_USER']);
$form = new Doku_Form($ID);
$form->startFieldset($this->getLang('g2fa_fieldset'));
$form->addHidden('do', 'profile');
$form->addHidden('g2fa', '1');
+ $reveal = false;
switch($cmd) {
case "gensecret" :
if($th->createTokenForUser($_SERVER['REMOTE_USER'])) {
msg($this->getLang('g2fa_created'));
$secret = $th->getSecret($_SERVER['REMOTE_USER']);
}
break;
case "update":
+ if($INPUT->param('secret') == "********")
+ {
+ msg($this->getLang('g2fa_notchanged'));
+ break;
+ }
if($th->saveToken($_SERVER['REMOTE_USER'], $INPUT->param('secret')))
msg($this->getLang('g2fa_updated'));
+ else
+ msg($this->getLang('g2fa_notchanged'));
$secret = $th->getSecret($_SERVER['REMOTE_USER']);
break;
case "showqr" :
if($secret != '') {
$ga = new PHPGangsta_GoogleAuthenticator();
$url = $ga->getQRCodeGoogleUrl('DokuWiki for '.$_SERVER['REMOTE_USER'], $secret);
$form->addElement(form_makeTag('img', array('src' => $url, 'alt' => 'Google 2FA QR Image')));
$form->addElement(form_makeTag('br'));
+ $reveal = true;
}
break;
case "delsecret" :
if($th->deleteTokenForUser($_SERVER['REMOTE_USER'])) {
msg($this->getLang('g2fa_removed'));
$secret = '';
}
break;
}
-
- $form->addElement(form_makeTextField('secret', $secret, $this->getLang('secret'), '', 'block', array('size'=>'50')));
+ if($reveal) {
+ $form->addElement(form_makeTextField('secret', $secret, $this->getLang('secret'), '', 'block', array('size'=>'50')));
+ } else {
+ $form->addElement(form_makeTextField('secret', '********', $this->getLang('secret'), '', 'block', array('size'=>'50')));
+ }
$form->addElement(form_makeButton('submit', '', $this->getLang('showqr'), array('name' => 'fn[showqr]', 'disabled' => $secret == '' ? 'disabled' : '')));
$form->addElement(form_makeTag('br'));
$form->addElement(form_makeButton('submit', '', $this->getLang('generate'), array('name' => 'fn[gensecret]')));
$form->addElement(form_makeButton('submit', '', $this->getLang('update'), array('name' => 'fn[update]')));
$form->addElement(form_makeTag('br'));
$form->addElement(form_makeButton('submit', '', $this->getLang('delete'), array('name' => 'fn[delsecret]', 'disabled' => $secret == '' ? 'disabled' : '' )));
$form->endFieldset();
html_form('g2fa', $form);
}
}
?>
diff --git a/lang/de/lang.php b/lang/de/lang.php
--- a/lang/de/lang.php
+++ b/lang/de/lang.php
@@ -1,18 +1,19 @@
<?php
$lang['g2fa'] = "Google Authenticator Token";
$lang['menu'] = "Google 2Factor Authenticator Token Manager";
$lang['hint'] = "Google 2-Faktor Authentifizierung wurde noch nicht eingerichtet. Unter Profil kann es aktiviert werden.";
$lang['force'] = "Google 2-Faktor Authentifizierung wurde nicht eingerichtet, aber ist erforderlich. Admin kontaktiern.";
$lang['g2fa_fieldset'] = "Google 2-Faktor Konfiguration";
$lang['g2fa_created'] = "Neuen Schlüssel erstellt und gespeichert.";
$lang['g2fa_updated'] = "Neuen Schlüssel gespeichert.";
+$lang['g2fa_notchanged'] = "Schlüssel konnte nicht aktualisiert werden.";
$lang['g2fa_removed'] = "Schlüssel für diesen Account gelöscht.";
$lang['secret'] = "Schlüssel";
-$lang['showqr'] = "QR Code anzeigen";
+$lang['showqr'] = "QR Code/Schlüssel anzeigen";
$lang['generate'] = "Schlüssel erzeugen";
$lang['delete'] = "Schlüssel löschen";
$lang['update'] = "Schlüssel ändern";
?>
diff --git a/lang/en/lang.php b/lang/en/lang.php
--- a/lang/en/lang.php
+++ b/lang/en/lang.php
@@ -1,17 +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['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 QR Code";
+$lang['showqr'] = "Show Secret/QR Code";
$lang['generate'] = "Generate Secret";
$lang['delete'] = "Delete Secret";
$lang['update'] = "Update Secret";
?>
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Wed, Dec 4, 4:52 PM (10 h, 40 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
558370
Default Alt Text
(6 KB)
Attached To
rGTFA authg2fa
Event Timeline
Log In to Comment