--- loncom/auth/lonacc.pm 2021/02/10 11:37:49 1.159.2.8.2.11 +++ loncom/auth/lonacc.pm 2020/10/23 21:33:46 1.159.2.15 @@ -1,7 +1,7 @@ # The LearningOnline Network # Cookie Based Access Handler # -# $Id: lonacc.pm,v 1.159.2.8.2.11 2021/02/10 11:37:49 raeburn Exp $ +# $Id: lonacc.pm,v 1.159.2.15 2020/10/23 21:33:46 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -355,14 +355,6 @@ sub sso_login { # login but immediately go to switch server to find us a new # machine &Apache::lonauth::success($r,$user,$domain,$home,'noredirect'); - foreach my $item (keys(%form)) { - $env{'form.'.$item} = $form{$item}; - } - unless ($form{'symb'}) { - unless (($r->uri eq '/adm/roles') || ($r->uri eq '/adm/sso')) { - $env{'form.origurl'} = $r->uri; - } - } $env{'request.sso.login'} = 1; if (defined($r->dir_config("lonSSOReloginServer"))) { $env{'request.sso.reloginserver'} = @@ -377,7 +369,7 @@ sub sso_login { } else { # need to login them in, so generate the need data that # migrate expects to do login - my $ip = &Apache::lonnet::get_requestor_ip($r); + my $ip = $r->get_remote_host(); my %info=('ip' => $ip, 'domain' => $domain, 'username' => $user, @@ -550,7 +542,6 @@ sub handler { my $lonhost = &Apache::lonnet::host_from_dns($hostname); if ($lonhost) { my $actual = &Apache::lonnet::absolute_url($hostname); - my $exphostname = &Apache::lonnet::hostname($lonhost); my $expected = $Apache::lonnet::protocol{$lonhost}.'://'.$hostname; unless ($actual eq $expected) { $env{'request.use_absolute'} = $expected; @@ -595,47 +586,26 @@ sub handler { } } } - if ($requrl=~m{^/+tiny/+$match_domain/+\w+$}) { - if ($env{'user.name'} eq 'public' && - $env{'user.domain'} eq 'public') { - $env{'request.firsturl'}=$requrl; - return FORBIDDEN; - } else { - return OK; - } - } # ---------------------------------------------------------------- Check access my $now = time; - my ($check_symb,$check_access,$check_block,$access,$poss_symb); + my $check_symb; if ($requrl !~ m{^/(?:adm|public|(?:prt|zip)spool)/} || $requrl =~ /^\/adm\/.*\/(smppg|bulletinboard)(\?|$ )/x) { - $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; + 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(\?|$)/)) { + $check_symb = 1; + } } - } - if (($check_access) || ($check_block)) { if ($check_symb) { if ($env{'form.symb'}) { $poss_symb=&Apache::lonnet::symbclean($env{'form.symb'}); @@ -655,9 +625,7 @@ sub handler { if ($poss_symb) { my ($possmap,$resid,$url)=&Apache::lonnet::decode_symb($poss_symb); $url = &Apache::lonnet::clutter($url); - my $toplevelmap = $env{'course.'.$env{'request.course.id'}.'.url'}; - unless (($url eq $requrl) && (($possmap eq $toplevelmap) || - (&Apache::lonnet::is_on_map($possmap)))) { + unless (($url eq $requrl) && (&Apache::lonnet::is_on_map($possmap))) { undef($poss_symb); } if ($poss_symb) { @@ -675,18 +643,6 @@ 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/}) { @@ -704,6 +660,9 @@ 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; } @@ -727,7 +686,7 @@ sub handler { } } } elsif (($handle =~ /^publicuser_\d+$/) && (&Apache::lonnet::is_portfolio_url($requrl))) { - my $clientip = &Apache::lonnet::get_requestor_ip($r); + my $clientip = $r->get_remote_host(); if (&Apache::lonnet::allowed('bre',$requrl,undef,undef,$clientip) ne 'F') { $env{'user.error.msg'}="$requrl:bre:1:1:Access Denied"; return HTTP_NOT_ACCEPTABLE; @@ -776,32 +735,18 @@ sub handler { } if ($env{'form.symb'}) { $symb=&Apache::lonnet::symbclean($env{'form.symb'}); - if (($requrl eq '/adm/navmaps') || - ($requrl =~ m{^/adm/wrapper/}) || - ($requrl =~ m{^/adm/coursedocs/showdoc/})) { - unless (&Apache::lonnet::symbverify($symb,$requrl)) { - if (&Apache::lonnet::is_on_map($requrl)) { - $symb = &Apache::lonnet::symbread($requrl); - unless (&Apache::lonnet::symbverify($symb,$requrl)) { - undef($symb); - } - } - } - if ($symb) { - if ($requrl eq '/adm/navmaps') { - my ($map,$mid,$murl)=&Apache::lonnet::decode_symb($symb); - &Apache::lonnet::symblist($map,$murl => [$murl,$mid]); - } elsif (($requrl =~ m{^/adm/wrapper/}) || - ($requrl =~ m{^/adm/coursedocs/showdoc/})) { - my ($map,$mid,$murl)=&Apache::lonnet::decode_symb($symb); - if ($map =~ /\.page$/) { - my $mapsymb = &Apache::lonnet::symbread($map); - ($map,$mid,$murl)=&Apache::lonnet::decode_symb($mapsymb); - } - &Apache::lonnet::symblist($map,$murl => [$murl,$mid], - 'last_known' =>[$murl,$mid]); - } + if ($requrl eq '/adm/navmaps') { + my ($map,$mid,$murl)=&Apache::lonnet::decode_symb($symb); + &Apache::lonnet::symblist($map,$murl => [$murl,$mid]); + } elsif ($requrl =~ m|^/adm/wrapper/| + || $requrl =~ m|^/adm/coursedocs/showdoc/|) { + my ($map,$mid,$murl)=&Apache::lonnet::decode_symb($symb); + if ($map =~ /\.page$/) { + my $mapsymb = &Apache::lonnet::symbread($map); + ($map,$mid,$murl)=&Apache::lonnet::decode_symb($mapsymb); } + &Apache::lonnet::symblist($map,$murl => [$murl,$mid], + 'last_known' =>[$murl,$mid]); } elsif ((&Apache::lonnet::symbverify($symb,$requrl)) || (($requrl=~m|(.*)/smpedit$|) && &Apache::lonnet::symbverify($symb,$1)) || @@ -861,14 +806,10 @@ sub handler { } } if ($invalidsymb) { - if ($requrl eq '/adm/navmaps') { - undef($symb); - } else { - $r->log_reason('Invalid symb for '.$requrl.': '.$symb); - $env{'user.error.msg'}= - "$requrl:bre:1:1:Invalid Access"; - return HTTP_NOT_ACCEPTABLE; - } + $r->log_reason('Invalid symb for '.$requrl.': '.$symb); + $env{'user.error.msg'}= + "$requrl:bre:1:1:Invalid Access"; + return HTTP_NOT_ACCEPTABLE; } } } @@ -935,7 +876,7 @@ sub handler { } # ------------------------------------ See if this is a viewable portfolio file if (&Apache::lonnet::is_portfolio_url($requrl)) { - my $clientip = &Apache::lonnet::get_requestor_ip($r); + my $clientip = $r->get_remote_host(); my $access=&Apache::lonnet::allowed('bre',$requrl,undef,undef,$clientip); if ($access eq 'A') { &Apache::restrictedaccess::setup_handler($r);