I believe what you want is:

# To set the variable so that CGI scripts can access $ENV{'REMOTE_USER'}
# which is normally populated by Basic-Auth (this is only if you want to
# take control over the variable... populating it yourself)
#
$r->subprocess_env(REMOTE_USER => $user);

# To get the variable from the Apache request connection, you need to
# first populate %ENV
#
$r->subprocess_env;
my $user = $ENV{'REMOTE_USER'}

--
Devin

On Wed, 2009-09-30 at 16:16 +0200, Bernhard Janetzki wrote:
> Hello together,
> i'm trying basic authentication via
> 
> ## apache2 config:
>         <Location /auth>
>               SetHandler perl-script
>               PerlAuthenHandler DataExchange::AuthHandler
>               #PerlResponseHandler ModPerl::Registry
>               Options +ExecCGI
>               PerlOptions +GlobalRequest
> 
>               AuthType Basic
>               AuthName "The Gate"
>               Require valid-user
>         </Location>
> 
> 
> ## Example script:
> 
> package DataExchange::AuthHandler;
> 
> use strict;
> use warnings;
> 
> use Apache2::Access      ();
> use Apache2::RequestUtil ();
> 
> use Apache2::Const -compile => qw(OK HTTP_UNAUTHORIZED);
> 
> sub handler {
>     my $r = shift;
>     
>     warn $r->user();
>     
>        my $password = $r->get_basic_auth_pw;
> 
>     my $user = $r->user;    
>     if ($r->user eq $password) {
>         print Apache2::Const::OK;
>     }
> 
>     $r->note_basic_auth_failure;
>     return Apache2::Const::HTTP_UNAUTHORIZED;
> }
> 
> 1;
> 
> My password is filled up, but $r->user is undefined...
> Any ideas?
> 
> Thanks!
> Börni
> 
> p.s. mod_perl 2.0.4
-- 
Cheers,
Devin Teske

-> CONTACT INFORMATION <-
Field Engineer
Metavante Corporation
626-573-6040 Office
510-735-5650 Mobile
devin.te...@metavante.com

-> LEGAL DISCLAIMER <-
This message  contains confidential  and proprietary  information
of the sender,  and is intended only for the person(s) to whom it
is addressed. Any use, distribution, copying or disclosure by any
other person  is strictly prohibited.  If you have  received this
message in error,  please notify  the e-mail sender  immediately,
and delete the original message without making a copy.

-> END TRANSMISSION <-

Reply via email to