Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

RE: RE: RE: Getting username and password from the URL.

by btrott (Parson)
on Jun 12, 2000 at 06:37 UTC ( [id://17659]=note: print w/replies, xml ) Need Help??

in reply to RE: RE: Getting username and password from the URL.
in thread Getting username and password from the URL.

Yes, you'll need to get the $r object, which you don't have in your script. $r is the Apache request record.

You should set up your script as an Apache::Registry script. Then you can get $r like this:

my $r = Apache->request;
To set the script up as Apache::Registry, add something like this to httpd.conf:
<Location /perl> SetHandler perl-script PerlHandler Apache::Registry Options +ExecCGI </Location>
This sets up the perl subroutine under the document root to run under Apache::Registry. So put your script there.

Or, if you set up a mod_perl handler, your handler subroutine will be passed $r.

For example, you might set up a handler thusly in your httpd.conf:

<Location /foo> SetHandler perl-script PerlHandler My::Foo </Location>
And then in My::Foo:
package My::Foo; use strict; sub handler { my $r = shift; my $user = $r->connection->user; my($ret, $password) = $r->get_basic_auth_pw; $r->send_http_header; $r->print($user); $r->print($password); } 1;
I'd recommend trying the first approach.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://17659]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-05-18 15:28 GMT
Find Nodes?
    Voting Booth?

    No recent polls found