version 1.35.2.6.2.7, 2024/10/08 20:46:49
|
version 1.67, 2024/10/09 15:23:35
|
Line 31 package Apache::switchserver;
|
Line 31 package Apache::switchserver;
|
use strict; |
use strict; |
use Apache::Constants qw(:common :remotehost); |
use Apache::Constants qw(:common :remotehost); |
use Apache::lonnet; |
use Apache::lonnet; |
|
use Apache::loncommon; |
use Digest::MD5 qw(md5_hex); |
use Digest::MD5 qw(md5_hex); |
use CGI::Cookie(); |
use CGI::Cookie(); |
use Apache::lonlocal; |
use Apache::lonlocal; |
Line 65 sub do_redirect {
|
Line 66 sub do_redirect {
|
{'redirect' => [$delay,$url,'',$write_to_opener,1], |
{'redirect' => [$delay,$url,'',$write_to_opener,1], |
'only_body' => $only_body, |
'only_body' => $only_body, |
'switchserver' => 1, |
'switchserver' => 1, |
'links_disabled' => 1, |
'links_disabled' => 1,}); |
'no_inline_link' => 1,}); |
|
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); |
unless ($env{'user.name'} eq 'public' && ($env{'user.domain'} eq 'public')) { |
unless ($env{'user.name'} eq 'public' && ($env{'user.domain'} eq 'public')) { |
Line 158 sub handler {
|
Line 158 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; |
|
} |
} |
} |
} |
} |
} |
} |
Line 187 sub handler {
|
Line 191 sub handler {
|
if (exists($env{$rolekey})) { |
if (exists($env{$rolekey})) { |
my ($start,$end) = split(/\./,$env{$rolekey}); |
my ($start,$end) = split(/\./,$env{$rolekey}); |
unless (($start && $start > $now) || ($end && $end < $now)) { |
unless (($start && $start > $now) || ($end && $end < $now)) { |
$hasrole = $rolekey; |
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) { |
if ($hasrole) { |
$hasrole =~ s/^\Quser.role.\E//; |
$hasrole =~ s/^\Quser.role.\E//; |
Line 276 sub handler {
|
Line 285 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 298 sub handler {
|
Line 307 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 328 sub handler {
|
Line 350 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'))) { |