Annotation of loncom/auth/loncacc.pm, revision 1.1.1.1

1.1       albertel    1: # The LearningOnline Network
                      2: # Cookie Based Access Handler for Construction Area
                      3: # (lonacc: 5/21/99,5/22,5/29,5/31 Gerd Kortemeyer)
                      4: # 6/15 Gerd Kortemeyer
                      5: 
                      6: package Apache::loncacc;
                      7: 
                      8: use strict;
                      9: use Apache::Constants qw(:common :http);
                     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 $ownername=$requrl;
                     24:             $ownername=~s/\/\~(\w+).*/\1/;
                     25:             my $ownerdomain=$r->dir_config('lonDefDomain');
                     26:             my @handleparts=split(/\_/,$handle);
                     27:             my $username=$handleparts[0];
                     28:             my $domain=$handleparts[2];
                     29:             if (($username ne $ownername) || ($domain ne $ownerdomain)) {
                     30:                 $r->log_reason
                     31:                    ("$username at $domain not authorized", $r->filename); 
                     32: 	        return HTTP_NOT_ACCEPTABLE;
                     33:             }
                     34:             return OK; 
                     35:         } else { 
                     36:             $r->log_reason("Cookie $handle not valid", $r->filename) 
                     37:         };
                     38:     }
                     39:     $cookie=CGI::Cookie->new(-name  => 'lonURL',
                     40:                              -value => $requrl, 
                     41:                              -path  => '/');
                     42:     $r->err_headers_out->add('Set-Cookie' => $cookie);
                     43:     return FORBIDDEN;
                     44: }
                     45: 
                     46: 1;
                     47: __END__
                     48: 
                     49: 
                     50: 
                     51: 
                     52: 
                     53: 
                     54: 
                     55: 

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