Hi ,
I am having problems with the stacked handlers , i have enclosed the code below ,
the error i get is undefined value ($r) in sub authenticate
package SetRealm1;
use Apache;
use Apache::Constants qw(:common);
use DBI;
use diagnostics;
sub handler {
my $r = shift;
$r->push_handlers(PerlAuthenHandler => \authenticate());
## uri's are
return OK unless is_protected($r);
my $realm = get_realm($r);
my $authheader = 'Basic realm="'.$realm.'"';
$r->header_out("WWW-Authenticate" ,$authheader);
## Return 401 to browser and prompt for login
$r->status(AUTH_REQUIRED);
$r->send_http_header("text/html");
return AUTH_REQUIRED;
}
sub get_realm {
my $r = shift;
return " Test".int(rand(1000000)) if ($r->uri =~ /\/test/);
}
sub is_protected {
my $r = shift;
my @protected = ('\/test','\/icons');
for (@protected) { return 1 if ($r->uri =~ /$_/); }
return 0;
}
sub authenticate {
my $r = shift;
return OK unless $r->is_initial_req;
my ($res,$password) = $r->get_basic_auth_pw;
$r->log_reason("res is $res pword is $password ");
return $res if $res != OK;
my $username = $r->connection->user;
unless ($username && $pass)
{
$r->note_basic_auth_failure;
$r->log_reason("Did not provide username");
return AUTH_REQUIRED;
}
### check against database
return OK;
}
1;
thanks in advance
Kiran
_____________________________________________________
Chat with your friends as soon as they come online. Get Rediff Bol at
http://bol.rediff.com