--- loncom/auth/lonacc.pm 2022/08/24 20:58:50 1.206 +++ loncom/auth/lonacc.pm 2023/08/28 20:40:00 1.210 @@ -1,7 +1,7 @@ # The LearningOnline Network # Cookie Based Access Handler # -# $Id: lonacc.pm,v 1.206 2022/08/24 20:58:50 raeburn Exp $ +# $Id: lonacc.pm,v 1.210 2023/08/28 20:40:00 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -333,7 +333,8 @@ sub sso_login { } } - my ($linkprot,$linkprotuser,$linkprotexit,$linkkey,$deeplinkurl); + my ($linkprot,$linkprotuser,$linkprotexit,$linkkey,$deeplinkurl, + $linkprotpbid,$linkprotpburl); # # If Shibboleth auth is in use, and a dual SSO and non-SSO login page @@ -373,6 +374,8 @@ sub sso_login { $linkprot = $info{'linkprot'}; $linkprotuser = $info{'linkprotuser'}; $linkprotexit = $info{'linkprotexit'}; + $linkprotpbid = $info{'linkprotpbid'}; + $linkprotpburl = $info{'linkprotpburl'}; } elsif ($info{'linkkey'} ne '') { $linkkey = $info{'linkkey'}; } @@ -394,11 +397,15 @@ sub sso_login { if ($firsturl =~ m{^/tiny/$match_domain/\w+$}) { $form{'origurl'} = $firsturl; $deeplinkurl = $firsturl; + } elsif ($firsturl eq '/adm/email') { + $form{'origurl'} = $firsturl; } if ($form{'linkprot'}) { $linkprot = $form{'linkprot'}; $linkprotuser = $form{'linkprotuser'}; $linkprotexit = $form{'linkprotexit'}; + $linkprotpbid = $form{'linkprotpbid'}; + $linkprotpburl = $form{'linkprotpburl'}; } elsif ($form{'linkkey'} ne '') { $linkkey = $form{'linkkey'}; } @@ -428,6 +435,8 @@ sub sso_login { $linkprot = $form{'linkprot'}; $linkprotuser = $form{'linkprotuser'}; $linkprotexit = $form{'linkprotexit'}; + $linkprotpbid = $form{'linkprotpbid'}; + $linkprotpburl = $form{'linkprotpburl'}; } elsif ($form{'linkkey'} ne '') { $linkkey = $form{'linkkey'}; } @@ -442,6 +451,12 @@ sub sso_login { if ($link_info{'linkprotexit'} ne '') { $linkprotexit = $link_info{'linkprotexit'}; } + if ($link_info{'linkprotpbid'} ne '') { + $linkprotpbid = $link_info{'linkprotpbid'}; + } + if ($link_info{'linkprotpburl'} ne '') { + $linkprotpburl = $link_info{'linkprotpburl'}; + } } my $delete = &Apache::lonnet::tmpdel($form{'ltoken'}); delete($form{'ltoken'}); @@ -464,6 +479,8 @@ sub sso_login { linkprot => $linkprot, linkprotuser => $linkprotuser, linkprotexit => $linkprotexit, + linkprotpbid => $linkprotpbid, + linkprotpburl => $linkprotpburl, ); if ($env{'form.lcssowin'}) { $data{'lcssowin'} = $env{'form.lcssowin'}; @@ -536,10 +553,22 @@ sub sso_login { if ($linkprotexit ne '') { $env{'request.linkprotexit'} = $linkprotexit; } + if ($linkprotpbid ne '') { + $env{'request.linkprotpbid'} = $linkprotpbid; + } + if ($linkprotpburl ne '') { + $env{'request.linkprotpburl'} = $linkprotpburl; + } } elsif ($linkkey ne '') { $env{'request.linkkey'} = $linkkey; } } + if (($r->uri eq '/adm/sso') && ($form{'origurl'} eq '/adm/email')) { + if ($form{'display'} && ($env{'form.mailrecip'} eq $user.':'.$domain)) { + $env{'request.display'} = $form{'display'}; + $env{'request.mailrecip'} = $env{'form.mailrecip'}; + } + } $env{'request.sso.login'} = 1; if (defined($r->dir_config("lonSSOReloginServer"))) { $env{'request.sso.reloginserver'} = @@ -590,10 +619,22 @@ sub sso_login { if ($linkprotexit ne '') { $info{'linkprotexit'} = $linkprotexit; } + if ($linkprotpbid ne '') { + $info{'linkprotpbid'} = $linkprotpbid; + } + if ($linkprotpburl ne '') { + $info{'linkprotpburl'} = $linkprotpburl; + } } elsif ($linkkey ne '') { $info{'linkkey'} = $linkkey; } } + if (($r->uri eq '/adm/sso') && ($form{'origurl'} eq '/adm/email')) { + if ($form{'display'} && ($form{'mailrecip'} eq $user.':'.$domain)) { + $info{'display'} = &escape($form{'display'}); + $info{'mailrecip'} = &escape($form{'mailrecip'}); + } + } if ($r->dir_config("ssodirecturl") == 1) { $info{'origurl'} = $r->uri; } @@ -810,6 +851,8 @@ sub handler { linkprot => $info{'linkprot'}, linkprotuser => $info{'linkprotuser'}, linkprotexit => $info{'linkprotexit'}, + linkprotpbid => $info{'linkprotpbid'}, + linkprotpburl => $info{'linkprotpburl'}, ); } elsif ($info{'ltoken'} ne '') { my %ltoken_info = &Apache::lonnet::tmpget($info{'ltoken'}); @@ -820,6 +863,8 @@ sub handler { linkprot => $ltoken_info{'linkprot'}, linkprotuser => $ltoken_info{'linkprotuser'}, linkprotexit => $ltoken_info{'linkprotexit'}, + linkprotpbid => $ltoken_info{'linkprotpbid'}, + linkprotpburl => $ltoken_info{'linkprotpburl'}, ); } } @@ -846,6 +891,17 @@ sub handler { return FORBIDDEN; } return OK; + } elsif (($env{'request.course.id'}) && + (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) && + ($requrl=~m{^(/daxeopen|)(/uploaded/$cdom/$cnum/(?:docs|supplemental)/(?:default|\d+)/\d+/)([^/]+|)$})) { + my ($daxe,$path,$file) = ($1,$2,$3); + my $referrer; + unless ($daxe) { + $referrer = $r->headers_in->{'Referer'}; + } + if (($daxe) || ($referrer =~ m{\Qfile=/daxeopen$path\E})) { + return OK; + } } # ---------------------------------------------------------------- Check access my $now = time; @@ -919,18 +975,25 @@ sub handler { } } else { my $nodeeplinkcheck; - if (($check_access) && ($requrl =~ /\.(sequence|page)$/)) { - unless ($env{'form.navmap'}) { - if ($r->args ne '') { - &Apache::loncommon::get_unprocessed_cgi($r->args,['navmap']); - unless ($env{'form.navmap'}) { - $nodeeplinkcheck = 1; + if ($check_access) { + if ($requrl =~ m{^/daxeopen/priv/}) { + $nodeeplinkcheck = 1; + } elsif ($requrl =~ /\.(sequence|page)$/) { + unless ($env{'form.navmap'}) { + if ($r->args ne '') { + &Apache::loncommon::get_unprocessed_cgi($r->args,['navmap']); + unless ($env{'form.navmap'}) { + $nodeeplinkcheck = 1; + } } } } } my $clientip = &Apache::lonnet::get_requestor_ip($r); $access=&Apache::lonnet::allowed('bre',$requrl,'','',$clientip,'','',$nodeeplinkcheck); + if (($requrl =~ m{^/daxeopen/priv/}) && ($access eq '')) { + $env{'request.editurl'}=$requrl; + } } } if ($check_block) {