mirror of
https://github.com/webmin/webmin.git
synced 2026-08-22 23:10:34 +01:00
Fix to add login lib with reusable login warning
https://github.com/webmin/webmin/pull/2812#discussion_r3744668133
This commit is contained in:
27
login-lib.pl
Executable file
27
login-lib.pl
Executable file
@@ -0,0 +1,27 @@
|
||||
# login-lib.pl
|
||||
# Common functions for the built-in login pages.
|
||||
|
||||
# get_login_http_warning(&miniserv-config)
|
||||
# Returns the insecure-login warning HTML, or undef if none is needed
|
||||
sub get_login_http_warning
|
||||
{
|
||||
my ($miniserv) = @_;
|
||||
return undef if ($ENV{'HTTPS'} eq 'ON' ||
|
||||
(!$miniserv->{'ssl'} && $miniserv->{'no_ssl_warn'}));
|
||||
|
||||
my $warning = "⚠ $text{'login_notsecure'}";
|
||||
my $description = $text{'login_notsecure_http_desc'};
|
||||
if ($miniserv->{'ssl'}) {
|
||||
$warning = ui_tag('a', $warning,
|
||||
{ 'href' => "javascript:void(0);",
|
||||
'class' => 'inherit-color',
|
||||
'onclick' => "window.location.href = ".
|
||||
"window.location.href.replace(/^http:/, 'https:'); return false;",
|
||||
});
|
||||
$description = $text{'login_notsecure_desc'};
|
||||
}
|
||||
return ui_tag('span', $warning,
|
||||
{ class => 'not-secure', title => $description });
|
||||
}
|
||||
|
||||
1;
|
||||
@@ -40,7 +40,7 @@ $vers || usage();
|
||||
"webmin-systemd", "webmin-init", "webmin-daemon",
|
||||
"config-openbsd",
|
||||
"config-macos", "LICENCE",
|
||||
"session_login.cgi", "acl_security.pl",
|
||||
"session_login.cgi", "login-lib.pl", "acl_security.pl",
|
||||
"defaultacl", "rpc.cgi", "date_chooser.cgi",
|
||||
"safeacl", "install-module.pl", "LICENCE.ja",
|
||||
"favicon.ico", "config-netbsd", "fastrpc.cgi",
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
BEGIN { push(@INC, "."); };
|
||||
use WebminCore;
|
||||
require './login-lib.pl';
|
||||
|
||||
$pragma_no_cache = 1;
|
||||
#$ENV{'MINISERV_INTERNAL'} || die "Can only be called by miniserv.pl";
|
||||
@@ -73,23 +74,7 @@ print "$text{'pam_prefix'}\n";
|
||||
print &ui_form_start("@{[&get_webprefix()]}/pam_login.cgi", "post");
|
||||
print &ui_hidden("cid", $in{'cid'});
|
||||
|
||||
my $not_secure;
|
||||
if ($ENV{'HTTPS'} ne 'ON' &&
|
||||
($miniserv{'ssl'} || !$miniserv{'no_ssl_warn'})) {
|
||||
my $warning = "⚠ $text{'login_notsecure'}";
|
||||
my $description = $text{'login_notsecure_http_desc'};
|
||||
if ($miniserv{'ssl'}) {
|
||||
$warning = ui_tag('a', $warning,
|
||||
{ 'href' => "javascript:void(0);",
|
||||
'class' => 'inherit-color',
|
||||
'onclick' => "window.location.href = ".
|
||||
"window.location.href.replace(/^http:/, 'https:'); return false;",
|
||||
});
|
||||
$description = $text{'login_notsecure_desc'};
|
||||
}
|
||||
$not_secure = ui_tag('span', $warning,
|
||||
{ class => 'not-secure', title => $description });
|
||||
}
|
||||
my $not_secure = &get_login_http_warning(\%miniserv);
|
||||
|
||||
print &ui_table_start($text{'pam_header'} . $not_secure,
|
||||
"width=40% class='loginform'", 2);
|
||||
@@ -159,4 +144,3 @@ EOF
|
||||
}
|
||||
|
||||
&ui_print_footer();
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
BEGIN { push(@INC, "."); };
|
||||
use WebminCore;
|
||||
require './login-lib.pl';
|
||||
|
||||
$pragma_no_cache = 1;
|
||||
#$ENV{'MINISERV_INTERNAL'} || die "Can only be called by miniserv.pl";
|
||||
@@ -93,23 +94,7 @@ print "$text{'session_prefix'}\n";
|
||||
print &ui_form_start("@{[&get_webprefix()]}/session_login.cgi", "post");
|
||||
print &ui_hidden("page", $in{'page'});
|
||||
|
||||
my $not_secure;
|
||||
if ($ENV{'HTTPS'} ne 'ON' &&
|
||||
($miniserv{'ssl'} || !$miniserv{'no_ssl_warn'})) {
|
||||
my $warning = "⚠ $text{'login_notsecure'}";
|
||||
my $description = $text{'login_notsecure_http_desc'};
|
||||
if ($miniserv{'ssl'}) {
|
||||
$warning = ui_tag('a', $warning,
|
||||
{ 'href' => "javascript:void(0);",
|
||||
'class' => 'inherit-color',
|
||||
'onclick' => "window.location.href = ".
|
||||
"window.location.href.replace(/^http:/, 'https:'); return false;",
|
||||
});
|
||||
$description = $text{'login_notsecure_desc'};
|
||||
}
|
||||
$not_secure = ui_tag('span', $warning,
|
||||
{ class => 'not-secure', title => $description });
|
||||
}
|
||||
my $not_secure = &get_login_http_warning(\%miniserv);
|
||||
|
||||
print &ui_table_start($text{'session_header'} . $not_secure,
|
||||
"width=40% class='loginform'", 2);
|
||||
|
||||
Reference in New Issue
Block a user