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

Reply via email to