Charlie Smith wrote:
> Guess I'm talking to myself on this one. I'll change the subject and try
> again. Please let me clarify.   I need to grab the user's username and
> password in order to send an http request out to a protected site.  The
> site happens to be the same one the LWP request is being sent from, so I
> can use the credentials of the user.  Trouble is, I'm not sure how to
> grab the username and password.  If in php you can just reference the
> http_server_vars['php_auth_user'] and
> http_server_vars['php_auth_passwd'].  How is this done with mod_perl?

try looking at the code from

http://www.modperlcookbook.org/code/ch13/Cookbook/AuthHandler.pm

it's in an authentication module, but the username/password stuff can be
pulled out.

> 
> 
>>>> "Charlie Smith" <[EMAIL PROTECTED]> 12/01/03 08:17AM >>>
> 
> In one scenario, I'll redirect the user to another page using LWP.  So,
> I'd like to get the user credentials in order to authenticate the user.
> Does PERL have a way to get the credentials from an HTTP_SERVER_VARS hash
> or from the httpd password file (decrypted password)?

you don't have to do that.  instead, try passing on the Authorization header
from the initial response, which you can get from
$r->headers_in->get('Authorization').

something like this

  $r->headers_in->do(sub {
    $request->header(@_);
    1;
  });

where $request is an HTTP::Request object, might be able to help as well -
it reproduces all the incoming headers from the incoming request and uses
them for the remote request you're about to make.  a larger example that
might be able to help is here

http://www.modperlcookbook.org/code/ch05/Cookbook/SubRequestContent.pm

> 
> Also, is there a way to tell if user is using http or https before making
> call to LWP?

$r->subprocess_env('HTTPS')

HTH

--Geoff


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html

Reply via email to