File:  [LON-CAPA] / loncom / auth / lonacc.pm
Revision 1.3: download - view: text, annotated - select for diffs
Mon Nov 22 17:23:13 1999 UTC (24 years, 5 months ago) by www
Branches: MAIN
CVS tags: HEAD
Limit length of $middlename to 16 characters for critical message buffer
Add appenv to lonnet (not tested yet)

    1: # The LearningOnline Network
    2: # Cookie Based Access Handler
    3: # 5/21/99,5/22,5/29,5/31,6/15,16/11 Gerd Kortemeyer
    4: 
    5: package Apache::lonacc;
    6: 
    7: use strict;
    8: use Apache::Constants qw(:common);
    9: use Apache::File;
   10: use CGI::Cookie();
   11: 
   12: sub handler {
   13:     my $r = shift;
   14:     my $requrl=$r->uri;
   15:     my %cookies=CGI::Cookie->parse($r->header_in('Cookie'));
   16:     my $lonid=$cookies{'lonID'};
   17:     my $cookie;
   18:     if ($lonid) {
   19: 	my $handle=$lonid->value;
   20:         $handle=~s/\W//g;
   21:         my $lonidsdir=$r->dir_config('lonIDsDir');
   22:         if ((-e "$lonidsdir/$handle.id") && ($handle ne '')) {
   23:             my @profile;
   24: 	    {
   25:              my $idf=Apache::File->new("$lonidsdir/$handle.id");
   26:              @profile=<$idf>;
   27: 	    }
   28:             my $envi;
   29:             for ($envi=0;$envi<=$#profile;$envi++) {
   30: 		chomp($profile[$envi]);
   31: 		my ($envname,$envvalue)=split(/=/,$profile[$envi]);
   32:                 $r->subprocess_env("profile.$envname" => "$envvalue");
   33:             }
   34:             $r->subprocess_env("user.environment" => "$lonidsdir/$handle.id");
   35:             $r->subprocess_env("request.state" => "published");
   36:             return OK; 
   37:         } else { 
   38:            $r->log_reason("Cookie $handle not valid", $r->filename) 
   39:         };
   40:     }
   41:     $cookie=CGI::Cookie->new(-name  => 'lonURL',
   42:                              -value => $requrl, 
   43:                              -path  => '/');
   44:     $r->err_headers_out->add('Set-Cookie' => $cookie);
   45:     return FORBIDDEN;
   46: }
   47: 
   48: 1;
   49: __END__
   50: 
   51: 
   52: 
   53: 
   54: 
   55: 
   56: 
   57: 

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