Getting Apache::AuthCookie working. The AuthCookie portion is proving
simpler than Apache...

Problem is that accessing the /loginform location works perfectly: I
get the form, get the cookie back and get sent to the proper place.

Accessing the protected site blows up because the Apache object
referent is undef (see below for examples). No doubt I've screwed
up some part of the httpd.conf but cannot figure out what at this
point... 

Wandering through the Apache doc's hasn't helped, nor can I find
anything particularly descriptive in the Eagle book -- p. 123+ 
don't indicate that the $r is any different for a request and 
p. 554+ are in C. None of them seem to indicate that a redirected
request produces an invalid request object in the perl API.

Any suggestions as to what I've done wrong or specific working
examples would be appreciated.

/sl


Aside: this is rather obviusly hack code at this point. I know 
that, the only purpose is to get a working referent when accessing
the /foo site.



sub login_form($$)
{
        my( $class, $request ) = @_;

        print STDERR "\n$$: login_form: $class, ", Dumper $request;

        print STDERR "\n$$: login_form: $class\nrequest:\n", $request->as_string;

        print STDERR "Environment:\n", Dumper \%ENV;

        # this eventually needs to be updated for the user's
        # real dest uri.

        ( my $form = $loginform ) =~ s{DEST}{/foo};

        print STDOUT $form;
}


########################################################################
# Authorization cookie handler.
########################################################################

PerlModule Cdr::AuthCookie;

PerlSetVar CDRPath                      /foo

PerlSetVar CDRLoginScript       /cdrloginform
PerlSetVar CDRLoginHandler      /cdrlogin

#PerlSetVar     CDRExpires              +8h

PerlSetVar      AuthCookieDebug "3"

# this shows the login form.

<Location /cdrloginform>

        SetHandler perl-script  
        PerlHandler Cdr::AuthCookie->login_form

</Location>
       
# handle posted data from the login form.

<location /cdrlogin>

        AuthType Cdr::AuthCookie
        AuthName CDR 
        SetHandler perl-script
        PerlHandler Cdr::AuthCookie->login

</Location>

<Location /foo>

        SetHandler              perl-script

        AuthType                Cdr::AuthCookie
        AuthName                CDR

        PerlAuthenHandler       Cdr::AuthCookie->authenticate
        PerlAuthzHandler        Cdr::AuthCookie->authorize

        PerlHandler             Cdr::Hello      # just print the famous message

        require                 valid-user

</Location>

########################################################################

Result of accessing /cdrloginform:

        32309: login_form: Cdr::AuthCookie, 
                bless( do{\(my $o = 144324132)}, 'Apache' )


        32309: login_form: Cdr::AuthCookie
        request:

                GET /cdrloginform HTTP/1.1
        Accept: text/html, image/png, image/jpeg, image/gif, image/x-xbitmap, */*
        Accept-Encoding: deflate, gzip, x-gzip, identity, *;q=0
        Cache-Control: no-cache
        Connection: Keep-Alive, TE
        Host: cdr_dev.lit.alltel.com:8081
        TE: deflate, gzip, chunked, identity, trailers
        User-Agent: Opera/5.0 (Linux 2.2.18.ae i686; U)  [en]

        HTTP/1.1 (null)


        Environment [cruft removed]:

        {
          QUERY_STRING => '',
          REMOTE_PORT => '3767',
          HTTP_USER_AGENT => 'Opera/5.0 (Linux 2.2.18.ae i686; U)  [en]',
          HTTP_ACCEPT => 'text/html, image/png, image/jpeg, image/gif, 
image/x-xbitmap, */*',
          HTTP_HOST => 'cdr_dev.lit.alltel.com:8081',
          GATEWAY_INTERFACE => 'CGI-Perl/1.1',
          HTTP_TE => 'deflate, gzip, chunked, identity, trailers',
          SCRIPT_NAME => '/cdrloginform',
          SERVER_NAME => 'AlltelViewer',
          HTTP_ACCEPT_ENCODING => 'deflate, gzip, x-gzip, identity, *;q=0',
          MOD_PERL => 'mod_perl/1.26',
          SCRIPT_FILENAME => 
'/home/lembark/sandbox/cdr//code/app/website/htdocs/cdrloginform',
          APACHE_PORT => '8081',
          SERVER_PROTOCOL => 'HTTP/1.1',
          HTTP_CONNECTION => 'Keep-Alive, TE',
          SERVER_SIGNATURE => '<ADDRESS>Apache/1.3.20 Server at AlltelViewer Port 
8081</ADDRESS>
        ',
          SERVER_SOFTWARE => 'Apache/1.3.20 (Unix) mod_perl/1.26',
        :
          HTTP_CACHE_CONTROL => 'no-cache'
        }



Result of accessing /foo:


        32309: login_form: Cdr::AuthCookie, 
                undef

        [Thu Dec  6 11:11:20 2001] [error] Can't call method "as_string" on an 
undefined value at Cdr/AuthCookie.pm line 360, <DATA> line 1.


Reply via email to