Home > Archive > PERL Beginners > September 2007 > mod perl
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| George 2007-09-24, 7:01 pm |
| Hello All,
I'm having a problem with modperl and I can't figure out if it's my
stupiditry or modperls'. I'd love somebody with some modperl foo to
give me a hand.
First, the config:
rembox# cat /etc/redhat-release
Red Hat Enterprise Linux ES release 4 (Nahant Update 4)
rembox# rpm -qa | egrep 'http|mod_perl'
httpd-2.0.52-32.3.ent
httpd-devel-2.0.52-32.3.ent
mod_perl-1.99_16-4.5
httpd-suexec-2.0.52-32.3.ent
rembox# cat /etc/httpd/conf.d/perl.conf | egrep -v "^#"
LoadModule perl_module modules/mod_perl.so
Alias /perlremedy /opt/arsperl/scripts/htdocs/
PerlModule ModPerl::Registry
PerlSwitches -I/opt/arsperl/scripts/htdocs/sec/
PerlModule Apache::compat
<Directory /opt/arsperl/scripts/htdocs/*.pl>
SetHandler perl-script
PerlResponseHandler ModPerl::Registry
Options ExecCGI
PerlOptions +ParseHeaders
</Directory>
<Directory /opt/arsperl/scripts/htdocs/sec/>
SetHandler perl-script
PerlResponseHandler ModPerl::Registry
PerlAuthenHandler My::AuthTest
Options ExecCGI
PerlOptions +ParseHeaders +GlobalRequest
AuthType Basic
AuthName "Remedy access"
Require valid-user
</Directory>
<Location /perl-status>
SetHandler perl-script
PerlResponseHandler Apache::Status
Order deny,allow
Deny from all
Allow from .your-domain.com
</Location>
Here's the contents of My::AuthTest:
package My::AuthTest;
use Data::Dumper;
use Apache::Access;
use Apache::Const -compile => qw(OK DECLINED HTTP_UNAUTHORIZED);
use strict;
sub handler {
my $r = shift ;
open (FOO, ">/tmp/foo.george");
# get the client-supplied credentials
my $username = $r->user;
my ($status, $password) = $r->get_basic_auth_pw;
print FOO Dumper($username);
print FOO Dumper($password);
print FOO Dumper($status);
close FOO;
# only continue if apache says everything is OK
return $status unless $status == Apache::OK;
# Until we figure how to get the username, lets just return OK.
return Apache::OK;
}
1;
That handler lets the auth through so it's somewhat working. The
problem is $username is undef so I can't actually test a login or
anything. If I try get access to it from a script that's run after the
auth (ie, the actual request), then it's not blank and I can see the
username. I've also tried $r->connection->user;
I've read a whole bunch of the docs, but what seems to be provided by
RedHat bears to reference to what's on the interweb.
Can somebody tell me what I'm missing?
Cheers!
George
| |
| Matthew Whipple 2007-09-24, 7:01 pm |
| It appears as though the user method only returns a value after
successful authentication while you're trying to get it before.
George wrote:
> Hello All,
>
> I'm having a problem with modperl and I can't figure out if it's my
> stupiditry or modperls'. I'd love somebody with some modperl foo to
> give me a hand.
>
> First, the config:
>
> rembox# cat /etc/redhat-release
> Red Hat Enterprise Linux ES release 4 (Nahant Update 4)
>
> rembox# rpm -qa | egrep 'http|mod_perl'
> httpd-2.0.52-32.3.ent
> httpd-devel-2.0.52-32.3.ent
> mod_perl-1.99_16-4.5
> httpd-suexec-2.0.52-32.3.ent
>
> rembox# cat /etc/httpd/conf.d/perl.conf | egrep -v "^#"
> LoadModule perl_module modules/mod_perl.so
>
> Alias /perlremedy /opt/arsperl/scripts/htdocs/
>
> PerlModule ModPerl::Registry
> PerlSwitches -I/opt/arsperl/scripts/htdocs/sec/
> PerlModule Apache::compat
>
> <Directory /opt/arsperl/scripts/htdocs/*.pl>
> SetHandler perl-script
> PerlResponseHandler ModPerl::Registry
> Options ExecCGI
> PerlOptions +ParseHeaders
> </Directory>
>
> <Directory /opt/arsperl/scripts/htdocs/sec/>
> SetHandler perl-script
> PerlResponseHandler ModPerl::Registry
> PerlAuthenHandler My::AuthTest
> Options ExecCGI
> PerlOptions +ParseHeaders +GlobalRequest
>
> AuthType Basic
> AuthName "Remedy access"
> Require valid-user
> </Directory>
>
> <Location /perl-status>
> SetHandler perl-script
> PerlResponseHandler Apache::Status
> Order deny,allow
> Deny from all
> Allow from .your-domain.com
> </Location>
>
> Here's the contents of My::AuthTest:
>
> package My::AuthTest;
> use Data::Dumper;
> use Apache::Access;
> use Apache::Const -compile => qw(OK DECLINED HTTP_UNAUTHORIZED);
> use strict;
>
> sub handler {
> my $r = shift ;
> open (FOO, ">/tmp/foo.george");
>
> # get the client-supplied credentials
> my $username = $r->user;
> my ($status, $password) = $r->get_basic_auth_pw;
>
> print FOO Dumper($username);
> print FOO Dumper($password);
> print FOO Dumper($status);
>
> close FOO;
>
> # only continue if apache says everything is OK
> return $status unless $status == Apache::OK;
>
> # Until we figure how to get the username, lets just return OK.
> return Apache::OK;
>
> }
>
> 1;
>
> That handler lets the auth through so it's somewhat working. The
> problem is $username is undef so I can't actually test a login or
> anything. If I try get access to it from a script that's run after
> the auth (ie, the actual request), then it's not blank and I can see
> the username. I've also tried $r->connection->user;
>
> I've read a whole bunch of the docs, but what seems to be provided by
> RedHat bears to reference to what's on the interweb.
>
> Can somebody tell me what I'm missing?
>
> Cheers!
>
> George
>
>
>
| |
| George 2007-09-24, 7:01 pm |
| Hi,
I found the answer on another perl mongers list.
I needed to swap the user and passwd. $r->user isn't available until
after $r->get_basic_auth_pw has been called.
Cheers!
George
Matthew Whipple wrote:
> It appears as though the user method only returns a value after
> successful authentication while you're trying to get it before.
>
> George wrote:
>
| |
| Dr.Ruud 2007-09-24, 10:03 pm |
| George schreef:
> I'm having a problem with modperl and I can't figure out if it's my
> stupiditry or modperls'. I'd love somebody with some modperl foo to
> give me a hand.
See
[url]http://london.pm.org/pipermail/london.pm/W -of-Mon-20070924/010069.html[/url]
--
Affijn, Ruud
"Gewoon is een tijger."
|
|
|
|
|