Annotation of loncom/auth/lonacc.pm, revision 1.3
1.1 albertel 1: # The LearningOnline Network
2: # Cookie Based Access Handler
1.2 www 3: # 5/21/99,5/22,5/29,5/31,6/15,16/11 Gerd Kortemeyer
1.1 albertel 4:
5: package Apache::lonacc;
6:
7: use strict;
8: use Apache::Constants qw(:common);
1.2 www 9: use Apache::File;
1.1 albertel 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 '')) {
1.2 www 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: }
1.3 ! www 34: $r->subprocess_env("user.environment" => "$lonidsdir/$handle.id");
1.2 www 35: $r->subprocess_env("request.state" => "published");
36: return OK;
1.1 albertel 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>