You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by "Neil A. Hillard" <ne...@agustawestland.com> on 2008/02/13 17:55:09 UTC

[users@httpd] mod_perl, PerlAuthenHandler and REMOTE_USER

Hi,

	I've been having a dabble, using a perl module to handle some of our 
authentication requirements.  I have the perl auth handler working 
successfully but the username is not logged in access_log.

I have the following code in my perl module:

my $username = "test_user";
$r->user($username);

return OK;

I can see from my PHP script that the REMOTE_USER variable has been set 
successfully.

I am using the following LogFormat for access_log:

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" 
combined

Any pointers as to how I can get the username logged in access_log?

Many thanks in advance,


				Neil.

-- 
Neil Hillard                    neil.hillard@agustawestland.com
AgustaWestland                  http://www.whl.co.uk/

Disclaimer: This message does not necessarily reflect the
             views of Westland Helicopters Ltd.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] mod_perl, PerlAuthenHandler and REMOTE_USER

Posted by "Neil A. Hillard" <ne...@agustawestland.com>.
Craig,

Craig Dunigan wrote:
> On Wed, 13 Feb 2008, Neil A. Hillard wrote:
> 
>> Hi,
>>
>>     I've been having a dabble, using a perl module to handle some of 
>> our authentication requirements.  I have the perl auth handler working 
>> successfully but the username is not logged in access_log.
>>
>> I have the following code in my perl module:
>>
>> my $username = "test_user";
>> $r->user($username);
>>
>> return OK;
>>
>> I can see from my PHP script that the REMOTE_USER variable has been 
>> set successfully.
>>
>> I am using the following LogFormat for access_log:
>>
>> LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" 
>> \"%{User-Agent}i\"" combined
>>
>> Any pointers as to how I can get the username logged in access_log?
>>
>> Many thanks in advance,
>>
>>
>>                 Neil.
>>
>>
> 
> I found it necessary to do the following in my Perl auth handler as well 
> as $r->user($username) (assuming Apache2 API):
> 
> $r->subprocess_env('REMOTE_USER' => $username);

> $r->set_basic_credentials($username, $password);

Bingo - that's the one.  As password doesn't make sense I've set it to 
"" and it works a treat.


> I can't exactly recall the reasons, something about which process 
> (parent or child) writes the environment variables vs. which process 
> does the logging, or perhaps the order in which Apache sets variables 
> and writes to the log.  Or perhaps it was just overkill on my part, not 
> wanting to miss anything.  But it's working for me.

Many thanks,


				Neil.

-- 
Neil Hillard                    neil.hillard@agustawestland.com
AgustaWestland                  http://www.whl.co.uk/

Disclaimer: This message does not necessarily reflect the
             views of Westland Helicopters Ltd.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] mod_perl, PerlAuthenHandler and REMOTE_USER

Posted by Craig Dunigan <cd...@doit.wisc.edu>.
On Wed, 13 Feb 2008, Neil A. Hillard wrote:

> Hi,
>
> 	I've been having a dabble, using a perl module to handle some of our 
> authentication requirements.  I have the perl auth handler working 
> successfully but the username is not logged in access_log.
>
> I have the following code in my perl module:
>
> my $username = "test_user";
> $r->user($username);
>
> return OK;
>
> I can see from my PHP script that the REMOTE_USER variable has been set 
> successfully.
>
> I am using the following LogFormat for access_log:
>
> LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" 
> combined
>
> Any pointers as to how I can get the username logged in access_log?
>
> Many thanks in advance,
>
>
> 				Neil.
>
>

I found it necessary to do the following in my Perl auth handler as 
well as $r->user($username) (assuming Apache2 API):

$r->subprocess_env('REMOTE_USER' => $username);
$r->set_basic_credentials($username, $password);

I can't exactly recall the reasons, something about which process 
(parent or child) writes the environment variables vs. which process 
does the logging, or perhaps the order in which Apache sets variables 
and writes to the log.  Or perhaps it was just overkill on my part, 
not wanting to miss anything.  But it's working for me.


-- 
Craig Dunigan
IS Technical Services Specialist
Middleware - EIS - DoIT
University of Wisconsin, Madison

opinions expressed are my own, not the University's


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org