--- loncom/auth/lonlogin.pm 2022/05/25 18:05:56 1.196 +++ loncom/auth/lonlogin.pm 2022/06/26 04:03:47 1.200 @@ -1,7 +1,7 @@ # The LearningOnline Network # Login Screen # -# $Id: lonlogin.pm,v 1.196 2022/05/25 18:05:56 raeburn Exp $ +# $Id: lonlogin.pm,v 1.200 2022/06/26 04:03:47 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -68,6 +68,9 @@ sub handler { $env{'form.ltoken'} = $info{'ltoken'}; } elsif ($info{'linkprot'}) { $env{'form.linkprot'} = $info{'linkprot'}; + if ($info{'linkprotuser'} ne '') { + $env{'form.linkprotuser'} = $info{'linkprotuser'}; + } } elsif ($info{'linkkey'} ne '') { $env{'form.linkkey'} = $info{'linkkey'}; } @@ -181,6 +184,9 @@ sub handler { $link_info{'ltoken'} = $env{'form.ltoken'}; } elsif ($env{'form.linkprot'}) { $link_info{'linkprot'} = $env{'form.linkprot'}; + if ($env{'form.linkprotuser'} ne '') { + $link_info{'linkprotuser'} = $env{'form.linkprotuser'}; + } } elsif ($env{'form.linkkey'} ne '') { $link_info{'linkkey'} = $env{'form.linkkey'}; } @@ -249,16 +255,33 @@ sub handler { $dest = &HTML::Entities::encode($env{'form.firsturl'},'\'"<>&'); } if (($env{'form.ltoken'}) || ($env{'form.linkprot'})) { - my $linkprot; + my ($linkprot,$linkprotuser); if ($env{'form.ltoken'}) { my %info = &Apache::lonnet::tmpget($env{'form.ltoken'}); $linkprot = $info{'linkprot'}; - my $delete = &Apache::lonnet::tmpdel($env{'form.ltoken'}); + if ($info{'linkprotuser'} ne '') { + $linkprotuser = $info{'linkprotuser'}; + } } else { $linkprot = $env{'form.linkprot'}; + $linkprotuser = $env{'form.linkprotuser'}; } if ($linkprot) { my ($linkprotector,$deeplink) = split(/:/,$linkprot,2); + if (($deeplink =~ m{^/tiny/$match_domain/\w+$}) && + ($linkprotuser ne '') && ($linkprotuser ne $env{'user.name'}.':'.$env{'user.domain'})) { + my $ip = &Apache::lonnet::get_requestor_ip(); + my %linkprotinfo = ( + origurl => $deeplink, + linkprot => $linkprot, + linkprotuser => $linkprotuser, + ); + if ($env{'form.ltoken'}) { + my $delete = &Apache::lonnet::tmpdel($env{'form.ltoken'}); + } + &Apache::migrateuser::logout($r,$ip,$handle,undef,undef,\%linkprotinfo); + return OK; + } if ($env{'user.linkprotector'}) { my @protectors = split(/,/,$env{'user.linkprotector'}); unless (grep(/^\Q$linkprotector\E$/,@protectors)) { @@ -304,6 +327,9 @@ sub handler { } } } + if ($env{'form.ltoken'}) { + my $delete = &Apache::lonnet::tmpdel($env{'form.ltoken'}); + } $r->print( $start_page .'

'.&mt('You are already logged in!').'

' @@ -429,7 +455,7 @@ sub handler { # -------------------------------------------------------- Store away log token my ($tokenextras,$tokentype,$linkprot_for_login); - my @names = ('role','symb','iptoken','ltoken','linkprot','linkkey'); + my @names = ('role','symb','iptoken','ltoken','linkprotuser','linkprot','linkkey'); foreach my $name (@names) { if ($env{'form.'.$name} ne '') { if ($name eq 'ltoken') { @@ -437,13 +463,17 @@ sub handler { if ($info{'linkprot'}) { $linkprot_for_login = $info{'linkprot'}; $tokenextras .= '&linkprot='.&escape($info{'linkprot'}); + if ($info{'linkprotuser'}) { + $tokenextras .= '&linkprotuser='.&escape($info{'linkprotuser'}); + } $tokentype = 'link'; last; } } else { $tokenextras .= '&'.$name.'='.&escape($env{'form.'.$name}); if (($name eq 'linkkey') || ($name eq 'linkprot')) { - if (($env{'form.retry'}) && (!$env{'form.ltoken'}) && ($name eq 'linkprot')) { + if ((($env{'form.retry'}) || ($env{'form.sso'})) && + (!$env{'form.ltoken'}) && ($name eq 'linkprot')) { $linkprot_for_login = $env{'form.linkprot'}; } $tokentype = 'link'; @@ -907,7 +937,7 @@ ENDSAML my ($linkprotector,$linkproturi) = split(/:/,$linkprot_for_login,2); if (($linkprotector =~ /^\d+(c|d)$/) && ($linkproturi =~ m{^/+tiny/+$LONCAPA::match_domain/+\w+$})) { my $set_target; - if ($env{'form.retry'}) { + if (($env{'form.retry'}) || ($env{'form.sso'})) { if ($linkproturi eq $env{'form.firsturl'}) { $set_target = " document.server.target = '_self';"; } @@ -1031,6 +1061,7 @@ $versionrow
+$in_frame_js