2008/6/25 titetluc titetluc <[EMAIL PROTECTED]>:

> Hello all
>
> I am writing a Perl module to authenticate users (using mod_perl2 and httpd
> 2.2.6.
> I would like to display the user name (r->user) when accessing a directory
> (/test_index/index.html)
>
> I have the following httpd configuration
>
> <Location /test_index>
>     DirectoryIndex index.html
>     Options +indexes
> </Location>
>
> PerlModule Test
> <Location /test_index/index.html>
>     Require valid-user
>     AuthType basic
>     AuthName test_index
>     SetHandler perl-script
>
>     PerlAuthenHandler Apache2::AuthSSO::Test->set_user
>
>     PerlResponseHandler Apache2::AuthSSO::Test->display_user
> </Location>
>
> In addition, I added an empty index.html file in the htdocs/test_index
> directory
>
> The Perl Test module is
>
> package Test;
> use warnings;
> use strict;
> use Carp;
>
> use Apache2::Const qw(:common);
>
> sub set_user {
>     my ($self, $r) = @_;
>     $r->user('myself');
>     return OK;
> }
> sub display_user {
>     my ($self, $r) = @_;
>     my $user = defined $r->user ? $r->user : 'user is not defined';
>     print $user;
>     return OK;
> }
>
> 1;
>
> When I access with my browser to http://localhost/test_index/index.html,
> user is set to 'myself'
> BUT when I access with my browser to http://localhost/test_index/ ... user
> is not defined !!!
>
> I don't know if the problem comes from mod_perl or from the httpd
> configuration.
> Any help would be appreciated.
>
> Thanks
>


I found a thread related to directory indexes (
http://marc.info/?l=apache-modperl&m=119996305532711&w=2)
According to this thread, user information could be retrieved with
$r->main->user

But in my configuration, when accessing to http://localhost/test_index/,
$r->main is always undefined in the PerlResponseHandler !!!!

Please help

Thanks

Reply via email to