Diff for /loncom/auth/lonacc.pm between versions 1.159.2.14 and 1.159.2.17

version 1.159.2.14, 2020/10/06 17:39:04 version 1.159.2.17, 2021/01/02 22:11:26
Line 563  sub handler { Line 563  sub handler {
         if ($env{'user.noloadbalance'} eq $r->dir_config('lonHostID')) {          if ($env{'user.noloadbalance'} eq $r->dir_config('lonHostID')) {
             $checkexempt = 1;              $checkexempt = 1;
         }          }
         unless ($checkexempt) {          unless (($checkexempt) || (($requrl eq '/adm/switchserver') && (!$r->is_initial_req()))) {
             ($is_balancer,$otherserver) =              ($is_balancer,$otherserver) =
                 &Apache::lonnet::check_loadbalancing($env{'user.name'},                  &Apache::lonnet::check_loadbalancing($env{'user.name'},
                                                      $env{'user.domain'});                                                       $env{'user.domain'});
             if ($is_balancer) {              if ($is_balancer) {
                 unless (($requrl eq '/adm/switchserver') && (!$r->is_initial_req())) {                  # 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)                  my ($found_server,$balancer_cookie) = &Apache::lonnet::check_for_balancer_cookie($r);
                     my ($found_server,$balancer_cookie) = &Apache::lonnet::check_for_balancer_cookie($r);                  if (($found_server) && ($balancer_cookie =~ /^\Q$env{'user.domain'}\E_\Q$env{'user.name'}\E_/)) {
                     if (($found_server) && ($balancer_cookie =~ /^\Q$env{'user.domain'}\E_\Q$env{'user.name'}\E_/)) {                      $otherserver = $found_server;
                         $otherserver = $found_server;                  }
                     }                  unless ($requrl eq '/adm/switchserver') {
                       $r->set_handlers('PerlResponseHandler'=>
                                        [\&Apache::switchserver::handler]);
                 }                  }
             }  
         }  
         if ($is_balancer) {  
             unless (($requrl eq '/adm/switchserver') && (!$r->is_initial_req())) {  
                 $r->set_handlers('PerlResponseHandler'=>  
                                  [\&Apache::switchserver::handler]);  
                 if ($otherserver ne '') {                  if ($otherserver ne '') {
                     $env{'form.otherserver'} = $otherserver;                      $env{'form.otherserver'} = $otherserver;
                 }                  }
             }                  unless (($env{'form.origurl'}) || ($r->uri eq '/adm/roles') ||
             unless (($env{'form.origurl'}) || ($r->uri eq '/adm/roles') ||                          ($r->uri eq '/adm/switchserver') || ($r->uri eq '/adm/sso')) {
                     ($r->uri eq '/adm/switchserver') || ($r->uri eq '/adm/sso')) {                      $env{'form.origurl'} = $r->uri;
                 $env{'form.origurl'} = $r->uri;                  }
             }              }
         }          }
   
 # ---------------------------------------------------------------- Check access  # ---------------------------------------------------------------- Check access
  my $now = time;   my $now = time;
         my $check_symb;          my ($check_symb,$check_access,$check_block,$access,$poss_symb);
  if ($requrl !~ m{^/(?:adm|public|(?:prt|zip)spool)/}   if ($requrl !~ m{^/(?:adm|public|(?:prt|zip)spool)/}
     || $requrl =~ /^\/adm\/.*\/(smppg|bulletinboard)(\?|$ )/x) {      || $requrl =~ /^\/adm\/.*\/(smppg|bulletinboard)(\?|$ )/x) {
             my ($access,$poss_symb);              $check_access = 1;
             if (($env{'request.course.id'}) && (!$suppext)) {          }
                 $requrl=~/\.(\w+)$/;          if ((!$check_access) && ($env{'request.course.id'})) {
                 if ((&Apache::loncommon::fileembstyle($1) eq 'ssi') ||              if (($requrl eq '/adm/viewclasslist') ||
                     ($requrl=~/^\/adm\/.*\/(aboutme|smppg|bulletinboard)(\?|$ )/x) ||                  ($requrl =~ m{^(/adm/wrapper|)\Q/uploaded/$cdom/$cnum/docs/\E}) ||
                     ($requrl=~/^\/adm\/wrapper\//) ||                  ($requrl =~ m{^/adm/.*/aboutme$}) ||
                     ($requrl=~m|^/adm/coursedocs/showdoc/|) ||                  ($requrl=~m{^/adm/coursedocs/showdoc/})) {
                     ($requrl=~m|\.problem/smpedit$|) ||                  $check_block = 1;
                     ($requrl=~/^\/public\/.*\/syllabus$/) ||  
                     ($requrl=~/^\/adm\/(viewclasslist|navmaps)$/) ||  
                     ($requrl=~/^\/adm\/.*\/aboutme\/portfolio(\?|$)/)) {  
                     $check_symb = 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(\?|$)/)) {
                   $check_symb = 1;
               }
           }
           if (($check_access) || ($check_block)) {
             if ($check_symb) {              if ($check_symb) {
                 if ($env{'form.symb'}) {                  if ($env{'form.symb'}) {
                     $poss_symb=&Apache::lonnet::symbclean($env{'form.symb'});                      $poss_symb=&Apache::lonnet::symbclean($env{'form.symb'});
Line 629  sub handler { Line 635  sub handler {
                 if ($poss_symb) {                  if ($poss_symb) {
                     my ($possmap,$resid,$url)=&Apache::lonnet::decode_symb($poss_symb);                      my ($possmap,$resid,$url)=&Apache::lonnet::decode_symb($poss_symb);
                     $url = &Apache::lonnet::clutter($url);                      $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);                          undef($poss_symb);
                     }                      }
                     if ($poss_symb) {                      if ($poss_symb) {
Line 647  sub handler { Line 655  sub handler {
             } else {              } else {
                 $access=&Apache::lonnet::allowed('bre',$requrl);                  $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 '') {              if ($handle eq '') {
                 unless ($access eq 'F') {                  unless ($access eq 'F') {
                     if ($requrl =~ m{^/res/$match_domain/$match_username/}) {                      if ($requrl =~ m{^/res/$match_domain/$match_username/}) {
Line 664  sub handler { Line 684  sub handler {
     }      }
             if ($access eq 'B') {              if ($access eq 'B') {
                 if ($poss_symb) {                  if ($poss_symb) {
                     if ($requrl=~m{^(/adm/.*/aboutme)/portfolio$}) {  
                         $requrl = $1;  
                     }  
                     if (&Apache::lonnet::symbverify($poss_symb,$requrl)) {                      if (&Apache::lonnet::symbverify($poss_symb,$requrl)) {
                         $env{'request.symb'} = $poss_symb;                          $env{'request.symb'} = $poss_symb;
                     }                      }

Removed from v.1.159.2.14  
changed lines
  Added in v.1.159.2.17


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>