version 1.22, 2014/10/05 13:49:11
|
version 1.25.2.2, 2020/05/02 17:35:40
|
Line 37 use Apache::lonlocal;
|
Line 37 use Apache::lonlocal;
|
use Apache::lonlogin(); |
use Apache::lonlogin(); |
|
|
sub goto_login { |
sub goto_login { |
my ($r) = @_; |
my ($r,$domain) = @_; |
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
$r->send_http_header; |
$r->send_http_header; |
|
my $url = '/adm/login'; |
|
if ($domain) { |
|
$url .= '?domain='.$domain; |
|
} |
$r->print(&Apache::loncommon::start_page('Going to login',undef, |
$r->print(&Apache::loncommon::start_page('Going to login',undef, |
{'redirect' => |
{'redirect' => [0,$url],}). |
[0,'/adm/login'],}). |
|
'<h1>'.&mt('One moment please...').'</h1>'. |
'<h1>'.&mt('One moment please...').'</h1>'. |
'<p>'.&mt('Transferring to login page.').'</p>'. |
'<p>'.&mt('Transferring to login page.').'</p>'. |
&Apache::loncommon::end_page()); |
&Apache::loncommon::end_page()); |
Line 114 sub ip_changed {
|
Line 117 sub ip_changed {
|
my $url; |
my $url; |
my $lonhost= $r->dir_config('lonHostID'); |
my $lonhost= $r->dir_config('lonHostID'); |
my $switchto = $lonhost; |
my $switchto = $lonhost; |
if ($rule_in_effect eq 'balancer') { |
if ($rule_in_effect ne 'offloadedto') { |
my $hosthere; |
my $hosthere; |
if ($dataref->{'role'}) { |
my @ids=&Apache::lonnet::current_machine_ids(); |
my ($adom,$aname); |
unless ($rule_in_effect eq 'balancer') { |
if ($dataref->{'role'} =~ m{^au\./($match_domain)/$}) { |
if (grep(/^\Q$rule_in_effect\E$/,@ids)) { |
$adom = $1; |
$hosthere = 1; |
$aname = $dataref->{'username'}; |
} |
} elsif ($dataref->{'role'} =~ m{^(?:ca|aa)\./($match_domain)/($match_username)$}) { |
} |
$adom = $1; |
unless ($hosthere) { |
$aname = $2; |
if ($dataref->{'role'}) { |
} |
my ($adom,$aname); |
if ($adom ne '' && $aname ne '') { |
if ($dataref->{'role'} =~ m{^au\./($match_domain)/$}) { |
my $ahome = &Apache::lonnet::homeserver($aname,$adom); |
$adom = $1; |
unless ($ahome eq 'no_host') { |
$aname = $dataref->{'username'}; |
my @ids=&Apache::lonnet::current_machine_ids(); |
} elsif ($dataref->{'role'} =~ m{^(?:ca|aa)\./($match_domain)/($match_username)$}) { |
if ($ahome && grep(/^\Q$ahome\E$/,@ids)) { |
$adom = $1; |
$hosthere = 1; |
$aname = $2; |
|
} |
|
if ($adom ne '' && $aname ne '') { |
|
my $ahome = &Apache::lonnet::homeserver($aname,$adom); |
|
unless ($ahome eq 'no_host') { |
|
if ($ahome && grep(/^\Q$ahome\E$/,@ids)) { |
|
$hosthere = 1; |
|
} |
} |
} |
} |
} |
} |
} |
} |
} |
unless ($hosthere) { |
unless ($hosthere) { |
my $hostname = &Apache::lonnet::hostname($dataref->{'server'}); |
my $hostname; |
|
if ($rule_in_effect eq 'balancer') { |
|
$hostname = &Apache::lonnet::hostname($dataref->{'server'}); |
|
if ($hostname) { |
|
$switchto = $dataref->{'server'}; |
|
} |
|
} else { |
|
$hostname = &Apache::lonnet::hostname($rule_in_effect); |
|
if ($hostname) { |
|
$switchto = $rule_in_effect; |
|
} |
|
} |
if ($hostname) { |
if ($hostname) { |
$switchto = $dataref->{'server'}; |
|
my $protocol = $Apache::lonnet::protocol{$switchto}; |
my $protocol = $Apache::lonnet::protocol{$switchto}; |
$protocol = 'http' if ($protocol ne 'https'); |
$protocol = 'http' if ($protocol ne 'https'); |
$url = $protocol.'://'.$hostname; |
$url = $protocol.'://'.$hostname; |
$message .= '<br />'. |
if ($rule_in_effect eq 'balancer') { |
&mt('As a result, your LON-CAPA session is being redirected to the server where you originally logged in.'); |
$message .= '<br />'. |
|
&mt('As a result, your LON-CAPA session is being redirected to the server where you originally logged in.'); |
|
} else { |
|
$message .= '<br />'. |
|
&mt('As a result, your LON-CAPA session is being redirected.'); |
|
} |
|
} |
|
} |
|
unless ($hosthere) { |
|
if (($dataref->{'balancer'}) && ($dataref->{'balcookie'})) { |
|
&Apache::lonnet::delbalcookie($dataref->{'balcookie'},$dataref->{'balancer'}); |
} |
} |
} |
} |
} |
} |
Line 151 sub ip_changed {
|
Line 181 sub ip_changed {
|
$url .= '/adm/roles'; |
$url .= '/adm/roles'; |
} else { |
} else { |
$url .= '/adm/login'; |
$url .= '/adm/login'; |
|
if ($udom) { |
|
$url .= '?domain='.$udom; |
|
} |
$message .= '<br />'.&mt('You will need to provide your password one more time.'); |
$message .= '<br />'.&mt('You will need to provide your password one more time.'); |
} |
} |
my %info= ( |
my %info= ( |
'domain' => $dataref->{'domain'}, |
'domain' => $udom, |
'username' => $dataref->{'username'}, |
'username' => $dataref->{'username'}, |
'role' => $dataref->{'role'}, |
'role' => $dataref->{'role'}, |
'sessionserver' => $lonhost, |
'sessionserver' => $lonhost, |
Line 167 sub ip_changed {
|
Line 200 sub ip_changed {
|
} |
} |
my $iptoken = &Apache::lonnet::tmpput(\%info,$switchto); |
my $iptoken = &Apache::lonnet::tmpput(\%info,$switchto); |
unless ($iptoken eq 'conlost') { |
unless ($iptoken eq 'conlost') { |
$url .= '?iptoken='.$iptoken; |
$url .= ($url =~ /\?/) ? '&' : '?'; |
|
$url .= 'iptoken='.$iptoken; |
} |
} |
$r->print(&Apache::loncommon::start_page($title,undef, |
$r->print(&Apache::loncommon::start_page($title,undef, |
{'redirect' => |
{'redirect' => |
Line 201 sub handler {
|
Line 235 sub handler {
|
return &goto_login($r); |
return &goto_login($r); |
} |
} |
if ($data{'ip'} ne $ENV{'REMOTE_ADDR'}) { |
if ($data{'ip'} ne $ENV{'REMOTE_ADDR'}) { |
|
&Apache::lonnet::logthis('IP change when session migration requested -- was: '. |
|
$data{'ip'}.'; now: '.$ENV{'REMOTE_ADDR'}.' for '.$data{'username'}.':'.$data{'domain'}); |
return &ip_changed($r,$data{'domain'},$data{'server'},\%data); |
return &ip_changed($r,$data{'domain'},$data{'server'},\%data); |
} |
} |
|
|
&Apache::lonnet::logthis("Allowing access for $data{'username'}:$data{'domain'} to $data{'role'}"); |
&Apache::lonnet::logthis("Allowing access for $data{'username'}:$data{'domain'} to $data{'role'}"); |
my $home=&Apache::lonnet::homeserver($data{'username'},$data{'domain'}); |
my $home=&Apache::lonnet::homeserver($data{'username'},$data{'domain'}); |
if ($home =~ /(con_lost|no_such_host)/) { return &goto_login($r); } |
my $udom; |
|
if (&Apache::lonnet::domain($data{'domain'})) { |
|
$udom=$data{'domain'}; |
|
} |
|
if ($home =~ /(con_lost|no_such_host)/) { return &goto_login($r,$udom); } |
|
|
my $extra_env = &sso_check(\%data); |
my $extra_env = &sso_check(\%data); |
|
if (($data{'balancer'}) && ($data{'server'}) && ($data{'balcookie'})) { |
|
if (ref($extra_env) eq 'HASH') { |
|
$extra_env->{'request.balancercookie'} = $data{'server'}.':'.$data{'balcookie'}; |
|
} else { |
|
$extra_env = { 'request.balancercookie' => $data{'server'}.':'.$data{'balcookie'} }; |
|
} |
|
} |
|
|
my %form; |
my (%form,$cid); |
if ($data{'symb'} ne '') { |
if ($data{'symb'} ne '') { |
$form{'symb'} = $data{'symb'}; |
$form{'symb'} = $data{'symb'}; |
} |
} |
if ($data{'iptoken'} ne '') { |
if ($data{'iptoken'} ne '') { |
$form{'iptoken'} = $data{'iptoken'}; |
$form{'iptoken'} = $data{'iptoken'}; |
} |
} |
|
if ($data{'noloadbalance'} ne '') { |
if (!$data{'role'}) { |
$form{'noloadbalance'} = $data{'noloadbalance'}; |
|
} |
|
if ($data{'role'}) { |
|
if ($data{'role'} =~ m{\./($match_domain)/($match_courseid)(?:/\w+|$)}) { |
|
unless (&Apache::lonnet::homeserver($2,$1) eq 'no_host') { |
|
$cid = $1.'_'.$2; |
|
} |
|
} |
|
} else { |
my $handle = &Apache::lonnet::check_for_valid_session($r); |
my $handle = &Apache::lonnet::check_for_valid_session($r); |
if ($handle) { |
if ($handle) { |
&Apache::lonnet::transfer_profile_to_env($r->dir_config('lonIDsDir'), |
&Apache::lonnet::transfer_profile_to_env($r->dir_config('lonIDsDir'), |
Line 248 sub handler {
|
Line 303 sub handler {
|
$next_url .= '&orgurl='.&escape($data{'origurl'}); |
$next_url .= '&orgurl='.&escape($data{'origurl'}); |
} |
} |
&Apache::lonauth::success($r,$data{'username'},$data{'domain'},$home, |
&Apache::lonauth::success($r,$data{'username'},$data{'domain'},$home, |
$next_url,$extra_env,\%form); |
$next_url,$extra_env,\%form,$cid); |
return OK; |
return OK; |
} |
} |
|
|