You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by "Levi E. Stanley" <le...@eneservices.com> on 2005/04/07 13:13:19 UTC
Authentication problem
Hi,
Been seeing problems with an Authenticate script lately. It was working
fine up to the time I started getting slammed with traffic. I don't see
any connection problems in the log file at all. But what I have noticed
on the site is, I will click to go to download a file from the secure
area, and it won't prompt me for a username and password until minutes
later, like it is being delayed or something. Is this normal behavior
from high traffic?
More Info:
The server isn't even being over worked, it has 4 cpus and on high
traffic hours, it is around 2 on cpu load. So it can only be two
possibilities, the script or apache configuration. The apache version I
am using http-2.0.53, and mod_perl-2.0.0-RC4.
Here is the code:
package My::Authenticate;
use strict;
use ModPerl::Util ();
use Apache::Const qw(OK DECLINED AUTH_REQUIRED);
use Apache::Log;
use DBI;
sub handler{
my $r = shift;
my $s = Apache->server;
return Apache::DECLINED unless $r->is_initial_req;
my ($status,$password) = $r->get_basic_auth_pw;
my $username = $r->user;
return $status unless $status == Apache::OK;
my $hostname = $r->hostname;
$hostname=~/(.*?\.)?(.*?)\.[a-z]{3}$/;
my $table_access = $2."_access";
my $dbh =
DBI->connect('DBI:mysql:database=site_authentication;host=xxx.xxx.xxx.xxx','xxx','xxx');
my $rs = $dbh->prepare("select 1 from $table_access where
username='$username' and passwd='$password'");
$rs->execute;
my ($result) = $rs->fetchrow_array;
$rs->finish();
$dbh->disconnect();
if ($result){
return Apache::OK;
}
$r->note_basic_auth_failure;
return Apache::AUTH_REQUIRED;
}
1;
Any assistance on this issue would be greatly appreciated.