Diff for /loncom/auth/lonacc.pm between versions 1.67 and 1.75

version 1.67, 2005/07/07 05:53:35 version 1.75, 2006/04/07 22:42:00
Line 38  use Apache::lonlocal; Line 38  use Apache::lonlocal;
 use CGI::Cookie();  use CGI::Cookie();
 use Fcntl qw(:flock);  use Fcntl qw(:flock);
   
   sub cleanup {
       my ($r)=@_;
       if (! $r->is_initial_req()) { return DECLINED; }
       &Apache::lonnet::save_cache();
       return OK;
   }
   
   sub goodbye {
       my ($r)=@_;
       &Apache::lonnet::goodbye();
       return DONE;
   }
   
 sub handler {  sub handler {
     my $r = shift;      my $r = shift;
     my $requrl=$r->uri;      my $requrl=$r->uri;
     my %cookies=CGI::Cookie->parse($r->header_in('Cookie'));      my %cookies=CGI::Cookie->parse($r->header_in('Cookie'));
     my $lonid=$cookies{'lonID'};      my $lonid=$cookies{'lonID'};
     my $cookie;      my $cookie;
       my $lonidsdir=$r->dir_config('lonIDsDir');
   
       my $handle;
     if ($lonid) {      if ($lonid) {
  my $handle=$lonid->value;   $handle=$lonid->value;
         $handle=~s/\W//g;          $handle=~s/\W//g;
         my $lonidsdir=$r->dir_config('lonIDsDir');      }
         
       if ($r->user 
    && (!$lonid || !-e "$lonidsdir/$handle.id" || $handle eq '') ) {
    my $domain = $r->dir_config('lonDefDomain');
    my $home=&Apache::lonnet::homeserver($r->user,$domain);
    if ($home !~ /(con_lost|no_such_host)/) {
       $handle=&Apache::lonauth::success($r,$r->user,$domain,
        $home,'noredirect');
       $r->header_out('Set-cookie',"lonID=$handle; path=/");
    }
       }
   
       if ($r->dir_config("lonBalancer") eq 'yes') {
    $r->set_handlers('PerlResponseHandler'=>
    [\&Apache::switchserver::handler]);
       }
   
       if ($handle ne '') {
         if ((-e "$lonidsdir/$handle.id") && ($handle ne '')) {          if ((-e "$lonidsdir/$handle.id") && ($handle ne '')) {
   
 # ------------------------------------------------------ Initialize Environment  # ------------------------------------------------------ Initialize Environment
Line 95  sub handler { Line 129  sub handler {
     if ($env{'user.name'} eq 'public' &&       if ($env{'user.name'} eq 'public' && 
  $env{'user.domain'} eq 'public' &&   $env{'user.domain'} eq 'public' &&
  $requrl !~ m{^/+(res|public)/} &&   $requrl !~ m{^/+(res|public)/} &&
  $requrl !~ m{^/+adm/(roles|logout|randomlabel\.png)}) {   $requrl !~ m{^/+adm/(help|logout|randomlabel\.png)}) {
  $env{'request.querystring'}=$r->args;   $env{'request.querystring'}=$r->args;
  $env{'request.firsturl'}=$requrl;   $env{'request.firsturl'}=$requrl;
  return FORBIDDEN;   return FORBIDDEN;
Line 107  sub handler { Line 141  sub handler {
             if ((&Apache::loncommon::fileembstyle($1) eq 'ssi') ||              if ((&Apache::loncommon::fileembstyle($1) eq 'ssi') ||
  ($requrl=~/^\/adm\/.*\/(aboutme|navmaps|smppg|bulletinboard)(\?|$)/) ||   ($requrl=~/^\/adm\/.*\/(aboutme|navmaps|smppg|bulletinboard)(\?|$)/) ||
  ($requrl=~/^\/adm\/wrapper\//) ||   ($requrl=~/^\/adm\/wrapper\//) ||
    ($requrl=~m|^/adm/coursedocs/showdoc/|) ||
  ($requrl=~m|\.problem/smpedit$|) ||   ($requrl=~m|\.problem/smpedit$|) ||
  ($requrl=~/^\/public\/.*\/syllabus$/)) {   ($requrl=~/^\/public\/.*\/syllabus$/)) {
 # ------------------------------------- This is serious stuff, get symb and log  # ------------------------------------- This is serious stuff, get symb and log
Line 117  sub handler { Line 152  sub handler {
                 }                  }
                 if ($env{'form.symb'}) {                  if ($env{'form.symb'}) {
     $symb=&Apache::lonnet::symbclean($env{'form.symb'});      $symb=&Apache::lonnet::symbclean($env{'form.symb'});
                     if ($requrl =~ m|^/adm/wrapper/|) {                      if ($requrl =~ m|^/adm/wrapper/|
    || $requrl =~ m|^/adm/coursedocs/showdoc/|) {
                         my ($map,$mid,$murl)=&Apache::lonnet::decode_symb($symb);                          my ($map,$mid,$murl)=&Apache::lonnet::decode_symb($symb);
                         &Apache::lonnet::symblist($map,$murl => [$murl,$mid],                          &Apache::lonnet::symblist($map,$murl => [$murl,$mid],
   'last_known' =>[$murl,$mid]);    'last_known' =>[$murl,$mid]);
Line 125  sub handler { Line 161  sub handler {
      (($requrl=~m|(.*)/smpedit$|) &&       (($requrl=~m|(.*)/smpedit$|) &&
       &Apache::lonnet::symbverify($symb,$1))) {        &Apache::lonnet::symbverify($symb,$1))) {
                       my ($map,$mid,$murl)=&Apache::lonnet::decode_symb($symb);                        my ($map,$mid,$murl)=&Apache::lonnet::decode_symb($symb);
                       &Apache::lonnet::symblist($map,$murl => [$murl,$mid],        &Apache::lonnet::symblist($map,$murl => [$murl,$mid],
  'last_known' =>[$murl,$mid]);   'last_known' =>[$murl,$mid]);
     } else {      } else {
  $r->log_reason('Invalid symb for '.$requrl.': '.   $r->log_reason('Invalid symb for '.$requrl.': '.
Line 159  sub handler { Line 195  sub handler {
   }    }
             return OK;               return OK; 
         } else {           } else { 
             $r->log_reason("Cookie $handle not valid", $r->filename)               $r->log_reason("Cookie $handle not valid", $r->filename); 
         };          }
     }      }
   
 # -------------------------------------------- See if this is a public resource  # -------------------------------------------- See if this is a public resource
     if ($requrl=~m|^/public/|      if ($requrl=~m|^/public/|
  || (&Apache::lonnet::metadata($requrl,'copyright') eq 'public')) {   || (&Apache::lonnet::metadata($requrl,'copyright') eq 'public')) {
         &Apache::lonnet::logthis('Granting public access: '.$requrl);          &Apache::lonnet::logthis('Granting public access: '.$requrl);
           &Apache::lonlocal::get_language_handle($r);
  my $cookie=   my $cookie=
     &Apache::lonauth::success($r,'public','public','public');      &Apache::lonauth::success($r,'public','public','public');
         my $lonidsdir=$r->dir_config('lonIDsDir');          my $lonidsdir=$r->dir_config('lonIDsDir');
Line 179  sub handler { Line 216  sub handler {
  $r->header_out('Set-cookie',"lonID=$cookie; path=/");   $r->header_out('Set-cookie',"lonID=$cookie; path=/");
         return OK;          return OK;
     }      }
       if ($requrl=~m|^/+adm/+help/+|) {
    return OK;
       }
 # -------------------------------------------------------------- Not authorized  # -------------------------------------------------------------- Not authorized
     $requrl=~/\.(\w+)$/;      $requrl=~/\.(\w+)$/;
 #    if ((&Apache::loncommon::fileembstyle($1) eq 'ssi') ||  #    if ((&Apache::loncommon::fileembstyle($1) eq 'ssi') ||

Removed from v.1.67  
changed lines
  Added in v.1.75


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