Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

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

by Punto (Scribe)
on Jun 12, 2000 at 02:33 UTC ( [id://17658]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


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

If you are using mod_perl, try this:

The server is running mod_perl (I can see "mod_perl" on the "server" part of the http responses), I tryed this:

#!/usr/bin/perl print "Content type: text/html\n\n"; $username = $r->connection->user; my($ret, $password) = $r->get_basic_auth_pw; print $password;
And I get an "Internal Server Error". Do I have to use some library or something on the script?

Thanks!

Replies are listed 'Best First'.
RE: RE: RE: Getting username and password from the URL.
by btrott (Parson) on Jun 12, 2000 at 02:37 UTC
    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.
RE: RE: RE: Getting username and password from the URL.
by jjhorner (Hermit) on Jun 12, 2000 at 02:50 UTC

    While btrott's answer was right, I thought I would send you to a real world example here.

    J. J. Horner
    Linux, Perl, Apache, Stronghold, Unix
    jhorner@knoxlug.org http://www.knoxlug.org/
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://17658]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.