File:  [LON-CAPA] / loncom / auth / lonacc.pm
Revision 1.2: download - view: text, annotated - select for diffs
Tue Nov 16 19:14:15 1999 UTC (24 years, 6 months ago) by www
Branches: MAIN
CVS tags: HEAD
Putting environment variables into session profile
Reading environment variables from session profile
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("request.state" => "published");
   35:             return OK; 
   36:         } else { 
   37:            $r->log_reason("Cookie $handle not valid", $r->filename) 
   38:         };
   39:     }
   40:     $cookie=CGI::Cookie->new(-name  => 'lonURL',
   41:                              -value => $requrl, 
   42:                              -path  => '/');
   43:     $r->err_headers_out->add('Set-Cookie' => $cookie);
   44:     return FORBIDDEN;
   45: }
   46: 
   47: 1;
   48: __END__
   49: 
   50: 
   51: 
   52: 
   53: 
   54: 
   55: 
   56: 

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