You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Martijn <sw...@googlemail.com> on 2007/06/28 15:46:01 UTC
PerlAuthenHandler PerlAuthzHandler in mod_perl 2.0
Hello.
I'm doing some testing/debugging on a newly built server (Apache
2.0.52, mod_perl 2.0.3) and find that both PerlAuthenHandler and
PerlAuthzHandler are ignored. The weird thing is: other Perl*Handlers,
including PerlAccessHandler, work as expected (expected by me, that
is): they block access to mydomain.com/test in the setup copied below
and write a line in error_log.
I am afraid I am making a stupid mistake somewhere, but I can't find
where. Any help would be greatly appreciated.
Thanks.
Martijn.
-------
In httpd.conf:
PerlModule Testhandler
<Location /test>
# PerlAccessHandler TestHandler
# the above line *does* block access
PerlAuthenHandler TestHandler
PerlAuthzHandler TestHandler
# same problem if only one of the two lines occurs
</Location>
-------
Testhandler.pm:
package TestHandler;
use strict;
use Apache2::Log;
use Apache2::Const qw(:common :remotehost OK FORBIDDEN);
use Apache2::RequestRec ();
sub handler {
my ($r) = shift;
my $url = $r->uri;
$r->log_error('You are visiting ' . $url . '!');
return FORBIDDEN;
# DECLINED instead of FORBIDDEN doesn't work either
}
1;
Re: PerlAuthenHandler PerlAuthzHandler in mod_perl 2.0
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
Martijn wrote:
> Hello.
>
> I'm doing some testing/debugging on a newly built server (Apache
> 2.0.52, mod_perl 2.0.3) and find that both PerlAuthenHandler and
> PerlAuthzHandler are ignored.
>
> <Location /test>
> # PerlAccessHandler TestHandler
> # the above line *does* block access
> PerlAuthenHandler TestHandler
> PerlAuthzHandler TestHandler
> # same problem if only one of the two lines occurs
> </Location>
you need a Require directive for apache's auth* hooks to run. see the
introduction to chapter 13 of the mod_perl cookbook here
http://www.modperlcookbook.org/chapters/ch13.pdf
and the rest of the chapter as well, if you're interested. the concepts
are the same between httpd 1.3 and 2.0, though the code will require a
bit of modification for mod_perl 2.0.
HTH
--Geoff
Re: PerlAuthenHandler PerlAuthzHandler in mod_perl 2.0
Posted by Martijn <sw...@googlemail.com>.
> http://perl.apache.org/docs/2.0/user/handlers/http.html is your friend...
>
> Authen is only called if there is a 'require' and AuthType/AuthName
> directive,
> Authz is only called if Authen is successful.
Thanks to you both, this does help a lot. In this particular case, I
was only interested in the fact whether these phases were run. Since
PerlAccessHandler and PerlFixupHandler both run, they must run too (I
was suspicious the order of the Apache request cycle or the names of
the mod_perl directives might have changed in 2.0 or something...).
But reading this does help me a great deal understanding mod_perl in
general. And yes, I too wonder why I had never done it in the past. :)
Martijn
Re: PerlAuthenHandler PerlAuthzHandler in mod_perl 2.0
Posted by John ORourke <jo...@o-rourke.org>.
Geoffrey Young wrote:
>
>> and AuthType/AuthName
>> directive,
>>
>
> but that is not :) you might run into trouble if you don't define those
> directives, but their absence won't prevent the auth phases from running.
>
Interesting and useful! In that case we need a doc patch - see
http://perl.apache.org/docs/2.0/user/handlers/http.html#PerlAuthenHandler
"The check_user_id (authen) phase is called whenever the requested file
or directory is password protected. This, in turn, requires that the
directory be associated with AuthName, AuthType and at least one require
directive."
cheers
John
Re: PerlAuthenHandler PerlAuthzHandler in mod_perl 2.0
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
for the record
> Authen is only called if there is a 'require'
that's true
> and AuthType/AuthName
> directive,
but that is not :) you might run into trouble if you don't define those
directives, but their absence won't prevent the auth phases from running.
--Geoff
Re: PerlAuthenHandler PerlAuthzHandler in mod_perl 2.0
Posted by John ORourke <jo...@o-rourke.org>.
Hi Martijn,
http://perl.apache.org/docs/2.0/user/handlers/http.html is your friend...
Authen is only called if there is a 'require' and AuthType/AuthName
directive,
Authz is only called if Authen is successful.
cheers
John
Martijn wrote:
> Hello.
>
> I'm doing some testing/debugging on a newly built server (Apache
> 2.0.52, mod_perl 2.0.3) and find that both PerlAuthenHandler and
> PerlAuthzHandler are ignored. The weird thing is: other Perl*Handlers,
> including PerlAccessHandler, work as expected (expected by me, that
> is): they block access to mydomain.com/test in the setup copied below
> and write a line in error_log.
>
> I am afraid I am making a stupid mistake somewhere, but I can't find
> where. Any help would be greatly appreciated.