--- loncom/auth/lonacc.pm 2020/10/26 01:19:53 1.159.2.8.2.7 +++ loncom/auth/lonacc.pm 2021/01/03 00:12:12 1.159.2.8.2.8 @@ -1,7 +1,7 @@ # The LearningOnline Network # Cookie Based Access Handler # -# $Id: lonacc.pm,v 1.159.2.8.2.7 2020/10/26 01:19:53 raeburn Exp $ +# $Id: lonacc.pm,v 1.159.2.8.2.8 2021/01/03 00:12:12 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -607,24 +607,35 @@ sub handler { # ---------------------------------------------------------------- Check access my $now = time; - my $check_symb; + my ($check_symb,$check_access,$check_block,$access,$poss_symb); if ($requrl !~ m{^/(?:adm|public|(?:prt|zip)spool)/} || $requrl =~ /^\/adm\/.*\/(smppg|bulletinboard)(\?|$ )/x) { - my ($access,$poss_symb); - if (($env{'request.course.id'}) && (!$suppext)) { - $requrl=~/\.(\w+)$/; - if ((&Apache::loncommon::fileembstyle($1) eq 'ssi') || - ($requrl=~/^\/adm\/.*\/(aboutme|smppg|bulletinboard)(\?|$ )/x) || - ($requrl=~/^\/adm\/wrapper\//) || - ($requrl=~m|^/adm/coursedocs/showdoc/|) || - ($requrl=~m|\.problem/smpedit$|) || - ($requrl=~/^\/public\/.*\/syllabus$/) || - ($requrl=~/^\/adm\/(viewclasslist|navmaps)$/) || - ($requrl=~/^\/adm\/.*\/aboutme\/portfolio(\?|$)/) || - ($requrl=~m{^/adm/$cdom/$cnum/\d+/ext\.tool$})) { - $check_symb = 1; - } + $check_access = 1; + } + if ((!$check_access) && ($env{'request.course.id'})) { + if (($requrl eq '/adm/viewclasslist') || + ($requrl =~ m{^(/adm/wrapper|)\Q/uploaded/$cdom/$cnum/docs/\E}) || + ($requrl =~ m{^/adm/.*/aboutme$}) || + ($requrl=~m{^/adm/coursedocs/showdoc/}) || + ($requrl=~m{^(/adm/wrapper|)/adm/$cdom/$cnum/\d+/ext\.tool$})) { + $check_block = 1; + } + } + if (($env{'request.course.id'}) && (!$suppext)) { + $requrl=~/\.(\w+)$/; + if ((&Apache::loncommon::fileembstyle($1) eq 'ssi') || + ($requrl=~/^\/adm\/.*\/(aboutme|smppg|bulletinboard)(\?|$ )/x) || + ($requrl=~/^\/adm\/wrapper\//) || + ($requrl=~m|^/adm/coursedocs/showdoc/|) || + ($requrl=~m|\.problem/smpedit$|) || + ($requrl=~/^\/public\/.*\/syllabus$/) || + ($requrl=~/^\/adm\/(viewclasslist|navmaps)$/) || + ($requrl=~/^\/adm\/.*\/aboutme\/portfolio(\?|$)/) || + ($requrl=~m{^/adm/$cdom/$cnum/\d+/ext\.tool$})) { + $check_symb = 1; } + } + if (($check_access) || ($check_block)) { if ($check_symb) { if ($env{'form.symb'}) { $poss_symb=&Apache::lonnet::symbclean($env{'form.symb'}); @@ -644,7 +655,9 @@ sub handler { if ($poss_symb) { my ($possmap,$resid,$url)=&Apache::lonnet::decode_symb($poss_symb); $url = &Apache::lonnet::clutter($url); - unless (($url eq $requrl) && (&Apache::lonnet::is_on_map($possmap))) { + my $toplevelmap = $env{'course.'.$env{'request.course.id'}.'.url'}; + unless (($url eq $requrl) && (($possmap eq $toplevelmap) || + (&Apache::lonnet::is_on_map($possmap)))) { undef($poss_symb); } if ($poss_symb) { @@ -662,6 +675,18 @@ sub handler { } else { $access=&Apache::lonnet::allowed('bre',$requrl); } + } + if ($check_block) { + if ($access eq 'B') { + if ($poss_symb) { + if (&Apache::lonnet::symbverify($poss_symb,$requrl)) { + $env{'request.symb'} = $poss_symb; + } + } + &Apache::blockedaccess::setup_handler($r); + return OK; + } + } elsif ($check_access) { if ($handle eq '') { unless ($access eq 'F') { if ($requrl =~ m{^/res/$match_domain/$match_username/}) { @@ -679,9 +704,6 @@ sub handler { } if ($access eq 'B') { if ($poss_symb) { - if ($requrl=~m{^(/adm/.*/aboutme)/portfolio$}) { - $requrl = $1; - } if (&Apache::lonnet::symbverify($poss_symb,$requrl)) { $env{'request.symb'} = $poss_symb; }