File:  [LON-CAPA] / loncom / auth / lonacc.pm
Revision 1.85: download - view: text, annotated - select for diffs
Mon Jul 10 03:58:45 2006 UTC (17 years, 10 months ago) by raeburn
Branches: MAIN
CVS tags: HEAD
Mechanism for user to provide passphrase, and for the server to validate it when user attempts to access a passphrase-protected portfolio file.

    1: # The LearningOnline Network
    2: # Cookie Based Access Handler
    3: #
    4: # $Id: lonacc.pm,v 1.85 2006/07/10 03:58:45 raeburn Exp $
    5: #
    6: # Copyright Michigan State University Board of Trustees
    7: #
    8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    9: #
   10: # LON-CAPA is free software; you can redistribute it and/or modify
   11: # it under the terms of the GNU General Public License as published by
   12: # the Free Software Foundation; either version 2 of the License, or
   13: # (at your option) any later version.
   14: #
   15: # LON-CAPA is distributed in the hope that it will be useful,
   16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   18: # GNU General Public License for more details.
   19: #
   20: # You should have received a copy of the GNU General Public License
   21: # along with LON-CAPA; if not, write to the Free Software
   22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   23: #
   24: # /home/httpd/html/adm/gpl.txt
   25: #
   26: # http://www.lon-capa.org/
   27: #
   28: ###
   29: 
   30: package Apache::lonacc;
   31: 
   32: use strict;
   33: use Apache::Constants qw(:common :http :methods);
   34: use Apache::File;
   35: use Apache::lonnet;
   36: use Apache::loncommon();
   37: use Apache::lonlocal;
   38: use CGI::Cookie();
   39: use Fcntl qw(:flock);
   40: use LONCAPA;
   41: 
   42: sub cleanup {
   43:     my ($r)=@_;
   44:     if (! $r->is_initial_req()) { return DECLINED; }
   45:     &Apache::lonnet::save_cache();
   46:     return OK;
   47: }
   48: 
   49: sub goodbye {
   50:     my ($r)=@_;
   51:     &Apache::lonnet::goodbye();
   52:     return DONE;
   53: }
   54: 
   55: ###############################################
   56: 
   57: sub get_posted_cgi {
   58:     my ($r) = @_;
   59: 
   60:     my $buffer;
   61:     if ($r->header_in('Content-length')) {
   62: 	$r->read($buffer,$r->header_in('Content-length'),0);
   63:     }
   64:     unless ($buffer=~/^(\-+\w+)\s+Content\-Disposition\:\s*form\-data/si) {
   65: 	my @pairs=split(/&/,$buffer);
   66: 	my $pair;
   67: 	foreach $pair (@pairs) {
   68: 	    my ($name,$value) = split(/=/,$pair);
   69: 	    $value =~ tr/+/ /;
   70: 	    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
   71: 	    $name  =~ tr/+/ /;
   72: 	    $name  =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
   73: 	    &Apache::loncommon::add_to_env("form.$name",$value);
   74: 	}
   75:     } else {
   76: 	my $contentsep=$1;
   77: 	my @lines = split (/\n/,$buffer);
   78: 	my $name='';
   79: 	my $value='';
   80: 	my $fname='';
   81: 	my $fmime='';
   82: 	my $i;
   83: 	for ($i=0;$i<=$#lines;$i++) {
   84: 	    if ($lines[$i]=~/^$contentsep/) {
   85: 		if ($name) {
   86: 		    chomp($value);
   87: 		    if ($fname) {
   88: 			$env{"form.$name.filename"}=$fname;
   89: 			$env{"form.$name.mimetype"}=$fmime;
   90: 		    } else {
   91: 			$value=~s/\s+$//s;
   92: 		    }
   93: 		    &Apache::loncommon::add_to_env("form.$name",$value);
   94: 		}
   95: 		if ($i<$#lines) {
   96: 		    $i++;
   97: 		    $lines[$i]=~
   98: 		/Content\-Disposition\:\s*form\-data\;\s*name\=\"([^\"]+)\"/i;
   99: 		    $name=$1;
  100: 		    $value='';
  101: 		    if ($lines[$i]=~/filename\=\"([^\"]+)\"/i) {
  102: 			$fname=$1;
  103: 			if 
  104:                             ($lines[$i+1]=~/Content\-Type\:\s*([\w\-\/]+)/i) {
  105: 				$fmime=$1;
  106: 				$i++;
  107: 			    } else {
  108: 				$fmime='';
  109: 			    }
  110: 		    } else {
  111: 			$fname='';
  112: 			$fmime='';
  113: 		    }
  114: 		    $i++;
  115: 		}
  116: 	    } else {
  117: 		$value.=$lines[$i]."\n";
  118: 	    }
  119: 	}
  120:     }
  121: #
  122: # Digested POSTed values
  123: #
  124: # Remember the way this was originally done (GET or POST)
  125: #
  126:     $env{'request.method'}=$ENV{'REQUEST_METHOD'};
  127: #
  128: # There may also be stuff in the query string
  129: # Tell subsequent handlers that this was GET, not POST, so they can access query string.
  130: # Also, unset POSTed content length to cover all tracks.
  131: #
  132: 
  133:     $r->method_number(M_GET);
  134: 
  135:     $r->method('GET');
  136:     $r->headers_in->unset('Content-length');
  137: }
  138: 
  139: sub portfolio_access {
  140:     my ($udom,$unum,$file_name,$group) = @_;
  141:     my $current_perms = &Apache::lonnet::get_portfile_permissions($udom,$unum);
  142:     my %access_controls = &Apache::lonnet::get_access_controls(
  143:                                              $current_perms,$group,$file_name);
  144:     my ($public,$guest,@domains,@users,@courses,@groups);
  145:     my $now = time;
  146:     my $access_hash = $access_controls{$file_name};
  147:     if (ref($access_hash) eq 'HASH') {
  148:         foreach my $key (keys(%{$access_hash})) {
  149:             my ($num,$scope,$end,$start) = ($key =~ /^([^:]+):([a-z]+)_(\d*)_?(\d*)$/);
  150:             if ($start > $now) {
  151:                 next;
  152:             }
  153:             if ($end && $end<$now) {
  154:                 next;
  155:             }
  156:             if ($scope eq 'public') {
  157:                 $public = $key;
  158:                 last;
  159:             } elsif ($scope eq 'guest') {
  160:                 $guest = $key;
  161:             } elsif ($scope eq 'domains') {
  162:                 push(@domains,$key);
  163:             } elsif ($scope eq 'users') {
  164:                 push(@users,$key);
  165:             } elsif ($scope eq 'course') {
  166:                 push(@courses,$key);
  167:             } elsif ($scope eq 'group') {
  168:                 push(@groups,$key);
  169:             }
  170:         }
  171:         if ($public) {
  172:             return 'ok';
  173:         }
  174:         if ($env{'user.name'} eq 'public' && $env{'user.domain'} eq 'public') {
  175:             if ($guest) {
  176:                 return $guest;
  177:             }
  178:         } else {
  179:             if (@domains > 0) {
  180:                 foreach my $domkey (@domains) {
  181:                     my %content = &Apache::lonnet::parse_access_controls($$access_hash{$domkey});
  182:                     if (ref($content{'dom'}) eq 'ARRAY') {
  183:                         if (grep(/^\Q$env{'user.domain'}\E$/,@{$content{'dom'}})) {
  184:                             return 'ok';
  185:                         }
  186:                     }
  187:                 }
  188:             }
  189:             if (@users > 0) {
  190:                 foreach my $userkey (@users) {
  191:                     my %content = &Apache::lonnet::parse_access_controls($$access_hash{$userkey});
  192:                     if (exists($content{'users'}{$env{'user.name'}.':'.$env{'user.domain'}})) {
  193:                         return 'ok';
  194:                     }
  195:                 }
  196:             }
  197:             my %roleshash;
  198:             my @courses_and_groups = @courses;
  199:             push(@courses_and_groups,@groups); 
  200:             if (@courses_and_groups > 0) {
  201:                 my (%allgroups,%allroles); 
  202:                 my ($start,$end,$role,$sec,$group);
  203:                 foreach my $envkey (%env) {
  204:                     if ($envkey =~ m-^user\.role\.(gr|cc|in|ta|ep|st)\./([^/]+)/([^/]+)/?([^/]*)$-) {
  205:                         my $cid = $2.'_'.$3; 
  206:                         if ($1 eq 'gr') {
  207:                             $group = $4;
  208:                             $allgroups{$cid}{$group} = $env{$envkey};
  209:                         } else {
  210:                             if ($4 eq '') {
  211:                                 $sec = 'none';
  212:                             } else {
  213:                                 $sec = $4;
  214:                             }
  215:                             $allroles{$cid}{$1}{$sec} = $env{$envkey};
  216:                         }
  217:                     } elsif ($envkey =~ m-^user\.role\./cr/(\w+/\w+/\w*)./([^/]+)/([^/]+)/?([^/]*)$-) {
  218:                         my $cid = $2.'_'.$3;
  219:                         if ($4 eq '') {
  220:                             $sec = 'none';
  221:                         } else {
  222:                             $sec = $4;
  223:                         }
  224:                         $allroles{$cid}{$1}{$sec} = $env{$envkey};
  225:                     }
  226:                 }
  227:                 if (keys(%allroles) == 0) {
  228:                     return;
  229:                 }
  230:                 foreach my $key (@courses_and_groups) {
  231:                     my %content = &Apache::lonnet::parse_access_controls($$access_hash{$key});
  232:                     my $cnum = $content{'number'};
  233:                     my $cdom = $content{'domain'};
  234:                     my $cid = $cdom.'_'.$cnum;
  235:                     if (!exists($allroles{$cid})) {
  236:                         next;
  237:                     }    
  238:                     foreach my $role_id (keys(%{$content{'roles'}})) {
  239:                         my @sections = @{$content{'roles'}{$role_id}{'section'}};
  240:                         my @groups = @{$content{'roles'}{$role_id}{'group'}};
  241:                         my @status = @{$content{'roles'}{$role_id}{'access'}};
  242:                         my @roles = @{$content{'roles'}{$role_id}{'role'}};
  243:                         foreach my $role (keys(%{$allroles{$cid}})) {
  244:                             if ((grep/^all$/,@roles) || (grep/^\Q$role\E$/,@roles)) {
  245:                                 foreach my $sec (keys(%{$allroles{$cid}{$role}})) {
  246:                                     if (&course_group_datechecker($allroles{$cid}{$role}{$sec},$now,\@status) eq 'ok') {
  247:                                         if (grep/^all$/,@sections) {
  248:                                             return 'ok';
  249:                                         } else {
  250:                                             if (grep/^$sec$/,@sections) {
  251:                                                 return 'ok';
  252:                                             }
  253:                                         }
  254:                                     }
  255:                                 }
  256:                                 if (keys(%{$allgroups{$cid}}) == 0) {
  257:                                     if (grep/^none$/,@groups) {
  258:                                         return 'ok';
  259:                                     }
  260:                                 } else {
  261:                                     if (grep/^all$/,@groups) {
  262:                                         return 'ok';
  263:                                     } 
  264:                                     foreach my $group (keys(%{$allgroups{$cid}})) {
  265:                                         if (grep/^$group$/,@groups) {
  266:                                             return 'ok';
  267:                                         }
  268:                                     }
  269:                                 } 
  270:                             }
  271:                         }
  272:                     }
  273:                 }
  274:             }
  275:             if ($guest) {
  276:                 return $guest;
  277:             }
  278:         }
  279:     }
  280:     return;
  281: }
  282: 
  283: sub passphrase_access_checker {
  284:     my ($r,$guestkey,$requrl) = @_;
  285:     my ($num,$scope,$end,$start) = ($guestkey =~ /^([^:]+):([a-z]+)_(\d*)_?(\d*)$/);
  286:     if ($scope eq 'guest') {
  287:         if (exists($env{'user.passphrase_access_'.$requrl})) {
  288:             if (($env{'user.passphrase_access_'.$requrl} == 0) || 
  289:                 ($env{'user.passphrase_access_'.$requrl} > time)) {
  290:                 $env{'request.publicaccess'} = 1;
  291:                 return 'ok'; 
  292:             }
  293:         }
  294:     }
  295:     my $login = $r->dir_config('Login');
  296:     $login .= '?origurl='.&escape($requrl);
  297:     $r->custom_response(FORBIDDEN,$login);
  298:     return;
  299: }
  300: 
  301: sub course_group_datechecker {
  302:     my ($dates,$now,$status) = @_;
  303:     my ($start,$end) = split(/\./,$dates);
  304:     if (!$start && !$end) {
  305:         return 'ok';
  306:     }
  307:     if (grep/^active$/,@{$status}) {
  308:         if (((!$start) || ($start && $start <= $now)) && ((!$end) || ($end && $end >= $now))) {
  309:             return 'ok';
  310:         }
  311:     }
  312:     if (grep/^previous$/,@{$status}) {
  313:         if ($end > $now ) {
  314:             return 'ok';
  315:         }
  316:     }
  317:     if (grep/^future$/,@{$status}) {
  318:         if ($start > $now) {
  319:             return 'ok';
  320:         }
  321:     }
  322:     return; 
  323: }
  324: 
  325: sub handler {
  326:     my $r = shift;
  327:     my $requrl=$r->uri;
  328:     my %cookies=CGI::Cookie->parse($r->header_in('Cookie'));
  329:     my $lonid=$cookies{'lonID'};
  330:     my $cookie;
  331:     my $lonidsdir=$r->dir_config('lonIDsDir');
  332: 
  333:     my $handle;
  334:     if ($lonid) {
  335: 	$handle=$lonid->value;
  336:         $handle=~s/\W//g;
  337:     }
  338:       
  339:     my ($sso_login);
  340:     if ($r->user 
  341: 	&& (!$lonid || !-e "$lonidsdir/$handle.id" || $handle eq '') ) {
  342: 	$sso_login = 1;
  343: 	my $domain = $r->dir_config('lonDefDomain');
  344: 	my $home=&Apache::lonnet::homeserver($r->user,$domain);
  345: 	if ($home !~ /(con_lost|no_such_host)/) {
  346: 	    $handle=&Apache::lonauth::success($r,$r->user,$domain,
  347: 					     $home,'noredirect');
  348: 	    $r->header_out('Set-cookie',"lonID=$handle; path=/");
  349: 	}
  350:     }
  351: 
  352:     if ($sso_login) {
  353: 	&Apache::lonnet::appenv('request.sso.login' => 1);
  354:     }
  355: 
  356:     if ($r->dir_config("lonBalancer") eq 'yes') {
  357: 	$r->set_handlers('PerlResponseHandler'=>
  358: 			 [\&Apache::switchserver::handler]);
  359:     }
  360: 
  361:     if ($handle ne '') {
  362:         if ((-e "$lonidsdir/$handle.id") && ($handle ne '')) {
  363: 
  364: # ------------------------------------------------------ Initialize Environment
  365: 
  366:             &Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle);
  367: 
  368: # --------------------------------------------------------- Initialize Language
  369: 
  370: 	    &Apache::lonlocal::get_language_handle($r);
  371: 
  372: # -------------------------------------------------------------- Resource State
  373: 
  374:             if ($requrl=~/^\/+(res|uploaded)\//) {
  375:                $env{'request.state'} = "published";
  376: 	    } else {
  377: 	       $env{'request.state'} = 'unknown';
  378:             }
  379:             $env{'request.filename'} = $r->filename;
  380:             $env{'request.noversionuri'} = &Apache::lonnet::deversion($requrl);
  381: # -------------------------------------------------------- Load POST parameters
  382: 
  383: 	    &Apache::lonacc::get_posted_cgi($r);
  384: 
  385: # ---------------------------------------------------------------- Check access
  386:             my $now = time;
  387:             if ($requrl =~ m|/+uploaded/([^/]+)/([^/]+)/portfolio(/.+)$|) {
  388:                 my $result = &portfolio_access($1,$2,$3);
  389:                 if ($result eq 'ok') {
  390:                     return OK;
  391:                 } elsif ($result =~ /^[^:]+:guest_/) {
  392:                     if (&passphrase_access_checker($r,$result,$requrl) eq 'ok') {
  393:                         return OK;
  394:                     } else {
  395:                         return FORBIDDEN;
  396:                     } 
  397:                 }
  398:             } elsif ($requrl =~ m|/+uploaded/([^/]+)/([^/]+)/groups/([^/]+)/portfolio/(.+)$|) {
  399:                 my $result = &portfolio_access($1,$2,$3.'/'.$4,$3);
  400:                 if ($result eq 'ok') {
  401:                     return OK;
  402:                 } elsif ($result =~ /^[^:]+:guest_/) {
  403:                     if (&passphrase_access_checker($r,$result,$requrl) eq 'ok') {
  404:                         return OK;
  405:                     } else {
  406:                         return FORBIDDEN;
  407:                     }
  408:                 }
  409:             }
  410:             if ($requrl!~/^\/adm|public|prtspool\//) {
  411: 		my $access=&Apache::lonnet::allowed('bre',$requrl);
  412:                 if ($access eq '1') {
  413: 		   $env{'user.error.msg'}="$requrl:bre:0:0:Choose Course";
  414: 	           return HTTP_NOT_ACCEPTABLE; 
  415:                 }
  416:                 if (($access ne '2') && ($access ne 'F')) {
  417: 		   $env{'user.error.msg'}="$requrl:bre:1:1:Access Denied";
  418: 	           return HTTP_NOT_ACCEPTABLE; 
  419:                 }
  420:             }
  421: 	    if ($requrl =~ m|^/prtspool/|) {
  422: 		my $start='/prtspool/'.$env{'user.name'}.'_'.
  423: 		    $env{'user.domain'};
  424: 		if ($requrl !~ /^\Q$start\E/) {
  425: 		    $env{'user.error.msg'}="$requrl:bre:1:1:Access Denied";
  426: 		    return HTTP_NOT_ACCEPTABLE;
  427: 		}
  428: 	    }
  429: 	    if ($env{'user.name'} eq 'public' && 
  430: 		$env{'user.domain'} eq 'public' &&
  431: 		$requrl !~ m{^/+(res|public)/} &&
  432: 		$requrl !~ m{^/+adm/(help|logout|randomlabel\.png)}) {
  433: 		$env{'request.querystring'}=$r->args;
  434: 		$env{'request.firsturl'}=$requrl;
  435: 		return FORBIDDEN;
  436: 	    }
  437: # ------------------------------------------------------------- This is allowed
  438:           if ($env{'request.course.id'}) {
  439: 	    &Apache::lonnet::countacc($requrl);
  440:             $requrl=~/\.(\w+)$/;
  441:             if ((&Apache::loncommon::fileembstyle($1) eq 'ssi') ||
  442:  ($requrl=~/^\/adm\/.*\/(aboutme|navmaps|smppg|bulletinboard)(\?|$)/) ||
  443:  ($requrl=~/^\/adm\/wrapper\//) ||
  444:  ($requrl=~m|^/adm/coursedocs/showdoc/|) ||
  445:  ($requrl=~m|\.problem/smpedit$|) ||
  446:  ($requrl=~/^\/public\/.*\/syllabus$/)) {
  447: # ------------------------------------- This is serious stuff, get symb and log
  448: 		my $query=$r->args;
  449:                 my $symb;
  450:                 if ($query) {
  451: 		    &Apache::loncommon::get_unprocessed_cgi($query,['symb']);
  452:                 }
  453:                 if ($env{'form.symb'}) {
  454: 		    $symb=&Apache::lonnet::symbclean($env{'form.symb'});
  455:                     if ($requrl =~ m|^/adm/wrapper/|
  456: 			|| $requrl =~ m|^/adm/coursedocs/showdoc/|) {
  457:                         my ($map,$mid,$murl)=&Apache::lonnet::decode_symb($symb);
  458:                         &Apache::lonnet::symblist($map,$murl => [$murl,$mid],
  459: 						  'last_known' =>[$murl,$mid]);
  460:                     } elsif ((&Apache::lonnet::symbverify($symb,$requrl)) ||
  461: 			     (($requrl=~m|(.*)/smpedit$|) &&
  462: 			      &Apache::lonnet::symbverify($symb,$1))) {
  463:                       my ($map,$mid,$murl)=&Apache::lonnet::decode_symb($symb);
  464: 		      &Apache::lonnet::symblist($map,$murl => [$murl,$mid],
  465: 						'last_known' =>[$murl,$mid]);
  466: 		    } else {
  467: 			$r->log_reason('Invalid symb for '.$requrl.': '.
  468:                                        $symb);
  469: 		        $env{'user.error.msg'}=
  470:                                 "$requrl:bre:1:1:Invalid Access";
  471:   	                return HTTP_NOT_ACCEPTABLE; 
  472:                     }
  473:                 } else {
  474: 	            $symb=&Apache::lonnet::symbread($requrl);
  475: 		    if (&Apache::lonnet::is_on_map($requrl) && $symb &&
  476: 			!&Apache::lonnet::symbverify($symb,$requrl)) {
  477: 			$r->log_reason('Invalid symb for '.$requrl.': '.$symb);
  478: 		        $env{'user.error.msg'}=
  479:                                 "$requrl:bre:1:1:Invalid Access";
  480:   	                return HTTP_NOT_ACCEPTABLE; 
  481: 		    }
  482: 		    if ($symb) {
  483: 			my ($map,$mid,$murl)=
  484: 			    &Apache::lonnet::decode_symb($symb);
  485: 			&Apache::lonnet::symblist($map,$murl =>[$murl,$mid],
  486: 						'last_known' =>[$murl,$mid]);
  487: 		    }
  488:                 }
  489:                 $env{'request.symb'}=$symb;
  490:                 &Apache::lonnet::courseacclog($symb);
  491:             } else {
  492: # ------------------------------------------------------- This is other content
  493:                 &Apache::lonnet::courseacclog($requrl);    
  494:             }
  495: 	  }
  496:             return OK; 
  497:         } else { 
  498:             $r->log_reason("Cookie $handle not valid", $r->filename); 
  499:         }
  500:     }
  501: 
  502: # -------------------------------------------- See if this is a public resource
  503:     if ($requrl=~m|^/public/|
  504: 	|| (&Apache::lonnet::metadata($requrl,'copyright') eq 'public')) {
  505:         &Apache::lonnet::logthis('Granting public access: '.$requrl);
  506:         &Apache::lonlocal::get_language_handle($r);
  507: 	my $cookie=
  508: 	    &Apache::lonauth::success($r,'public','public','public');
  509:         my $lonidsdir=$r->dir_config('lonIDsDir');
  510: 	&Apache::lonnet::transfer_profile_to_env($lonidsdir,$cookie);
  511: 	&Apache::lonacc::get_posted_cgi($r);
  512:         $env{'request.state'} = "published";
  513:         $env{'request.publicaccess'} = 1;
  514:         $env{'request.filename'} = $r->filename;
  515: 
  516: 	$r->header_out('Set-cookie',"lonID=$cookie; path=/");
  517:         return OK;
  518:     }
  519:     if ($requrl=~m|^/+adm/+help/+|) {
  520: 	return OK;
  521:     }
  522: # ------------------------------------- See if this is a viewable portfolio file
  523:     if ($requrl =~ m|/+uploaded/([^/]+)/([^/]+)/portfolio(/.+)$|) {
  524:         my $result = &portfolio_access($1,$2,$3);
  525:         if ($result eq 'ok') {
  526:             return OK;
  527:         } elsif ($result =~ /^[^:]+:guest_/) {
  528:             if (&passphrase_access_checker($r,$result,$requrl) eq 'ok') {
  529:                 return OK;
  530:             } else {
  531:                 return FORBIDDEN;
  532:             }
  533:         }
  534:     } elsif ($requrl =~ m|/+uploaded/([^/]+)/([^/]+)/groups/([^/]+)/portfolio/(.+)$|) {
  535:         my $result = &portfolio_access($1,$2,$3.'/'.$4,$3);
  536:         if ($result eq 'ok') {
  537:             return OK;
  538:         } elsif ($result =~ /^[^:]+:guest_/) {
  539:             if (&passphrase_access_checker($r,$result,$requrl) eq 'ok') {
  540:                 return OK;
  541:             } else {
  542:                 return FORBIDDEN;
  543:             }
  544:         }
  545:     }
  546: # -------------------------------------------------------------- Not authorized
  547:     $requrl=~/\.(\w+)$/;
  548: #    if ((&Apache::loncommon::fileembstyle($1) eq 'ssi') ||
  549: #        ($requrl=~/^\/adm\/(roles|logout|email|menu|remote)/) ||
  550: #        ($requrl=~m|^/prtspool/|)) {
  551: # -------------------------- Store where they wanted to go and get login screen
  552: 	$env{'request.querystring'}=$r->args;
  553: 	$env{'request.firsturl'}=$requrl;
  554:        return FORBIDDEN;
  555: #   } else {
  556: # --------------------------------------------------------------------- Goodbye
  557: #       return HTTP_BAD_REQUEST;
  558: #   }
  559: }
  560: 
  561: 1;
  562: __END__
  563: 
  564: =head1 NAME
  565: 
  566: Apache::lonacc - Cookie Based Access Handler
  567: 
  568: =head1 SYNOPSIS
  569: 
  570: Invoked (for various locations) by /etc/httpd/conf/srm.conf:
  571: 
  572:  PerlAccessHandler       Apache::lonacc
  573: 
  574: =head1 INTRODUCTION
  575: 
  576: This module enables cookie based authentication and is used
  577: to control access for many different LON-CAPA URIs.
  578: 
  579: Whenever the client sends the cookie back to the server, 
  580: this cookie is handled by either lonacc.pm or loncacc.pm
  581: (see srm.conf for what is invoked when).  If
  582: the cookie is missing or invalid, the user is re-challenged
  583: for login information.
  584: 
  585: This is part of the LearningOnline Network with CAPA project
  586: described at http://www.lon-capa.org.
  587: 
  588: =head1 HANDLER SUBROUTINE
  589: 
  590: This routine is called by Apache and mod_perl.
  591: 
  592: =over 4
  593: 
  594: =item *
  595: 
  596: transfer profile into environment
  597: 
  598: =item *
  599: 
  600: load POST parameters
  601: 
  602: =item *
  603: 
  604: check access
  605: 
  606: =item *
  607: 
  608: if allowed, get symb, log, generate course statistics if applicable
  609: 
  610: =item *
  611: 
  612: otherwise return error
  613: 
  614: =item *
  615: 
  616: see if public resource
  617: 
  618: =item *
  619: 
  620: store attempted access
  621: 
  622: =back
  623: 
  624: =cut

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