> I need apache to do this: always ask for authentication, accept any
> username/password as valid, and set an enviroment variable with the
> password, so I can retrieve it on a CGI script later. I wrote this code:

You're on the right track; put this code into it's own module, and run it.
This should work:

package Test::AuthAny;

use strict;
use Apache::Constants qw( OK AUTH_REQUIRED );

sub handler {
    my $r = shift;
    my ($u,$p) = ($r->connection->user,($r->get_basic_auth_pw)[1]); 

    if ($u && $p) {
        $r->subprocess_env(USERNAME => $u);
        $r->subprocess_env(PASSWORD => $p);
        return OK;
    } else {
        $r->note_basic_auth_failure;
        $r->log_reason("username and password don't match");
        return AUTH_REQUIRED;
    }
}
1;
__END__


Install it as a PerlAuthenHandler for /auth/ like so:

<Location /auth>
    # Any other directievs you might have here already ...
    AuthType          Basic
    AuthName          "Name of the Authentcation Realm" 
    require           valid-user
    PerlAuthenHandler Test::AuthAny
</Location>

Now, from your CGI scripts, or SSI's, or whatever, you can grab $ENV{USERNAME}
and $ENV{PASSWORD} and use them.

> Thanks.. Bye.
> 
> Ariel.

darren

-- 
There are worse things in life than death. Have you ever spent an
evening with an insurance salesman?
-- Woody Allen

Reply via email to