Hi.
I am writing a new PerlAuthHandler module.
It is working fine in most cases, but..
In an attempt at being clever, I put the following code in the handler :
unless ($r->is_initial_req) {
if (defined $r->prev) {
# we are in a subrequest. Just copy user from main request.
$r->user( $r->prev->user );
}
# Also disable authorization phase
$r->set_handlers(PerlAuthzHandler => undef);
return OK;
}
The idea being that if we are in a sub-request, there is no point in
authenticating/authorizing it again, since the main request should
already do that, right ? Optimisation..
Now the above works very nicely, except in the case where, before this
handler gets called, there is an intervention by mod_rewrite.
It seems as if mod_rewrite makes the above fail, even when the rewrite
condition does not apply and the URL is considered as a "pass-through".
I suspect that it is because mod_rewrite, no matter what, invoques the
original (or modified) URL as a sub-request of the original request.
This would cause the above to fail, because in such a case, the above
conditional code would be invoked, but there is no $r->prev->user to be
copied.
So,
1) is my suspicion above correct ?
2) is there a way to modify the above code to still allow some
optimisation in that case ?
Thanks.