diff --git a/html/captive-portal/templates/mfa/TOTP.html b/html/captive-portal/templates/mfa/TOTP.html index 145d4bfe99e3..b837382617ed 100644 --- a/html/captive-portal/templates/mfa/TOTP.html +++ b/html/captive-portal/templates/mfa/TOTP.html @@ -6,7 +6,7 @@
[% ELSE %][% i18n("Please scan the code below in your favorite authenticator app") %]
- - [% END %] + + + [% END %] [% IF exist %] diff --git a/html/common/qrcode.js b/html/common/qrcode.js index 0cfa61a8977c..eeb637ff3f5a 100644 --- a/html/common/qrcode.js +++ b/html/common/qrcode.js @@ -4,5 +4,8 @@ document.addEventListener('DOMContentLoaded', function () { const qrcode = document.getElementById('qrcode'); const otp = qrcode.getAttribute('data-otp'); const username = qrcode.getAttribute('data-username'); - new QRCode(qrcode, `otpauth://totp/${username}.packetfence?secret=${otp}`); + const digits = qrcode.getAttribute('data-digits'); + const period = qrcode.getAttribute('data-period'); + const suffix = qrcode.getAttribute('data-suffix'); + new QRCode(qrcode, `otpauth://totp/${username}.${suffix}?secret=${otp}&digits=${digits}&period=${period}`); }); diff --git a/html/pfappserver/lib/pfappserver/Form/Config/Mfa/TOTP.pm b/html/pfappserver/lib/pfappserver/Form/Config/Mfa/TOTP.pm index 717eb89089bb..f92e5097f005 100644 --- a/html/pfappserver/lib/pfappserver/Form/Config/Mfa/TOTP.pm +++ b/html/pfappserver/lib/pfappserver/Form/Config/Mfa/TOTP.pm @@ -42,9 +42,36 @@ has_field 'radius_mfa_method' => default => 'strip-otp', ); +has_field 'period' => + ( + type => 'Duration', + default => { + interval => 30, + unit => 's', + }, + ); + +has_field 'token_size' => + ( + type => 'IntRange', + label => 'Token size', + required => 1, + default => 6, + range_start => 1, + range_end => 10, + ); + +has_field 'suffix' => + ( + type => 'Text', + required => 1, + default => 'packetfence', + messages => { required => 'Please specify the suffix that will be added to the username' }, + ); + has_block definition => ( - render_list => [ qw(id radius_mfa_method) ], + render_list => [ qw(id radius_mfa_method period token_size suffix) ], ); =over diff --git a/html/pfappserver/root/src/views/Configuration/mfas/_components/FormTypeTOTP.vue b/html/pfappserver/root/src/views/Configuration/mfas/_components/FormTypeTOTP.vue index 253927a8cef5..cc02ad8fc6b2 100644 --- a/html/pfappserver/root/src/views/Configuration/mfas/_components/FormTypeTOTP.vue +++ b/html/pfappserver/root/src/views/Configuration/mfas/_components/FormTypeTOTP.vue @@ -15,6 +15,11 @@ :text="$i18n.t('Define the method to be used in RADIUS to trigger OTP.')" /> +