version 1.121.2.22, 2021/12/12 01:48:40
|
version 1.121.2.27, 2024/10/09 17:56:24
|
Line 29
|
Line 29
|
package Apache::lonauth; |
package Apache::lonauth; |
|
|
use strict; |
use strict; |
use LONCAPA; |
use LONCAPA qw(:DEFAULT :match); |
use Apache::Constants qw(:common); |
use Apache::Constants qw(:common); |
use CGI qw(:standard); |
use CGI qw(:standard); |
use Apache::loncommon(); |
use Apache::loncommon(); |
Line 41 use Apache::lonlocal;
|
Line 41 use Apache::lonlocal;
|
use Apache::File(); |
use Apache::File(); |
use HTML::Entities; |
use HTML::Entities; |
use Digest::MD5; |
use Digest::MD5; |
|
use CGI::Cookie(); |
|
|
# ------------------------------------------------------------ Successful login |
# ------------------------------------------------------------ Successful login |
sub success { |
sub success { |
Line 148 sub success {
|
Line 149 sub success {
|
} |
} |
|
|
my $windowinfo=&Apache::lonmenu::open($env{'browser.os'}); |
my $windowinfo=&Apache::lonmenu::open($env{'browser.os'}); |
|
if ($env{'environment.remote'} eq 'on') { |
|
my $checkexempt; |
|
if ($env{'user.loadbalexempt'} eq $r->dir_config('lonHostID')) { |
|
if ($env{'user.loadbalcheck.time'} + 600 > time) { |
|
$checkexempt = 1; |
|
} |
|
} |
|
if ($env{'user.noloadbalance'} eq $r->dir_config('lonHostID')) { |
|
$checkexempt = 1; |
|
} |
|
unless (($checkexempt) || |
|
(($destination =~ m{^/adm/switchserver}) && (!$r->is_initial_req()))) { |
|
my ($is_balancer,$otherserver) = |
|
&Apache::lonnet::check_loadbalancing($env{'user.name'}, |
|
$env{'user.domain'}); |
|
if (($is_balancer) && ($otherserver ne '') && |
|
($otherserver ne $r->dir_config('lonHostID'))) { |
|
$env{'environment.remote'} = 'off'; |
|
} |
|
} |
|
} |
my $startupremote=&Apache::lonmenu::startupremote($destination); |
my $startupremote=&Apache::lonmenu::startupremote($destination); |
my $remoteinfo=&Apache::lonmenu::load_remote_msg($lowerurl); |
my $remoteinfo=&Apache::lonmenu::load_remote_msg($lowerurl); |
my $setflags=&Apache::lonmenu::setflags(); |
my $setflags=&Apache::lonmenu::setflags(); |
Line 250 sub failed {
|
Line 272 sub failed {
|
my $firsturl = &Apache::loncommon::cleanup_html($form->{firsturl}); |
my $firsturl = &Apache::loncommon::cleanup_html($form->{firsturl}); |
if ($firsturl ne '') { |
if ($firsturl ne '') { |
$retry .= (($retry=~/\?/)?'&':'?').'firsturl='.$firsturl; |
$retry .= (($retry=~/\?/)?'&':'?').'firsturl='.$firsturl; |
if ($form->{firsturl} =~ m{^/tiny/$match_domain/\w+$}) { |
|
unless (exists($form->{linkprot})) { |
|
if (exists($form->{linkkey})) { |
|
$retry .= 'linkkey='.$form->{linkkey}; |
|
} |
|
} |
|
} |
|
} |
} |
} |
} |
} elsif ($querystr ne '') { |
} elsif ($querystr ne '') { |
Line 329 sub handler {
|
Line 344 sub handler {
|
$form{'serverid'}); |
$form{'serverid'}); |
unless (($tmpinfo=~/^error/) || ($tmpinfo eq 'con_lost') || |
unless (($tmpinfo=~/^error/) || ($tmpinfo eq 'con_lost') || |
($tmpinfo eq 'no_such_host')) { |
($tmpinfo eq 'no_such_host')) { |
my ($des_key,$firsturl,@rest)=split(/&/,$tmpinfo)l |
my ($des_key,$firsturl,@rest)=split(/&/,$tmpinfo); |
$firsturl = &unescape($firsturl); |
$firsturl = &unescape($firsturl); |
my %info; |
my %info; |
foreach my $item (@rest) { |
foreach my $item (@rest) { |
Line 406 sub handler {
|
Line 421 sub handler {
|
my ($key,$value) = split(/=/,$item); |
my ($key,$value) = split(/=/,$item); |
$form{$key} = &unescape($value); |
$form{$key} = &unescape($value); |
} |
} |
my $upass = &Apache::loncommon::des_decrypt($key,$form{'upass0'}); |
my $upass = &Apache::loncommon::des_decrypt($des_key,$form{'upass0'}); |
|
|
# ---------------------------------------------------------------- Authenticate |
# ---------------------------------------------------------------- Authenticate |
|
|
Line 427 sub handler {
|
Line 442 sub handler {
|
# --------------------------------------------------------------------- Failed? |
# --------------------------------------------------------------------- Failed? |
|
|
if ($authhost eq 'no_host') { |
if ($authhost eq 'no_host') { |
&failed($r,'Username and/or password could not be authenticated.', |
my $pwdverify; |
\%form); |
if (&Apache::lonnet::homeserver($form{'uname'},$form{'udom'}) eq 'no_host') { |
return OK; |
my %possunames = &alternate_unames_check($form{'uname'},$form{'udom'}); |
|
if (keys(%possunames) > 0) { |
|
foreach my $rulematch (keys(%possunames)) { |
|
my $possuname = $possunames{$rulematch}; |
|
if (($possuname ne '') && ($possuname =~ /^$match_username$/)) { |
|
$authhost=Apache::lonnet::authenticate($possuname,$upass, |
|
$form{'udom'},undef, |
|
$clientcancheckhost); |
|
if (($authhost eq 'no_host') || ($authhost eq 'no_account_on_host')) { |
|
next; |
|
} elsif (($authhost ne '') && (&Apache::lonnet::hostname($authhost) ne '')) { |
|
$pwdverify = 1; |
|
&Apache::lonnet::logthis("Authenticated user: $possuname was submitted as: $form{'uname'}"); |
|
$form{'uname'} = $possuname; |
|
last; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
unless ($pwdverify) { |
|
&failed($r,'Username and/or password could not be authenticated.', |
|
\%form); |
|
return OK; |
|
} |
} elsif ($authhost eq 'no_account_on_host') { |
} elsif ($authhost eq 'no_account_on_host') { |
if ($defaultauth) { |
if ($defaultauth) { |
my $domdesc = &Apache::lonnet::domain($form{'udom'},'description'); |
my $domdesc = &Apache::lonnet::domain($form{'udom'},'description'); |
Line 468 sub handler {
|
Line 507 sub handler {
|
$firsturl='/adm/roles'; |
$firsturl='/adm/roles'; |
} |
} |
|
|
my $hosthere; |
my ($hosthere,%sessiondata); |
if ($form{'iptoken'}) { |
if ($form{'iptoken'}) { |
my %sessiondata = &Apache::lonnet::tmpget($form{'iptoken'}); |
%sessiondata = &Apache::lonnet::tmpget($form{'iptoken'}); |
my $delete = &Apache::lonnet::tmpdel($form{'iptoken'}); |
my $delete = &Apache::lonnet::tmpdel($form{'iptoken'}); |
if (($sessiondata{'domain'} eq $form{'udom'}) && |
if (($sessiondata{'domain'} eq $form{'udom'}) && |
($sessiondata{'username'} eq $form{'uname'})) { |
($sessiondata{'username'} eq $form{'uname'})) { |
Line 817 sub loginhelpdisplay {
|
Line 856 sub loginhelpdisplay {
|
return; |
return; |
} |
} |
|
|
|
sub alternate_unames_check { |
|
my ($uname,$udom) = @_; |
|
my %possunames; |
|
my %domdefs = &Apache::lonnet::get_domain_defaults($udom); |
|
if (ref($domdefs{'unamemap_rule'}) eq 'ARRAY') { |
|
if (@{$domdefs{'unamemap_rule'}} > 0) { |
|
%possunames = |
|
&Apache::lonnet::inst_rulecheck($udom,$uname,undef, |
|
'unamemap',$domdefs{'unamemap_rule'}); |
|
} |
|
} |
|
return %possunames; |
|
} |
|
|
1; |
1; |
__END__ |
__END__ |
|
|