Kwik Wrote:Just want to mention that a password protection is a MUST HAVE, please, please. I will use BeNes workaround meanwhile. ^^
What about using a combination of perl and htaccess?
If someone may enhance this script, it might be a solution.
http://perl.apache.org/docs/1.0/guide/se...e_snippets
inserted into a .htaccess file
Code:
PerlModule My::Auth
<Location /private>
PerlAccessHandler My::Auth::access_handler
PerlSetVar Intranet "10.10.10.1 => userA, 10.10.10.2 => userB"
PerlAuthenHandler My::Auth::authen_handler
AuthName realm
AuthType Basic
Require valid-user
Order deny, allow
Deny from all
</Location>
Now the code of My/Auth.pm:
Code:
sub access_handler {
my $r = shift;
unless ($r->some_auth_required) {
$r->log_reason("No authentication has been configured");
return FORBIDDEN;
}
# get list of IP addresses
my %ips = split /\s*(?:=>|,)\s*/, $r->dir_config("Intranet");
if (my $user = $ips{$r->connection->remote_ip}) {
# update connection record
$r->connection->user($user);
# do not ask for a password
$r->set_handlers(PerlAuthenHandler => [\&OK]);
}
return OK;
}
sub authen_handler {
my $r = shift;
# get user's authentication credentials
my ($res, $sent_pw) = $r->get_basic_auth_pw;
return $res if $res != OK;
my $user = $r->connection->user;
# authenticate through DBI
my $reason = authen_dbi($r, $user, $sent_pw);
if ($reason) {
$r->note_basic_auth_failure;
$r->log_reason($reason, $r->uri);
return AUTH_REQUIRED;
}
return OK;
}
sub authen_dbi{
my ($r, $user, $sent_pw) = @_;
# validate username/passwd
return 0 if (*PASSED*) # replace with real code!!!
return "Failed for X reason";
}
# don't forget 1;
1;