mirror of
https://github.com/webmin/webmin.git
synced 2026-03-12 05:33:16 +00:00
Compare commits
5 Commits
dev/no-log
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d594e82f0 | ||
|
|
cbd96a4176 | ||
|
|
ed17ade510 | ||
|
|
dc63aa22a5 | ||
|
|
1b9b9ae21f |
@@ -66,14 +66,18 @@ if ($in{'enable'}) {
|
||||
{ 'provider' => $user->{'twofactor_provider'},
|
||||
'id' => $user->{'twofactor_id'} });
|
||||
|
||||
# Show a test form, so the user can validate
|
||||
print &ui_form_start("test_twofactor.cgi");
|
||||
print $text{'twofactor_testdesc'},"<p>\n";
|
||||
print "$text{'twofactor_testfield'} \n",
|
||||
&ui_textbox("test", undef, 12),"\n";
|
||||
print &ui_hidden("user", $in{'user'}) if ($in{'user'});
|
||||
print "<p>\n";
|
||||
print &ui_form_end([ [ undef, $text{'twofactor_test'} ] ]);
|
||||
# Show a test form only when enrolling for yourself
|
||||
if ($user->{'name'} eq $base_remote_user) {
|
||||
print &ui_form_start("test_twofactor.cgi");
|
||||
print &ui_tag('p', $text{'twofactor_testdesc'});
|
||||
print &ui_tag('p', "$text{'twofactor_testfield'}".
|
||||
" ".
|
||||
&ui_textbox("test", undef, 12));
|
||||
print &ui_hidden("user", $in{'user'}) if ($in{'user'});
|
||||
print &ui_tag('p');
|
||||
print &ui_form_end([ [ undef,
|
||||
$text{'twofactor_test'} ] ]);
|
||||
}
|
||||
}
|
||||
|
||||
&ui_print_footer("", $text{'index_return'});
|
||||
|
||||
@@ -918,7 +918,7 @@ if ($has_parted) {
|
||||
elsif ($tag eq "linux-swap") {
|
||||
@rv = ( "swap" );
|
||||
}
|
||||
elsif ($tag eq "NTFS") {
|
||||
elsif ($tag eq "NTFS" || $tag eq "ntfs") {
|
||||
@rv = ( "ntfs" );
|
||||
}
|
||||
elsif ($tag eq "reiserfs") {
|
||||
|
||||
@@ -224,24 +224,57 @@ sub message_twofactor_totp
|
||||
my ($user) = @_;
|
||||
my $name = &get_display_hostname()." (".$user->{'name'}.")";
|
||||
my $str = "otpauth://totp/".$name."?secret=".$user->{'twofactor_id'};
|
||||
my $url;
|
||||
my $qrcode = &ui_tag('p',
|
||||
&text('twofactor_qrcode', "<tt>$user->{'twofactor_id'}</tt>"));
|
||||
if (&can_generate_qr()) {
|
||||
my $url;
|
||||
if (&get_product_name() eq 'usermin') {
|
||||
$url = "qr.cgi?size=6&str=".&urlize($str);
|
||||
$url = "qr.cgi?size=6";
|
||||
}
|
||||
else {
|
||||
$url = "$gconfig{'webprefix'}/webmin/qr.cgi?".
|
||||
"size=6&str=".&urlize($str);
|
||||
$url = "$gconfig{'webprefix'}/webmin/qr.cgi?size=6";
|
||||
}
|
||||
my $id = "twofactor_qr_".int(time())."_".int(rand(1000000));
|
||||
my $img = &ui_tag('img', undef,
|
||||
{ 'id' => $id, 'border' => 0,
|
||||
'style' => 'width:210px; height:210px; '.
|
||||
'border:1px solid #444;',
|
||||
'alt' => 'QR code' });
|
||||
my $id_js = "e_javascript($id);
|
||||
my $url_js = "e_javascript($url);
|
||||
my $str_js = "e_javascript($str);
|
||||
return <<EOF;
|
||||
$qrcode$img
|
||||
<script>
|
||||
(function() {
|
||||
const img = document.getElementById("$id_js"),
|
||||
body = "str=" + encodeURIComponent("$str_js");
|
||||
fetch("$url_js", {
|
||||
method: "POST",
|
||||
body: body
|
||||
}).then(function(response) {
|
||||
if (!response.ok) { return null; }
|
||||
return response.blob();
|
||||
}).then(function(blob) {
|
||||
if (!blob) { return; }
|
||||
const reader = new FileReader();
|
||||
reader.onloadend = function() { img.src = reader.result; };
|
||||
reader.readAsDataURL(blob);
|
||||
}).catch(function() { });
|
||||
})();
|
||||
</script>
|
||||
<p>
|
||||
EOF
|
||||
}
|
||||
else {
|
||||
$url = "https://api.qrserver.com/v1/create-qr-code/?".
|
||||
"size=200x200&data=".&urlize($str);
|
||||
my $url = "https://api.qrserver.com/v1/create-qr-code/?".
|
||||
"size=200x200&data=".&urlize($str);
|
||||
my $img = &ui_tag('img', undef,
|
||||
{ 'src' => $url, 'border' => 0, 'alt' => 'QR code' });
|
||||
return <<EOF;
|
||||
$qrcode$img<p>
|
||||
EOF
|
||||
}
|
||||
my $rv;
|
||||
$rv .= &text('twofactor_qrcode', "<tt>$user->{'twofactor_id'}</tt>")."<p>\n";
|
||||
$rv .= "<img src='$url' border=0><p>\n";
|
||||
return $rv;
|
||||
}
|
||||
|
||||
# validate_twofactor_totp(id, token)
|
||||
|
||||
Reference in New Issue
Block a user