version 1.35.2.6.2.3, 2022/08/30 16:20:17
|
version 1.63, 2022/09/13 12:22:14
|
Line 62 sub do_redirect {
|
Line 62 sub do_redirect {
|
} |
} |
my $start_page = |
my $start_page = |
&Apache::loncommon::start_page('Switching Server ...',undef, |
&Apache::loncommon::start_page('Switching Server ...',undef, |
{'redirect' => [$delay,$url,'',$write_to_opener], |
{'redirect' => [$delay,$url,'',$write_to_opener,1], |
'only_body' => $only_body,}); |
'only_body' => $only_body,}); |
my $end_page = &Apache::loncommon::end_page(); |
my $end_page = &Apache::loncommon::end_page(); |
$r->print($start_page.$extra_text.$end_page); |
$r->print($start_page.$extra_text.$end_page); |
Line 102 sub handler {
|
Line 102 sub handler {
|
if (!defined($handle)) { return FORBIDDEN; } |
if (!defined($handle)) { return FORBIDDEN; } |
|
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
['otherserver','role','origurl','symb','lcssowin']); |
['otherserver','role','origurl','symb','lcssowin','edit']); |
|
|
my $switch_to=&Apache::lonnet::hostname($env{'form.otherserver'}); |
my $switch_to=&Apache::lonnet::hostname($env{'form.otherserver'}); |
if (! $env{'form.otherserver'}) { |
if (! $env{'form.otherserver'}) { |
Line 155 sub handler {
|
Line 155 sub handler {
|
$skip_canhost_check = 1; |
$skip_canhost_check = 1; |
} |
} |
} elsif ($env{'form.role'} =~ m{^[ac]a\./($match_domain)/($match_username)$}) { |
} elsif ($env{'form.role'} =~ m{^[ac]a\./($match_domain)/($match_username)$}) { |
if (&Apache::lonnet::homeserver($2,$1) eq $env{'form.otherserver'}) { |
my ($audom,$auname) = ($1,$2); |
$skip_canhost_check = 1; |
if (&Apache::lonnet::homeserver($auname,$audom) eq $env{'form.otherserver'}) { |
|
if ((&Apache::lonnet::will_trust('othcoau',$env{'user.domain'},$audom)) && |
|
(&Apache::lonnet::will_trust('coaurem',$audom,$env{'user.domain'}))) { |
|
$skip_canhost_check = 1; |
|
} |
} |
} |
} |
} |
} |
} |
} |
} |
|
|
unless ($skip_canhost_check) { |
unless ($skip_canhost_check) { |
my $canhost = 1; |
my $canhost = &Apache::lonnet::can_switchserver($env{'user.domain'},$env{'form.otherserver'}); |
my $uprimary_id = &Apache::lonnet::domain($env{'user.domain'},'primary'); |
unless ($canhost) { |
my $uint_dom = &Apache::lonnet::internet_dom($uprimary_id); |
if (($env{'request.course.id'}) && ($env{'form.symb'} ne '') && |
my @intdoms; |
(&Apache::lonnet::allowed('mdc',$env{'request.course.id'}))) { |
my $internet_names = &Apache::lonnet::get_internet_names($env{'form.otherserver'}); |
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
if (ref($internet_names) eq 'ARRAY') { |
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
@intdoms = @{$internet_names}; |
if (($cdom ne '') && ($cnum ne '') && ($env{'form.role'} =~ m{^([^.]+)\Q./$cdom/$cnum\E$})) { |
} |
my $symb = &Apache::lonnet::symbclean($env{'form.symb'}); |
unless ($uint_dom ne '' && grep(/^\Q$uint_dom\E$/,@intdoms)) { |
my ($map,$idx,$url) = &Apache::lonnet::decode_symb($symb); |
my $serverhomeID = &Apache::lonnet::get_server_homeID($switch_to); |
if (&Apache::lonnet::symbverify($symb,$url)) { |
my $serverhomedom = &Apache::lonnet::host_domain($serverhomeID); |
my $fileloc = &Apache::lonnet::declutter(&Apache::lonnet::filelocation("",$url)); |
my %defdomdefaults = &Apache::lonnet::get_domain_defaults($serverhomedom); |
my $resurl = &Apache::lonnet::clutter($url); |
my %udomdefaults = &Apache::lonnet::get_domain_defaults($env{'user.domain'}); |
if ($resurl =~ m{^/res/($match_domain)/($match_username)/}) { |
my $remoterev = &Apache::lonnet::get_server_loncaparev($env{'user.domain'},$env{'form.otherserver'}); |
my ($audom,$auname) = ($1,$2); |
$canhost = |
if (&Apache::lonnet::homeserver($auname,$audom) eq $env{'form.otherserver'}) { |
&Apache::lonnet::can_host_session($env{'user.domain'}, |
my @possroles = ("user.role.au./$audom/","user.role.ca./$audom/$auname","user.role.aa./$audom/$auname"); |
$env{'form.otherserver'}, |
my $hasrole; |
$remoterev, |
foreach my $rolekey (@possroles) { |
$udomdefaults{'remotesessions'}, |
if (exists($env{$rolekey})) { |
$defdomdefaults{'hostedsessions'}); |
my ($start,$end) = split(/\./,$env{$rolekey}); |
|
unless (($start && $start > $now) || ($end && $end < $now)) { |
|
if ($rolekey eq "user.role.au./$audom/") { |
|
$hasrole = $rolekey; |
|
} elsif ((&Apache::lonnet::will_trust('othcoau',$env{'user.domain'},$audom)) && |
|
(&Apache::lonnet::will_trust('coaurem',$audom,$env{'user.domain'}))) { |
|
$hasrole = $rolekey; |
|
} |
|
} |
|
if ($hasrole) { |
|
$hasrole =~ s/^\Quser.role.\E//; |
|
last; |
|
} |
|
} |
|
} |
|
if ($hasrole) { |
|
$env{'form.role'} = $hasrole; |
|
$env{'form.origurl'} = &Apache::lonnet::deversion($resurl); |
|
$env{'form.origurl'} =~ s{^/res/}{/priv/}; |
|
delete($env{'form.symb'}); |
|
$canhost = 1; |
|
if ($env{'form.edit'}) { |
|
my $ip = &Apache::lonnet::get_requestor_ip($r,REMOTE_NOLOOKUP); |
|
my %info=('ip' => $ip, |
|
'domain' => $env{'user.domain'}, |
|
'username' => $env{'user.name'}, |
|
'home' => $env{'user.home'}, |
|
'role' => $env{'form.role'}, |
|
'server' => $r->dir_config('lonHostID'), |
|
'origurl' => $env{'form.origurl'}); |
|
&Apache::loncommon::content_type($r,'text/html'); |
|
my $token = &Apache::lonnet::tmpput(\%info,$env{'form.otherserver'}); |
|
my $url = $protocol.'://'.$switch_to.'/adm/login?'. |
|
'domain='.$env{'user.domain'}. |
|
'&username='.$env{'user.name'}. |
|
'&token='.$token; |
|
return &do_redirect($r,$url,0); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
} |
} |
unless ($canhost) { return FORBIDDEN; } |
unless ($canhost) { return FORBIDDEN; } |
} |
} |
Line 204 sub handler {
|
Line 251 sub handler {
|
my $logmsg = "Switch Server to $env{'form.otherserver'}"; |
my $logmsg = "Switch Server to $env{'form.otherserver'}"; |
if ($env{'form.role'}) { |
if ($env{'form.role'}) { |
$logmsg .= " with role: $env{'form.role'}"; |
$logmsg .= " with role: $env{'form.role'}"; |
|
} elsif (($env{'form.lti.reqcrs'}) && ($env{'form.lti.reqrole'} eq 'cc')) { |
|
$logmsg .= " to create new LTI course"; |
|
} elsif ($env{'form.lti.selfenrollrole'}) { |
|
$logmsg .= " to selfenroll with role: $env{'form.lti.selfenrollrole'}"; |
} else { |
} else { |
$logmsg .= " (no role)"; |
$logmsg .= " (no role)"; |
} |
} |
Line 231 sub handler {
|
Line 282 sub handler {
|
|
|
# ---------------------------------------------------------------- Get handover |
# ---------------------------------------------------------------- Get handover |
|
|
my ($is_balancer,$setcookie,$newcookieid,$otherbalcookie); |
my ($is_balancer,$setcookie,$newcookieid,$otherbalcookie,$offloadto,$dom_balancers); |
my $only_body = 0; |
my $only_body = 0; |
($is_balancer,undef,$setcookie) = |
($is_balancer,undef,$setcookie,$offloadto,$dom_balancers) = |
&Apache::lonnet::check_loadbalancing($env{'user.name'},$env{'user.domain'},'switchserver'); |
&Apache::lonnet::check_loadbalancing($env{'user.name'},$env{'user.domain'},'switchserver'); |
if ($is_balancer && $setcookie && $env{'form.otherserver'}) { |
if ($is_balancer && $setcookie && $env{'form.otherserver'}) { |
|
|
Line 253 sub handler {
|
Line 304 sub handler {
|
$otherbalcookie = $env{'request.balancercookie'}; |
$otherbalcookie = $env{'request.balancercookie'}; |
} |
} |
|
|
my %info=('ip' => $ip, |
my %info=('ip' => $ip, |
'domain' => $env{'user.domain'}, |
'domain' => $env{'user.domain'}, |
'username' => $env{'user.name'}, |
'username' => $env{'user.name'}, |
'role' => $env{'form.role'}, |
'home' => $env{'user.home'}, |
'server' => $r->dir_config('lonHostID'), |
'role' => $env{'form.role'}, |
'balancer' => $is_balancer); |
'server' => $r->dir_config('lonHostID'), |
|
'balancer' => $is_balancer, |
|
'dom_balancers' => $dom_balancers, |
|
'offloadto' => ''); |
|
if (ref($offloadto) eq 'HASH') { |
|
foreach my $key (keys(%{$offloadto})) { |
|
if (ref($offloadto->{$key}) eq 'ARRAY') { |
|
$info{'offloadto'} .= $key.'='.join(',',@{$offloadto->{$key}}).'&'; |
|
} |
|
} |
|
$info{'offloadto'} =~ s/\&$//; |
|
} elsif (ref($offloadto) eq 'ARRAY') { |
|
$info{'offloadto'} = join(',',@{$offloadto}); |
|
} |
if ($newcookieid) { |
if ($newcookieid) { |
$info{'balcookie'} = $newcookieid; |
$info{'balcookie'} = $newcookieid; |
} elsif ($otherbalcookie) { |
} elsif ($otherbalcookie) { |
Line 277 sub handler {
|
Line 341 sub handler {
|
if (defined($r->dir_config("lonSSOUserLogoutScriptFile_$info{domain}"))) { |
if (defined($r->dir_config("lonSSOUserLogoutScriptFile_$info{domain}"))) { |
if (open(my $fh,'<',$r->dir_config("lonSSOUserLogoutScriptFile_$info{domain}"))) { |
if (open(my $fh,'<',$r->dir_config("lonSSOUserLogoutScriptFile_$info{domain}"))) { |
$ssologoutscript .= join('',<$fh>); |
$ssologoutscript .= join('',<$fh>); |
close($fh); |
close($fh); |
} |
} |
} |
} |
if (defined($r->dir_config('lonSSOUserLogoutScriptFile'))) { |
if (defined($r->dir_config('lonSSOUserLogoutScriptFile'))) { |
Line 303 sub handler {
|
Line 367 sub handler {
|
if ($env{'request.deeplink.login'}) { |
if ($env{'request.deeplink.login'}) { |
$info{'deeplink.login'} = $env{'request.deeplink.login'}; |
$info{'deeplink.login'} = $env{'request.deeplink.login'}; |
} |
} |
|
if ($env{'request.lti.login'}) { |
|
$info{'lti.login'} = $env{'request.lti.login'}; |
|
} |
|
if ($env{'request.lti.uri'}) { |
|
$info{'lti.uri'} = $env{'request.lti.uri'}; |
|
} |
|
if ($env{'request.lti.reqcrs'}) { |
|
$info{'lti.reqcrs'} = $env{'request.lti.reqcrs'}; |
|
} |
|
if ($env{'request.lti.reqrole'}) { |
|
$info{'lti.reqrole'} = $env{'request.lti.reqrole'}; |
|
} |
|
if ($env{'request.lti.selfenrollrole'}) { |
|
$info{'lti.selfenrollrole'} = $env{'request.lti.selfenrollrole'}; |
|
} |
|
if ($env{'request.lti.sourcecrs'}) { |
|
$info{'lti.sourcecrs'} = $env{'request.lti.sourcecrs'}; |
|
} |
|
if ($env{'request.lti.passbackid'}) { |
|
$info{'lti.passbackid'} = $env{'request.lti.passbackid'}; |
|
} |
|
if ($env{'request.lti.passbackurl'}) { |
|
$info{'lti.passbackurl'} = $env{'request.lti.passbackurl'}; |
|
} |
|
if ($env{'request.lti.rosterid'}) { |
|
$info{'lti.rosterid'} = $env{'request.lti.rosterid'}; |
|
} |
|
if ($env{'request.lti.rosterurl'}) { |
|
$info{'lti.rosterurl'} = $env{'request.lti.rosterurl'}; |
|
} |
|
if ($env{'request.lti.target'}) { |
|
$info{'lti.target'} = $env{'request.lti.target'}; |
|
} |
my $token = &Apache::lonnet::tmpput(\%info,$env{'form.otherserver'}); |
my $token = &Apache::lonnet::tmpput(\%info,$env{'form.otherserver'}); |
my @args = ("domain=$env{'user.domain'}", |
my @args = ("domain=$env{'user.domain'}", |
"username=$env{'user.name'}", |
"username=$env{'user.name'}", |