RT-Extension-TOTPMFA
view release on metacpan or search on metacpan
html/Callbacks/TOTPMFA/Prefs/Elements/EditAboutMe/FormRightColumn view on Meta::CPAN
<%doc>
Add a section to the user "about me" page providing the TOTPMFA settings.
These are processed on form submission by the UpdateLogic callback of the
/Prefs/AboutMe.html page.
</%doc>
\
<%ARGS>
$UserObj => undef
</%ARGS>
\
<%INIT>
return if (not $UserObj);
return if (not $UserObj->Id);
return if (not $UserObj->Privileged);
my $Settings = RT::Extension::TOTPMFA::UserSettings($UserObj);
my $Digits = RT->Config->Get('TOTPMFA_Digits') || 6;
</%INIT>
\
<&| /Widgets/TitleBox, title => loc('Multi-factor authentication'), id => "user-prefs-totpmfa" &>
<& /Elements/TOTPMFATypeSelector, Settings => $Settings &>
<div class="form-row">
<div class="label col-3"><&|/l&>Register with TOTP app</&>:</div>
% my $qrcode_url = RT->Config->Get('WebPath') ."/Helpers/TOTPMFA";
<div class="value col-9"><b><a id="get_totp_qrcode" href="TOTPMFA.png"><&|/l&>Click to view QR code</&></a></b><img id="totp_qrcode"></img></div>
<script type="text/javascript">
jQuery(function () {
jQuery('#get_totp_qrcode').on('click', function () {
jQuery.get(<% $qrcode_url |n,j %>, function (data) {
jQuery('#totp_qrcode').attr("src", "data:image/png;base64," + data);
jQuery('#get_totp_qrcode').hide();
});
return false;
});
});
</script>
</div>
<div class="form-row">
<div class="label col-3"><&|/l&>MFA validation duration</&>:</div>
<div class="value col-9"><input name="TOTPMFADuration" size="8" value="<% $Settings->{'Duration'} %>" /> <&|/l&>(seconds between MFA prompts)</&></div>
</div>
<div class="form-row">
<div class="label col-3"><&|/l&>Yubikey identifier</&>:</div>
<div class="value col-9"><input size="50" name="TOTPMFAYubikey" value="<% $Settings->{'Yubikey'} %>" placeholder="<&|/l&>Enter a Yubikey OTP here to register the device</&>" /></div>
</div>
<div class="form-row">
<div class="label col-12">
<& /Elements/Submit, Label => loc('Save Preferences') &>
</div>
</div>
<div class="form-row">
<div class="value col-12">
<&|/l&>To test your authenticator app without switching on multi-factor authentication, enter a one-time passcode from it here and click on the "Test" button.</&>
</div>
</div>
<div class="form-row">
<div class="label col-3"><&|/l&>One-time passcode</&>:</div>
<div class="value col-9">
<input type="text" name="TestTOTPMFA" autocomplete="off" placeholder="<% loc("[_1] digits or Yubikey OTP", $Digits) %>" size="20" maxlength="45" pattern="(\d{<% $Digits %>,<% $Digits %>}|[a-z]{32,45})" />
<input type="submit" name="TestTOTPMFAButton" value="<&|/l&>Test</&>" />
</div>
</div>
<div class="form-row">
<div class="value col-12">
<&|/l&>If your TOTP app is lost or the QR code is exposed to others, you can generate a new TOTP secret below.</&>
<b><&|/l&>This will invalidate any previously registered secret.</&></b>
</div>
</div>
<div class="form-row">
<div class="value col-12" style="text-align: center; font-weight: bold;">
<a href="#" id="ResetTOTPMFASecretPrompt" style="display: none"><&|/l&>Click here to show the reset button.</&></a>
</div>
</div>
<div class="form-row">
<div class="label col-12">
( run in 0.548 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )