| 1 | package Plack::Middleware::Auth::LemonldapNG; | ||
| 2 | |||
| 3 | our $AUTHORITY = 'cpan:GUIMARD'; | ||
| 4 | our $VERSION = '2.23.0'; | ||
| 5 | our $llclass = 'Lemonldap::NG::Handler::Server'; | ||
| 6 | |||
| 7 | use strict; | ||
| 8 | use base qw(Plack::Middleware); | ||
| 9 | use Plack::Util; | ||
| 10 | use Plack::Util::Accessor qw( | ||
| 11 | llhandler | ||
| 12 | llparams | ||
| 13 | on_reject | ||
| 14 | ); | ||
| 15 | |||
| 16 | sub prepare_app { | ||
| 17 | my ($self) = @_; | ||
| 18 | Plack::Util::load_class($llclass); | ||
| 19 | $self->llhandler( $llclass->run( $self->llparams ) ); | ||
| 20 | } | ||
| 21 | |||
| 22 | sub call { | ||
| 23 | my ( $self, $env ) = @_; | ||
| 24 | my $res = $self->llhandler->($env); | ||
| 25 | my $rejApp = $self->on_reject; | ||
| 26 | unless ( $res->[0] == 200 ) { | ||
| 27 | if ($rejApp) { | ||
| 28 | return $self->$rejApp( $env, $res ); | ||
| 29 | } | ||
| 30 | else { | ||
| 31 | return $res; | ||
| 32 | } | ||
| 33 | } | ||
| 34 | my $app = $self->app; | ||
| 35 | @_ = $env; | ||
| 36 | goto $app; | ||
| 37 | } | ||
| 38 | |||
| 39 | __PACKAGE__; | ||
| 40 | __END__ |