version 1.174, 2018/11/24 16:19:04
|
version 1.176, 2018/12/05 03:29:05
|
Line 37 use Apache::lonauth();
|
Line 37 use Apache::lonauth();
|
use Apache::lonlocal;
|
use Apache::lonlocal;
|
use Apache::migrateuser();
|
use Apache::migrateuser();
|
use lib '/home/httpd/lib/perl/';
|
use lib '/home/httpd/lib/perl/';
|
use LONCAPA;
|
use LONCAPA qw(:DEFAULT :match);
|
use CGI::Cookie();
|
use CGI::Cookie();
|
|
|
sub handler {
|
sub handler {
|
Line 47 sub handler {
|
Line 47 sub handler {
|
(join('&',$ENV{'QUERY_STRING'},$env{'request.querystring'},
|
(join('&',$ENV{'QUERY_STRING'},$env{'request.querystring'},
|
$ENV{'REDIRECT_QUERY_STRING'}),
|
$ENV{'REDIRECT_QUERY_STRING'}),
|
['interface','username','domain','firsturl','localpath','localres',
|
['interface','username','domain','firsturl','localpath','localres',
|
'token','role','symb','iptoken']);
|
'token','role','symb','iptoken','btoken']);
|
if (!defined($env{'form.firsturl'})) {
|
if (!defined($env{'form.firsturl'})) {
|
&Apache::lonacc::get_posted_cgi($r,['firsturl']);
|
&Apache::lonacc::get_posted_cgi($r,['firsturl']);
|
}
|
}
|
Line 64 sub handler {
|
Line 64 sub handler {
|
|
|
# For "public user" - remove any exising "public" cookie, as user really wants to log-in
|
# For "public user" - remove any exising "public" cookie, as user really wants to log-in
|
my ($handle,$lonidsdir,$expirepub,$userdom);
|
my ($handle,$lonidsdir,$expirepub,$userdom);
|
|
$lonidsdir=$r->dir_config('lonIDsDir');
|
unless ($r->header_only) {
|
unless ($r->header_only) {
|
$handle = &Apache::lonnet::check_for_valid_session($r,'lonID',undef,\$userdom);
|
$handle = &Apache::lonnet::check_for_valid_session($r,'lonID',undef,\$userdom);
|
if ($handle ne '') {
|
if ($handle ne '') {
|
$lonidsdir=$r->dir_config('lonIDsDir');
|
|
if ($handle=~/^publicuser\_/) {
|
if ($handle=~/^publicuser\_/) {
|
unlink($r->dir_config('lonIDsDir')."/$handle.id");
|
unlink($r->dir_config('lonIDsDir')."/$handle.id");
|
undef($handle);
|
undef($handle);
|
Line 106 sub handler {
|
Line 106 sub handler {
|
return OK;
|
return OK;
|
}
|
}
|
|
|
|
my $lonhost = $r->dir_config('lonHostID');
|
$env{'form.firsturl'} =~ s/(`)/'/g;
|
$env{'form.firsturl'} =~ s/(`)/'/g;
|
|
|
# Check if browser sent a LON-CAPA load balancer cookie (and this is a balancer)
|
# Check if browser sent a LON-CAPA load balancer cookie (and this is a balancer)
|
Line 120 sub handler {
|
Line 121 sub handler {
|
if ($env{'form.firsturl'} ne '') {
|
if ($env{'form.firsturl'} ne '') {
|
$dest = $env{'form.firsturl'};
|
$dest = $env{'form.firsturl'};
|
}
|
}
|
|
my %info = (
|
|
balcookie => $lonhost.':'.$balancer_cookie,
|
|
);
|
|
my $balancer_token = &Apache::lonnet::tmpput(\%info,$found_server);
|
|
if ($balancer_token) {
|
|
$dest .= (($dest=~/\?/)?'&;':'?') . 'btoken='.$balancer_token;
|
|
}
|
my $url = $protocol.'://'.$hostname.$dest;
|
my $url = $protocol.'://'.$hostname.$dest;
|
my $start_page =
|
my $start_page =
|
&Apache::loncommon::start_page('Switching Server ...',undef,
|
&Apache::loncommon::start_page('Switching Server ...',undef,
|
Line 131 sub handler {
|
Line 139 sub handler {
|
}
|
}
|
|
|
#
|
#
|
|
# Check if a LON-CAPA load balancer sent user here because user's browser sent
|
|
# it a balancer cookie for an active session on this server.
|
|
#
|
|
|
|
my $balcookie;
|
|
if ($env{'form.btoken'}) {
|
|
my %info = &Apache::lonnet::tmpget($env{'form.btoken'});
|
|
$balcookie = $info{'balcookie'};
|
|
&Apache::lonnet::tmpdel($env{'form.btoken'});
|
|
delete($env{'form.btoken'});
|
|
}
|
|
|
|
#
|
# If browser sent an old cookie for which the session file had been removed
|
# If browser sent an old cookie for which the session file had been removed
|
# check if configuration for user's domain has a portal URL set. If so
|
# check if configuration for user's domain has a portal URL set. If so
|
# switch user's log-in to the portal.
|
# switch user's log-in to the portal.
|
Line 156 sub handler {
|
Line 177 sub handler {
|
&Apache::loncommon::end_page();
|
&Apache::loncommon::end_page();
|
my $dest = '/adm/roles';
|
my $dest = '/adm/roles';
|
if ($env{'form.firsturl'} ne '') {
|
if ($env{'form.firsturl'} ne '') {
|
$dest = $env{'form.firsturl'};
|
$dest = $env{'form.firsturl'};
|
}
|
}
|
$r->print(
|
$r->print(
|
$start_page
|
$start_page
|
Line 194 sub handler {
|
Line 215 sub handler {
|
my $iconpath=
|
my $iconpath=
|
&Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
|
&Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
|
|
|
my $lonhost = $r->dir_config('lonHostID');
|
|
my $domain = &Apache::lonnet::default_login_domain();
|
my $domain = &Apache::lonnet::default_login_domain();
|
my $defdom = $domain;
|
my $defdom = $domain;
|
if ($lonhost ne '') {
|
if ($lonhost ne '') {
|
unless ($sessiondata{'sessionserver'}) {
|
unless ($sessiondata{'sessionserver'}) {
|
my $redirect = &check_loginvia($domain,$lonhost);
|
my $redirect = &check_loginvia($domain,$lonhost,$lonidsdir,$balcookie);
|
if ($redirect) {
|
if ($redirect) {
|
$r->print($redirect);
|
$r->print($redirect);
|
return OK;
|
return OK;
|
Line 208 sub handler {
|
Line 228 sub handler {
|
}
|
}
|
|
|
if (($sessiondata{'domain'}) &&
|
if (($sessiondata{'domain'}) &&
|
(&Apache::lonnet::domain($env{'form.domain'},'description'))) {
|
(&Apache::lonnet::domain($sessiondata{'domain'},'description'))) {
|
$domain=$sessiondata{'domain'};
|
$domain=$sessiondata{'domain'};
|
} elsif (($env{'form.domain'}) &&
|
} elsif (($env{'form.domain'}) &&
|
(&Apache::lonnet::domain($env{'form.domain'},'description'))) {
|
(&Apache::lonnet::domain($env{'form.domain'},'description'))) {
|
Line 707 ENDDOCUMENT
|
Line 727 ENDDOCUMENT
|
}
|
}
|
|
|
sub check_loginvia {
|
sub check_loginvia {
|
my ($domain,$lonhost) = @_;
|
my ($domain,$lonhost,$lonidsdir,$balcookie) = @_;
|
if ($domain eq '' || $lonhost eq '') {
|
if ($domain eq '' || $lonhost eq '' || $lonidsdir eq '') {
|
return;
|
return;
|
}
|
}
|
my %domconfhash = &Apache::loncommon::get_domainconf($domain);
|
my %domconfhash = &Apache::loncommon::get_domainconf($domain);
|
Line 737 sub check_loginvia {
|
Line 757 sub check_loginvia {
|
}
|
}
|
if ($newhost ne $lonhost) {
|
if ($newhost ne $lonhost) {
|
if (&Apache::lonnet::hostname($newhost) ne '') {
|
if (&Apache::lonnet::hostname($newhost) ne '') {
|
|
if ($balcookie) {
|
|
my ($balancer,$cookie) = split(/:/,$balcookie);
|
|
if ($cookie =~ /^($match_domain)_($match_username)_([a-f0-9]+)$/) {
|
|
my ($udom,$uname,$cookieid) = ($1,$2,$3);
|
|
unless (&Apache::lonnet::delbalcookie($cookie,$balancer) eq 'ok') {
|
|
if ((-d $lonidsdir) && (opendir(my $dh,$lonidsdir))) {
|
|
while (my $filename=readdir($dh)) {
|
|
if ($filename=~/^(\Q$uname\E_\d+_\Q$udom\E_$match_lonid)\.id$/) {
|
|
my $handle = $1;
|
|
my %hash =
|
|
&Apache::lonnet::get_sessionfile_vars($handle,$lonidsdir,
|
|
['request.balancercookie',
|
|
'user.linkedenv']);
|
|
if ($hash{'request.balancercookie'} eq "$balancer:$cookieid") {
|
|
if (unlink("$lonidsdir/$filename")) {
|
|
if (($hash{'user.linkedenv'} =~ /^[a-f0-9]+_linked$/) &&
|
|
(-l "$lonidsdir/$hash{'user.linkedenv'}.id") &&
|
|
(readlink("$lonidsdir/$hash{'user.linkedenv'}.id") eq "$lonidsdir/$filename")) {
|
|
unlink("$lonidsdir/$hash{'user.linkedenv'}.id");
|
|
}
|
|
}
|
|
}
|
|
last;
|
|
}
|
|
}
|
|
closedir($dh);
|
|
}
|
|
}
|
|
}
|
|
}
|
$output = &redirect_page($newhost,$path);
|
$output = &redirect_page($newhost,$path);
|
}
|
}
|
}
|
}
|