version 1.57, 2022/02/06 21:37:04
|
version 1.66, 2022/09/17 23:38:50
|
Line 42 use CGI::Cookie;
|
Line 42 use CGI::Cookie;
|
|
|
sub goto_login { |
sub goto_login { |
my ($r,$domain,$data) = @_; |
my ($r,$domain,$data) = @_; |
|
my $write_to_opener; |
|
if (ref($data) eq 'HASH') { |
|
$write_to_opener = $data->{'lcssowin'}; |
|
} |
if ((ref($data) eq 'HASH') && ($data->{'lti.login'})) { |
if ((ref($data) eq 'HASH') && ($data->{'lti.login'})) { |
&Apache::ltiauth::invalid_request($r,'22'); |
&Apache::ltiauth::invalid_request($r,'22'); |
} else { |
} else { |
Line 52 sub goto_login {
|
Line 56 sub goto_login {
|
$url .= '?domain='.$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' => [0,$url],}). |
{'redirect' => [0,$url,'',$write_to_opener],}). |
'<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 285 sub ip_changed {
|
Line 289 sub ip_changed {
|
'username' => $dataref->{'username'}, |
'username' => $dataref->{'username'}, |
'sessionserver' => $lonhost, |
'sessionserver' => $lonhost, |
); |
); |
my @names = ('origurl','symb','role','linkprot','linkkey'); |
my @names = ('origurl','symb','role','linkprotuser','linkprotexit','linkprot','linkkey'); |
foreach my $name (@names) { |
foreach my $name (@names) { |
if ($dataref->{$name} ne '') { |
if ($dataref->{$name} ne '') { |
$info{$name} = $dataref->{$name}; |
$info{$name} = $dataref->{$name}; |
} |
} |
} |
} |
|
if ($info{'origurl'} eq '/adm/email') { |
|
if (($dataref->{'display'}) && ($dataref->{'mailrecip'})) { |
|
if (&unescape($dataref->{'mailrecip'}) eq $dataref->{'username'}.':'.$dataref->{'domain'}) { |
|
$info{'display'} = $dataref->{'display'}; |
|
$info{'mailrecip'} = $dataref->{'mailrecip'}; |
|
} |
|
} |
|
} |
my $iptoken = &Apache::lonnet::tmpput(\%info,$switchto,'link'); |
my $iptoken = &Apache::lonnet::tmpput(\%info,$switchto,'link'); |
unless ($iptoken eq 'conlost') { |
unless ($iptoken eq 'conlost') { |
$url .= (($url =~ /\?/) ? '&' : '?') . 'iptoken='.$iptoken; |
$url .= (($url =~ /\?/) ? '&' : '?') . 'iptoken='.$iptoken; |
} |
} |
$r->print(&Apache::loncommon::start_page($title,undef, |
$r->print(&Apache::loncommon::start_page($title,undef, |
{'redirect' => |
{'redirect' => |
[2,$url],}). |
[2,$url,'',$dataref->{'lcssowin'}],}). |
'<h1>'.&mt('One moment please...').'</h1>'. |
'<h1>'.&mt('One moment please...').'</h1>'. |
'<p class="LC_warning">'.$message.'</p>'. |
'<p class="LC_warning">'.$message.'</p>'. |
&Apache::loncommon::end_page()); |
&Apache::loncommon::end_page()); |
Line 308 sub ip_changed {
|
Line 320 sub ip_changed {
|
} |
} |
|
|
sub logout { |
sub logout { |
my ($r,$ip,$handle,$data,$lti_env) = @_; |
my ($r,$ip,$handle,$data,$lti_env,$linkprot_info) = @_; |
my $lonidsdir=$r->dir_config('lonIDsDir'); |
my $lonidsdir=$r->dir_config('lonIDsDir'); |
if (unlink("$lonidsdir/$handle.id")) { |
if (unlink("$lonidsdir/$handle.id")) { |
if (($env{'user.linkedenv'} =~ /^[a-f0-9]+_linked$/) && |
if (($env{'user.linkedenv'} =~ /^[a-f0-9]+_linked$/) && |
Line 335 sub logout {
|
Line 347 sub logout {
|
-expires => '-10y',); |
-expires => '-10y',); |
$r->headers_out->add('Set-cookie' => $c); |
$r->headers_out->add('Set-cookie' => $c); |
} |
} |
my (%info,%user_info,%lti_info); |
|
if (ref($lti_env) eq 'HASH') { |
|
foreach my $key (sort(keys(%{$lti_env}))) { |
|
if ($key =~ /^request\.(.+)$/) { |
|
$lti_info{$1} = $lti_env->{$key}; |
|
} |
|
} |
|
} |
|
my $lonhost = $r->dir_config('lonHostID'); |
my $lonhost = $r->dir_config('lonHostID'); |
|
my ($url,$token,$delay,$write_to_opener,%info,%user_info); |
if (ref($data) eq 'HASH') { |
if (ref($data) eq 'HASH') { |
%user_info=('ip' => $ip, |
%user_info=('ip' => $ip, |
'domain' => $data->{'domain'}, |
'domain' => $data->{'domain'}, |
Line 353 sub logout {
|
Line 358 sub logout {
|
'origurl' => $data->{'origurl'}, |
'origurl' => $data->{'origurl'}, |
'symb' => $data->{'symb'}, |
'symb' => $data->{'symb'}, |
'server' => $lonhost); |
'server' => $lonhost); |
|
$write_to_opener = $data->{'lcssowin'}; |
|
} |
|
$delay = 0.1; |
|
if (ref($linkprot_info) eq 'HASH') { |
|
if ($linkprot_info->{'linkprotuser'} ne '') { |
|
$token = &Apache::lonnet::tmpput($linkprot_info,$lonhost); |
|
$url = '/adm/login?ltoken='.$token; |
|
} else { |
|
foreach my $key (keys(%user_info)) { |
|
if ($user_info{$key} eq '') { |
|
delete($user_info{$key}); |
|
} |
|
} |
|
%info = (%user_info,%{$linkprot_info}); |
|
$token = &Apache::lonnet::tmpput(\%info,$lonhost); |
|
$url = '/adm/migrateuser?token='.$token; |
|
} |
|
$delay = 0; |
|
} else { |
|
my %lti_info; |
|
if (ref($lti_env) eq 'HASH') { |
|
foreach my $key (sort(keys(%{$lti_env}))) { |
|
if ($key =~ /^request\.(.+)$/) { |
|
$lti_info{$1} = $lti_env->{$key}; |
|
} |
|
} |
|
} |
|
%info = (%user_info,%lti_info); |
|
$token = &Apache::lonnet::tmpput(\%info,$lonhost); |
|
$url = '/adm/migrateuser?token='.$token; |
} |
} |
%info = (%user_info,%lti_info); |
|
my $token = &Apache::lonnet::tmpput(\%info,$lonhost); |
|
my $url = '/adm/migrateuser?token='.$token; |
|
$r->send_http_header; |
$r->send_http_header; |
$r->print( |
$r->print( |
&Apache::loncommon::start_page('Updating Session ...',undef, |
&Apache::loncommon::start_page('Updating Session ...',undef, |
{'redirect' => [0.1,$url], |
{'redirect' => [$delay,$url,'',$write_to_opener], |
'only_body' => 1,}). |
'only_body' => 1,}). |
&Apache::loncommon::end_page()); |
&Apache::loncommon::end_page()); |
if ($env{'request.balancercookie'}) { |
if ($env{'request.balancercookie'}) { |
Line 722 sub handler {
|
Line 754 sub handler {
|
$handle); |
$handle); |
my $checklaunch; |
my $checklaunch; |
if ($data{'origurl'} =~ m{^/tiny/$match_domain/\w+$}) { |
if ($data{'origurl'} =~ m{^/tiny/$match_domain/\w+$}) { |
if ($env{'request.linkprot'} ne '') { |
unless ($env{'request.linkprot'} eq $data{'linkprot'}) { |
unless ($env{'request.linkprot'} eq $data{'linkprot'}) { |
$checklaunch = 1; |
$checklaunch = 1; |
|
} |
|
} |
|
if ($env{'request.linkkey'} ne '') { |
|
unless ($env{'request.linkkey'} eq $data{'linkkey'}) { |
|
$checklaunch = 1; |
|
} |
|
} |
} |
if ($env{'request.deeplink.login'}) { |
unless ($env{'request.linkprotexit'} eq $data{'linkprotexit'}) { |
unless ($env{'request.deeplink.login'} eq $data{'deeplink.login'}) { |
$checklaunch = 1; |
$checklaunch = 1; |
} |
} |
unless ($env{'request.linkkey'} eq $data{'linkkey'}) { |
|
$checklaunch = 1; |
|
} |
|
unless ($env{'request.deeplink.login'} eq $data{'deeplink.login'}) { |
|
$checklaunch = 1; |
} |
} |
} |
} |
if ($data{'linkprot'} ne '') { |
if ($data{'linkprot'} ne '') { |
if (($env{'user.name'} ne $data{'username'}) || |
if (($env{'user.name'} ne $data{'username'}) || |
($env{'user.domain'} ne $data{'domain'})) { |
($env{'user.domain'} ne $data{'domain'})) { |
my %linkprot_env; |
my %linkprot_env; |
foreach my $item ('linkprot','deeplink.login') { |
foreach my $item ('linkprot','linkprotexit','deeplink.login') { |
if ($data{$item}) { |
if ($data{$item}) { |
$linkprot_env{'request.'.$item} = $data{$item}; |
$linkprot_env{$item} = $data{$item}; |
} |
} |
} |
} |
&logout($r,$ip,$handle,\%data,\%linkprot_env); |
&logout($r,$ip,$handle,\%data,undef,\%linkprot_env); |
return OK; |
return OK; |
} |
} |
&Apache::lonnet::appenv({'request.linkprot' => $data{'linkprot'}}); |
&Apache::lonnet::appenv({'request.linkprot' => $data{'linkprot'}}); |
|
if ($data{'linkprotexit'}) { |
|
&Apache::lonnet::appenv({'request.linkprotexit' => $data{'linkprotexit'}}); |
|
} |
if ($env{'request.linkkey'}) { |
if ($env{'request.linkkey'}) { |
&Apache::lonnet::delenv('request.linkkey'); |
&Apache::lonnet::delenv('request.linkkey'); |
} |
} |
Line 889 sub handler {
|
Line 921 sub handler {
|
my %info; |
my %info; |
if ($env{'request.linkprot'}) { |
if ($env{'request.linkprot'}) { |
$info{'linkprot'} = $env{'request.linkprot'}; |
$info{'linkprot'} = $env{'request.linkprot'}; |
|
foreach my $item ('linkprotuser','linkprotexit') { |
|
if ($data{$item}) { |
|
$info{$item} = $data{$item}; |
|
} |
|
} |
} elsif ($env{'request.linkkey'} ne '') { |
} elsif ($env{'request.linkkey'} ne '') { |
$info{'linkkey'} = $env{'request.linkkey'}; |
$info{'linkkey'} = $env{'request.linkkey'}; |
} |
} |
Line 897 sub handler {
|
Line 934 sub handler {
|
$info{'checklaunch'} = 1; |
$info{'checklaunch'} = 1; |
} |
} |
my $token = &Apache::lonnet::tmpput(\%info,$r->dir_config('lonHostID'),'link'); |
my $token = &Apache::lonnet::tmpput(\%info,$r->dir_config('lonHostID'),'link'); |
unless (($token eq 'con_lost') || ($token eq 'refused') || |
unless (($token eq 'con_lost') || ($token eq 'refused') || ($token =~ /^error:/) || |
($token eq 'unknown_cmd') || ($token eq 'no_such_host')) { |
($token eq 'unknown_cmd') || ($token eq 'no_such_host')) { |
$dest .= (($dest =~ /\?/) ? '&' : '?') . 'ttoken='.$token; |
$dest .= (($dest =~ /\?/) ? '&' : '?') . 'ttoken='.$token; |
} |
} |
Line 940 sub handler {
|
Line 977 sub handler {
|
'user.linkproturi' => $linkuri, |
'user.linkproturi' => $linkuri, |
'request.linkprot' => $data{'linkprot'}}; |
'request.linkprot' => $data{'linkprot'}}; |
} |
} |
|
if ($data{'linkprotexit'}) { |
|
$extra_env->{'request.linkprotexit'} = $data{'linkprotexit'}; |
|
} |
|
} |
|
foreach my $item ('linkprotuser','linkprotexit') { |
|
if ($data{$item} ne '') { |
|
$form{$item} = $data{$item}; |
|
} |
} |
} |
} elsif ($data{'linkkey'} ne '') { |
} elsif ($data{'linkkey'} ne '') { |
if (ref($extra_env) eq 'HASH') { |
if (ref($extra_env) eq 'HASH') { |
Line 959 sub handler {
|
Line 1004 sub handler {
|
$extra_env = {'request.deeplink.login' => $data{'deeplink.login'}}; |
$extra_env = {'request.deeplink.login' => $data{'deeplink.login'}}; |
} |
} |
} |
} |
|
if ($desturl eq '/adm/email') { |
|
if (($data{'display'}) && ($data{'mailrecip'})) { |
|
if (&unescape($data{'mailrecip'}) eq "$data{'username'}:$data{'domain'}") { |
|
$form{'display'} = &unescape($data{'display'}); |
|
} |
|
} |
|
} |
} |
} |
my $skipcritical; |
my $skipcritical; |
if ($data{'lti.login'}) { |
if ($data{'lti.login'}) { |
Line 970 sub handler {
|
Line 1022 sub handler {
|
} |
} |
&Apache::lonauth::success($r,$data{'username'},$data{'domain'}, |
&Apache::lonauth::success($r,$data{'username'},$data{'domain'}, |
$home,$desturl,$extra_env,\%form,$skipcritical,'', |
$home,$desturl,$extra_env,\%form,$skipcritical,'', |
$expirepub); |
$expirepub,$data{'lcssowin'}); |
} |
} |
return OK; |
return OK; |
} |
} |
Line 1005 sub handler {
|
Line 1057 sub handler {
|
} elsif ($data{'origurl'} =~ m{^/tiny/$match_domain/\w+$}) { |
} elsif ($data{'origurl'} =~ m{^/tiny/$match_domain/\w+$}) { |
$next_url=$data{'origurl'}; |
$next_url=$data{'origurl'}; |
} else { |
} else { |
$next_url='/adm/roles?selectrole=1&'.&escape($data{'role'}).'=1'; |
if ($data{'lti.login'}) { |
if ($data{'origurl'} ne '') { |
$next_url='/adm/roles?selectrole=1&'.&escape($data{'role'}).'=1'; |
$next_url .= '&orgurl='.&escape($data{'origurl'}); |
if ($data{'origurl'} ne '') { |
|
$next_url .= '&orgurl='.&escape($data{'origurl'}); |
|
} |
|
} else { |
|
$next_url='/adm/roles?selectrole=1&'.&escape($data{'role'}).'=1'; |
|
if ($data{'origurl'} ne '') { |
|
$next_url .= '&orgurl='.&escape($data{'origurl'}); |
|
} |
} |
} |
} |
} |
if ($data{'lti.login'}) { |
if ($data{'lti.login'}) { |
if (($data{'origurl'} =~ m{/default_\d+\.sequence$}) || |
if (($data{'origurl'} =~ m{/default_\d+\.sequence$}) || |
($data{'origurl'} =~ m{^/res/.+\.sequence$})) { |
($data{'origurl'} =~ m{^/res/.+\.sequence$})) { |
$next_url .= '&navmap=1'; |
if ($reuse_session) { |
|
$next_url .= '&navmap=1'; |
|
} else { |
|
$next_url .= '&navmap=1'; |
|
} |
} |
} |
} |
} |
if ($reuse_session) { |
if ($reuse_session) { |
$r->internal_redirect($next_url); |
$r->internal_redirect($next_url); |
} elsif ($data{'deeplink.login'}) { |
} else { |
if (ref($extra_env) eq 'HASH') { |
if ($data{'deeplink.login'}) { |
$extra_env->{'request.deeplink.login'} = $data{'deeplink.login'}; |
if (ref($extra_env) eq 'HASH') { |
} else { |
$extra_env->{'request.deeplink.login'} = $data{'deeplink.login'}; |
$extra_env = {'request.deeplink.login' => $data{'deeplink.login'}}; |
} else { |
} |
$extra_env = {'request.deeplink.login' => $data{'deeplink.login'}}; |
if ($data{'linkprot'}) { |
} |
$extra_env->{'request.linkprot'} = $data{'linkprot'}; |
if ($data{'linkprot'}) { |
} elsif ($data{'linkkey'} ne '') { |
$extra_env->{'request.linkprot'} = $data{'linkprot'}; |
$extra_env->{'request.linkkey'} = $data{'linkkey'}; |
if ($data{'linkprotexit'}) { |
|
$extra_env->{'request.linkprotexit'} = $data{'linkprotexit'}; |
|
} |
|
foreach my $item ('linkprotuser','linkprotexit') { |
|
if ($data{$item}) { |
|
$form{'request.'.$item} = $data{$item}; |
|
} |
|
} |
|
} elsif ($data{'linkkey'} ne '') { |
|
$extra_env->{'request.linkkey'} = $data{'linkkey'}; |
|
} |
} |
} |
&Apache::lonauth::success($r,$data{'username'},$data{'domain'},$home, |
&Apache::lonauth::success($r,$data{'username'},$data{'domain'},$home, |
$next_url,$extra_env,\%form,'',$cid); |
$next_url,$extra_env,\%form,'',$cid,'',$data{'lcssowin'}); |
} |
} |
return OK; |
return OK; |
} |
} |