2016-01-25 19:03:48 +01:00
|
|
|
package Lemonldap::NG::Handler::PSGI::Server;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use Mouse;
|
2016-01-26 07:14:54 +01:00
|
|
|
use Lemonldap::NG::Handler::SharedConf qw(:tsv);
|
2016-01-25 19:03:48 +01:00
|
|
|
|
|
|
|
extends 'Lemonldap::NG::Handler::PSGI';
|
|
|
|
|
|
|
|
sub router {
|
|
|
|
return [ 200, [], [] ];
|
|
|
|
}
|
|
|
|
|
|
|
|
sub _run {
|
|
|
|
my $self = shift;
|
2016-01-26 07:14:54 +01:00
|
|
|
return sub {
|
|
|
|
my $req = $_[0];
|
|
|
|
$self->lmLog( 'New request', 'debug' );
|
2016-01-28 07:43:46 +01:00
|
|
|
my $res = $self->_authAndTrace(
|
|
|
|
Lemonldap::NG::Common::PSGI::Request->new( $_[0] ) );
|
2016-01-26 07:14:54 +01:00
|
|
|
|
2016-01-29 12:09:55 +01:00
|
|
|
# Transform 302 responses in 401 since Nginx refuse it
|
|
|
|
if($res->[0] == 302 or $res->[0] == 303) {
|
|
|
|
$res->[0] = 401;
|
|
|
|
push @{$res->[1]},'X-Location' => $tsv->{portal}
|
|
|
|
}
|
|
|
|
|
2016-01-26 07:14:54 +01:00
|
|
|
# TODO: transform headers in $res->[1]
|
|
|
|
return $res;
|
|
|
|
};
|
2016-01-25 19:03:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
1;
|