Quoting Marcel Weber <[EMAIL PROTECTED]> [12 Feb-02 16:15]:
> I don't get the point why it did not work the other way round,
> but now everything is just fine now :

Make it a little more generic:

package Apache::MultiAuthen;

use strict;
use Apache::Constants qw(:common);

sub handler {
    my $r = shift;
    my($res, $sent_pw) = $r->get_basic_auth_pw;
    return $res if $res != OK;

    # Tweak this; unsure about dir_config returning an array
    my @auth_modules = $r->dir_config("AuthModules");

    for my $am (@auth_modules) {
        load($am);

        if ($@) {
            $r->log("Error loading module '$am': $@");
            next;
        }

        my $handler = \&{"$am\::handler"};
        if ($handler->($r) == OK) {
            $r->log_reason("$am return OK");
            return OK
        }

        $r->log_reason("$am not OK");
    }

    $r->note_basic_auth_failure;
    return AUTH_REQUIRED;
}

sub load {
    my $module = @_;
    $module  =~ s[::][/]g;
    $module .= '.pm';

    eval { require $module; };
    
    return $@ ? 1 : 0;
}

1;

__END__

(darren)

-- 
Never attribute to malice that which is adequately explained by
incompetence.
    -- Napolean Bonaparte

Reply via email to