Problem with Apache::AuthCookie

2001-12-09 Thread Steven Lembark

Getting multiple header entries from AuthCookie returned to the
client. This happens even if I stub out the authen_cred and
authen_ses_key to return foo. Other thing I notice after
adding logging to the authentication and authorization sub's
is that the $r-connection-user set by authentication isn't
available in $r-connection-user in authorization. As a 
result of the undef $r-connection-user in authorization
it's sending back a FORBIDDEN which [I think?] causes the
problems.

The examples I've seen of login_form code use a simple print to
get things on the screen (e.g., Apache::AuthTicket).
I've tried this and various combinations of sending the headers
and form with no luck.

Ideally Apache::AuthCookie should only require the login_form,
authen_cred and authen_ses_key sub's to function with the 
addition of login_screen to use a location rather rather than
#!-ed code for the login form.

Does anyone know of a simple, working example of deriving a 
class from Apache::AuthTicket or some specific documentation
for a complete class? The code that comes with it is only
useful for testing

Below are the relavant error_log items (showing the user 
available in authenticate and undef in authorize).


thanx.
sl


# Authorization cookie handler.


PerlModule Cdr::AuthCookie;

PerlSetVar CDRPath  /foo

PerlSetVar CDRLoginScript   /cdrloginform
PerlSetVar CDRLoginHandler  /cdrlogin

#PerlSetVar CDRExpires  +8h

PerlSetVar  AuthCookieDebug 9

# 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

SetHandler  perl-script

AuthTypeCdr::AuthCookie
AuthNameCDR 

PerlHandler Cdr::AuthCookie-login

/Location

Location /foo

SetHandler  perl-script

AuthTypeCdr::AuthCookie
AuthNameCDR

PerlAuthenHandler   Cdr::AuthCookie-authenticate
PerlAuthzHandlerCdr::AuthCookie-authorize

PerlHandler Cdr::Hello

require valid-user

/Location

Location /foo/bar

SetHandler  perl-script

AuthTypeCdr::AuthCookie
AuthNameCDR

PerlAuthenHandler   Cdr::AuthCookie-authenticate
PerlAuthzHandlerCdr::AuthCookie-authorize

PerlHandler Cdr::Hello

require valid-user

/Location

###
# Cdr::AuthCookie.pm
###

package Cdr::AuthCookie;

use strict;

use base qw( Apache::AuthCookie );

local $\ = \n;
local $, = \n;

# CPAN modules

use Carp;

use Apache::Constants qw(:common M_GET M_POST FORBIDDEN REDIRECT);
use Apache::Log;

use Digest::MD5 qw( md5_hex );

# used for sharing and generating the shared secret
# used in the authrization process.

use IPC::SysV;
use IPC::Shareable;

use Digest::MD5 qw( md5_hex );

use Data::Dumper;
$Data::Dumper::Purity   = 1;
$Data::Dumper::Terse= 1;
$Data::Dumper::Indent   = 1;
$Data::Dumper::Deepcopy = 0;
$Data::Dumper::Quotekeys= 0;

# homegrown modules

use Cdr::Reportz;
use Cdr::Shared qw( logrequest sendreply );


# package variables


# initialize the untied variable to false, use $key to check the status.

our $secret = '';
our $key = '';

# amount of time before a cookie times out.
# currently set to 8 hours (28 800 sec).
#
# 10 sec for testing only, probably useful in production.

my $timeout = 30; #28800;

# login screen returns this to the caller.

my $loginform = 'END';

html

head
!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 3.2 Final//EN
base href=$ENV{BASEURL} 
/head
body

form method=get action=/cdrlogin 

!-- Login form for an Cdr::AuthCookie --

input type=hidden name=destination value=DEST 

table

tr
th align=center colspan=2 Please Enter Your Username and Password to 
log in:

tr
th align=right Username:
td align=left  input type=text name=credential_0 size=12 
maxlenth=12 

tr
th align=right Password:
td align=left  input type=password name=credential_1 size=12 
maxlenth=12 

tr
   

Problem with Apache::AuthCookie-3.00

2001-12-06 Thread Steven Lembark


Getting multiple HTTP replies returned to the client. They
get a form and followig it an 'access denied' message from
Apache.

The examples I've seen of login_form code use a simple print to
get things on the screen (e.g., Apache::AuthTicket).
I've tried this and various combinations of sending the headers
and form with no luck.

Ideally Apache::AuthCookie should only require the login_form,
authen_cred and authen_ses_key sub's to function with the
addition of login_screen to use a location rather rather than
#!-ed code for the login form.

Does anyone know of a simple, working example of deriving a
class from Apache::AuthTicket or some specific documentation
for a complete class? The code that comes with it is only
useful for testing; the other modules include quit a bit of
non-AuthCookie sub's that may have a bearing on how the
form is handled. The login_form is taken from Apache::AuthTicket
(basically just a header and static body).

My sub-class also overloads authentication to call login_form($r)
rather than without arguments.

sub authen_cred( $$\@ ) { foo }

sub authen_ses_key( $$$ ) { foo }

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

$request-no_cache( 1 );
$request-send_http_header( 'text/html' );
$request-print( $form );

OK
}



--
Steven Lembark   2930 W. Palmer
Workhorse Computing   Chicago, IL 60647
+1 800 762 1582