Compare commits

...

5 Commits

Author SHA1 Message Date
Jamie Cameron
1d594e82f0 Sometimes ntfs is in lower case
Some checks are pending
webmin.dev: webmin/webmin / build (push) Waiting to run
https://github.com/webmin/webmin/issues/2635
2026-03-11 22:24:06 -07:00
Jamie Cameron
cbd96a4176 Make code more readable 2026-03-11 16:43:46 -07:00
Ilia Ross
ed17ade510 Fix not to leak 2FA auth secret to logs
https://github.com/webmin/webmin/pull/2638

[no-build]
2026-03-12 01:17:42 +02:00
Ilia Ross
dc63aa22a5 Fix to build HTML nicely
[no-build]
2026-03-12 01:06:49 +02:00
Ilia Ross
1b9b9ae21f Fix to show test form for two-factor only when enrolling for yourself
Some checks failed
webmin.dev: webmin/webmin / build (push) Has been cancelled
2026-03-10 23:31:47 +02:00
3 changed files with 56 additions and 19 deletions

View File

@@ -66,14 +66,18 @@ if ($in{'enable'}) {
{ 'provider' => $user->{'twofactor_provider'}, { 'provider' => $user->{'twofactor_provider'},
'id' => $user->{'twofactor_id'} }); 'id' => $user->{'twofactor_id'} });
# Show a test form, so the user can validate # Show a test form only when enrolling for yourself
print &ui_form_start("test_twofactor.cgi"); if ($user->{'name'} eq $base_remote_user) {
print $text{'twofactor_testdesc'},"<p>\n"; print &ui_form_start("test_twofactor.cgi");
print "$text{'twofactor_testfield'}&nbsp;\n", print &ui_tag('p', $text{'twofactor_testdesc'});
&ui_textbox("test", undef, 12),"\n"; print &ui_tag('p', "$text{'twofactor_testfield'}".
print &ui_hidden("user", $in{'user'}) if ($in{'user'}); "&nbsp;&nbsp;".
print "<p>\n"; &ui_textbox("test", undef, 12));
print &ui_form_end([ [ undef, $text{'twofactor_test'} ] ]); 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'}); &ui_print_footer("", $text{'index_return'});

View File

@@ -918,7 +918,7 @@ if ($has_parted) {
elsif ($tag eq "linux-swap") { elsif ($tag eq "linux-swap") {
@rv = ( "swap" ); @rv = ( "swap" );
} }
elsif ($tag eq "NTFS") { elsif ($tag eq "NTFS" || $tag eq "ntfs") {
@rv = ( "ntfs" ); @rv = ( "ntfs" );
} }
elsif ($tag eq "reiserfs") { elsif ($tag eq "reiserfs") {

View File

@@ -224,24 +224,57 @@ sub message_twofactor_totp
my ($user) = @_; my ($user) = @_;
my $name = &get_display_hostname()." (".$user->{'name'}.")"; my $name = &get_display_hostname()." (".$user->{'name'}.")";
my $str = "otpauth://totp/".$name."?secret=".$user->{'twofactor_id'}; 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()) { if (&can_generate_qr()) {
my $url;
if (&get_product_name() eq 'usermin') { if (&get_product_name() eq 'usermin') {
$url = "qr.cgi?size=6&str=".&urlize($str); $url = "qr.cgi?size=6";
} }
else { else {
$url = "$gconfig{'webprefix'}/webmin/qr.cgi?". $url = "$gconfig{'webprefix'}/webmin/qr.cgi?size=6";
"size=6&str=".&urlize($str);
} }
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 = &quote_javascript($id);
my $url_js = &quote_javascript($url);
my $str_js = &quote_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 { else {
$url = "https://api.qrserver.com/v1/create-qr-code/?". my $url = "https://api.qrserver.com/v1/create-qr-code/?".
"size=200x200&data=".&urlize($str); "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) # validate_twofactor_totp(id, token)