plack / Plack

PSGI toolkit and server adapters
http://plackperl.org/
Other
486 stars 214 forks source link

Authen::Basic Middleware doesn't seem to work #702

Closed briankwest closed 8 months ago

briankwest commented 8 months ago
my $app = sub { .. }

sub authenticator {
    my ($ausername, $apassword, $env) = @_;
    print STDERR "\nAuthenticating $ausername\n";

    return $ausername eq 'admin' && $apassword eq 'secret';
}

my $server = builder {
    enable "Auth::Basic", authenticator => \&authenticator;
    $app;
};
# Running the PSGI application                                                                                                                                                                                                                               
my $runner = Plack::Runner->new;

$runner->parse_options('-s', 'Twiggy');

$runner->run($server);

When the username and password are correct I receive:

Response should be array ref or code ref: at /app/local/lib/perl5/Plack/Middleware/Lint.pm line 120 Plack::Middleware::Lint::validate_res('Plack::Middleware::Lint=HASH(0x55b14e4399a8)', '') called at /app/local/lib/perl5/Plack/Middleware/Lint.pm line 40

I have http auth on two paths, tried to insert debug to sort what is going on but seems when the authenticate is successful Plack::Middleware::Lint::validate_res bails.

Any help would be appreciated.

briankwest commented 8 months ago

I found the problem, code to handle this was nested in an extra curley brace so it was out of scope.