Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing a bug and adding support for custom save device days and latest RC elastic skin. #165

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
82f9c0c
Update twofactor_gauthenticator_form.js
InputOutputZ Aug 23, 2022
8d7360b
Create en_UK.inc
InputOutputZ Aug 23, 2022
6bb2db6
Update config.inc.php.dist
InputOutputZ Aug 23, 2022
404c9ca
Update config.inc.php.dist
InputOutputZ Aug 23, 2022
36a4e8c
Update twofactor_gauthenticator.php
InputOutputZ Aug 23, 2022
c91cf3d
Update twofactor_gauthenticator_form.js
InputOutputZ Aug 23, 2022
7c514d0
Update twofactor_gauthenticator.js
InputOutputZ Aug 23, 2022
4455846
Update 2FA_qr_code.js
InputOutputZ Aug 23, 2022
92f5ced
Update en_US.inc
InputOutputZ Aug 29, 2022
24cbfd8
Update twofactor_gauthenticator.php
InputOutputZ Aug 29, 2022
1fcd9a1
Update twofactor_gauthenticator.php
InputOutputZ Aug 29, 2022
f46e3db
Update twofactor_gauthenticator.php
InputOutputZ Aug 29, 2022
525b49d
Update config.inc.php.dist
InputOutputZ Aug 29, 2022
077a70d
Update twofactor_gauthenticator.php
InputOutputZ Aug 29, 2022
d80c844
Update twofactor_gauthenticator.php
InputOutputZ Aug 30, 2022
97456ae
Update twofactor_gauthenticator.php
InputOutputZ Aug 30, 2022
f7480bd
Update twofactor_gauthenticator.php
InputOutputZ Aug 31, 2022
0586d78
Update twofactor_gauthenticator.php
InputOutputZ Aug 31, 2022
7bbd7c0
Update twofactor_gauthenticator.php
InputOutputZ Sep 1, 2022
52e7dfb
Update twofactor_gauthenticator.php
InputOutputZ Sep 1, 2022
751c88c
Update twofactor_gauthenticator.php
InputOutputZ Sep 3, 2022
226f583
Update twofactor_gauthenticator.php
InputOutputZ Sep 3, 2022
ef84202
Update twofactor_gauthenticator.php
InputOutputZ Sep 11, 2022
4d62786
Update twofactor_gauthenticator.php
InputOutputZ Sep 21, 2022
cf55714
Update twofactor_gauthenticator.php
InputOutputZ Oct 18, 2022
d66e0d5
Update 2FA_qr_code.js
InputOutputZ Apr 13, 2023
849a623
Update twofactor_gauthenticator.js
InputOutputZ Apr 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions 2FA_qr_code.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
if (window.rcmail) {
rcmail.addEventListener('init', function() {

var url_qr_code_values = 'otpauth://totp/Roundcube:' +$('#prefs-title').html().split(/ - /)[1]+ '?secret=' +$('#2FA_secret').get(0).value +'&issuer=RoundCube2FA%20'+window.location.hostname;
var url_qr_code_values = 'otpauth://totp/Roundcube:' +$('#prefs-title').html().split(/ - /)[0]+ '?secret=' +$('#2FA_secret').get(0).value +'&issuer=%20'+window.location.hostname;

var qrcode = new QRCode(document.getElementById("2FA_qr_code"), {
text: url_qr_code_values,
width: 200,
height: 200,
colorDark : "#000000",
colorDark : rcmail.env.qr_image_colour,
colorLight : "#ffffff",
correctLevel : QRCode.CorrectLevel.M // like charts.googleapis.com
correctLevel : QRCode.CorrectLevel.M //like charts.googleapis.com
});

$('#2FA_qr_code').prop('title', ''); // enjoy the silence (qrcode.js uses text to set title)
Expand Down
7 changes: 6 additions & 1 deletion config.inc.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,17 @@ $rcmail_config['whitelist'] = array('192.168.1.0/24', '::1', '192.168.0.9');

// Admin can disable saving devices for all users (paranoid mode)
// Default: allow saving devices (true)
$rcmail_config['allow_save_device_30days'] = true;
$rcmail_config['allow_save_device_xdays'] = true;

$rcmail_config['save_device_xdays'] = 30;

$rcmail_config['qr_image_colour'] = "#000000";

// Make the 2-step field a masked password input type
// Default: form field will be text (false)
$rcmail_config['twofactor_formfield_as_password'] = false;

$rcmail_config['enable_ua2fa'] = false;

// Users allowed to use plugin (IMPORTANT: other users DON'T have plugin activated)
$rcmail_config['users_allowed_2FA'] = array('ale.*@tereborace.com', '[email protected]');
Expand Down
41 changes: 41 additions & 0 deletions localization/en_UK.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
// Labels used for different portions of the plugin
$labels = array();
$labels['activate'] = 'Activate';
$labels['twofactor_gauthenticator'] = 'Two-Factor Authentication';
$labels['code'] = 'Google Authenticator Code';

$labels['two_step_verification_form'] = '2-Factor Authentication Code:';

$labels['secret'] = 'Secret';
$labels['qr_code'] = 'QR Code';
$labels['msg_infor'] = 'You can scan this QR code containing the 2-Factor settings using a TOTP compatible app such as <a href="https://github.com/google/google-authenticator" target="_blank">google-authenticator</a>';

$labels['show_secret'] = 'Show secret';
$labels['hide_secret'] = 'Hide secret';
$labels['create_secret'] = 'Create secret';

$labels['show_qr_code'] = 'Show QR Code';
$labels['hide_qr_code'] = 'Hide QR Code';

$labels['recovery_codes'] = 'Recovery codes';
$labels['show_recovery_codes'] = 'Show recovery codes';
$labels['hide_recovery_codes'] = 'Hide recovery codes';

$labels['setup_all_fields'] = 'Fill all fields (make sure you click save to store your settings)';

$labels['enrollment_dialog_title'] = '2-Factor authentication enrollment';
$labels['enrollment_dialog_msg'] = '<strong>2-Factor authentication codes</strong> are required for increased security, please configure them now.';

$labels['check_code'] = 'Check code';
$labels['code_ok'] = 'Code OK';
$labels['code_ko'] = 'Incorrect code';

$labels['dont_ask_me_xdays'] = 'Don&#39;t ask me codes again on this computer for % days';

$labels['check_code_to_activate'] = 'To save, please scan the QR Code and enter the current 2-Factor code below.';

// Messages used for the different portions of the plugin
$messages = array();
$messages['successfully_saved'] = '2-Factor authentication settings saved successfully.';

5 changes: 2 additions & 3 deletions localization/en_US.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Labels used for different portions of the plugin
$labels = array();
$labels['activate'] = 'Activate';
$labels['twofactor_gauthenticator'] = '2-Factor Authentication';
$labels['twofactor_gauthenticator'] = 'Two-Factor Authentication';
$labels['code'] = 'Google Authenticator Code';

$labels['two_step_verification_form'] = '2-Factor Authentication Code:';
Expand Down Expand Up @@ -31,11 +31,10 @@ $labels['check_code'] = 'Check code';
$labels['code_ok'] = 'Code OK';
$labels['code_ko'] = 'Incorrect code';

$labels['dont_ask_me_30days'] = 'Don&#39;t ask me codes again on this computer for 30 days';
$labels['dont_ask_me_xdays'] = 'Don&#39;t ask me codes again on this computer for % days';

$labels['check_code_to_activate'] = 'To save, please scan the QR Code and enter the current 2-Factor code below.';

// Messages used for the different portions of the plugin
$messages = array();
$messages['successfully_saved'] = '2-Factor authentication settings saved successfully.';

10 changes: 6 additions & 4 deletions twofactor_gauthenticator.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ if (window.rcmail) {
});

// add qr-code before msg_infor
var url_qr_code_values = 'otpauth://totp/' +$('#prefs-title').html().split(/ - /)[1]+ '?secret=' +$('#2FA_secret').get(0).value +'&issuer=RoundCube2FA%20'+window.location.hostname;
$('table tr:last').before('<tr><td>' +rcmail.gettext('qr_code', 'twofactor_gauthenticator')+ '</td><td><input type="button" class="button mainaction btn btn-primary" id="2FA_change_qr_code" value="'
var url_qr_code_values = 'otpauth://totp/' +$('#prefs-title').html().split(/ - /)[0]+ '?secret=' +$('#2FA_secret').get(0).value +'&issuer=%20'+window.location.hostname;
$('table tr:last').before('<tr class="form-group row"><td class="title col-sm-6">' +rcmail.gettext('qr_code', 'twofactor_gauthenticator')+ '</td><td class="col-sm-6"><input type="button" class="button mainaction btn btn-primary" id="2FA_change_qr_code" value="'
+rcmail.gettext('hide_qr_code', 'twofactor_gauthenticator')+ '"><div id="2FA_qr_code" style="display: visible; margin-top: 10px;"></div></td></tr>');

var qrcode = new QRCode(document.getElementById("2FA_qr_code"), {
text: url_qr_code_values,
width: 200,
height: 200,
colorDark : "#000000",
colorDark : rcmail.env.qr_image_colour,
colorLight : "#ffffff",
correctLevel : QRCode.CorrectLevel.L // like charts.googleapis.com
});
Expand Down Expand Up @@ -129,7 +129,9 @@ if (window.rcmail) {
$('#2FA_check_code').click(function(){
url = "./?_action=plugin.twofactor_gauthenticator-checkcode&code=" +$('#2FA_code_to_check').val() + '&secret='+$('#2FA_secret').val();
$.post(url, function(data){
alert(data);

alert(data);

if(data == rcmail.gettext('code_ok', 'twofactor_gauthenticator'))
$('#2FA_setup_fields').prev().removeAttr('disabled');

Expand Down
Loading