Tidy
This commit is contained in:
parent
7a83f4e84b
commit
4ebcae3e15
|
@ -53,9 +53,8 @@ sub load {
|
||||||
my ( $self, $cfgNum, $fields ) = @_;
|
my ( $self, $cfgNum, $fields ) = @_;
|
||||||
$fields = $fields ? join( ",", @$fields ) : '*';
|
$fields = $fields ? join( ",", @$fields ) : '*';
|
||||||
my $sth =
|
my $sth =
|
||||||
$self->_dbh->prepare( "SELECT field,value from "
|
$self->_dbh->prepare(
|
||||||
. $self->{dbiTable}
|
"SELECT field,value from " . $self->{dbiTable} . " WHERE cfgNum=?" );
|
||||||
. " WHERE cfgNum=?" );
|
|
||||||
$sth->execute($cfgNum);
|
$sth->execute($cfgNum);
|
||||||
my ( $res, @row );
|
my ( $res, @row );
|
||||||
while ( @row = $sth->fetchrow_array ) {
|
while ( @row = $sth->fetchrow_array ) {
|
||||||
|
|
|
@ -48,7 +48,8 @@ sub run {
|
||||||
return $class->REDIRECT;
|
return $class->REDIRECT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $class->Lemonldap::NG::Handler::Main::run( $req, $rule, $protection );
|
return $class->Lemonldap::NG::Handler::Main::run( $req, $rule,
|
||||||
|
$protection );
|
||||||
}
|
}
|
||||||
|
|
||||||
## @rmethod protected hash getCDAInfos(id)
|
## @rmethod protected hash getCDAInfos(id)
|
||||||
|
|
|
@ -25,16 +25,21 @@ sub register {
|
||||||
if ( my $orig = LWP::Protocol::implementor($proto) ) {
|
if ( my $orig = LWP::Protocol::implementor($proto) ) {
|
||||||
$orig{$proto} = $orig;
|
$orig{$proto} = $orig;
|
||||||
LWP::Protocol::implementor( $proto, $class );
|
LWP::Protocol::implementor( $proto, $class );
|
||||||
} else {
|
}
|
||||||
Carp::carp("LWP::Protocol::$proto is unavailable. Skip registering overrides for it.") if $^W;
|
else {
|
||||||
|
Carp::carp(
|
||||||
|
"LWP::Protocol::$proto is unavailable. Skip registering overrides for it."
|
||||||
|
) if $^W;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( defined wantarray ) {
|
if ( defined wantarray ) {
|
||||||
return LWP::Protocol::PSGI::Guard->new(sub {
|
return LWP::Protocol::PSGI::Guard->new(
|
||||||
|
sub {
|
||||||
$class->unregister_app($app);
|
$class->unregister_app($app);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +56,6 @@ sub unregister_app {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sub unregister {
|
sub unregister {
|
||||||
my $class = shift;
|
my $class = shift;
|
||||||
for my $proto (@protocols) {
|
for my $proto (@protocols) {
|
||||||
|
@ -71,8 +75,10 @@ sub request {
|
||||||
my $content = $response->content;
|
my $content = $response->content;
|
||||||
$response->content('');
|
$response->content('');
|
||||||
$self->collect_once( $arg, $response, $content );
|
$self->collect_once( $arg, $response, $content );
|
||||||
} else {
|
}
|
||||||
$orig{$self->{scheme}}->new($self->{scheme}, $self->{ua})->request($request, $proxy, $arg, @rest);
|
else {
|
||||||
|
$orig{ $self->{scheme} }->new( $self->{scheme}, $self->{ua} )
|
||||||
|
->request( $request, $proxy, $arg, @rest );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,8 +99,7 @@ sub handles {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
package
|
package LWP::Protocol::PSGI::Guard;
|
||||||
LWP::Protocol::PSGI::Guard;
|
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
|
@ -107,8 +112,7 @@ sub DESTROY {
|
||||||
$self->();
|
$self->();
|
||||||
}
|
}
|
||||||
|
|
||||||
package
|
package LWP::Protocol::PSGI::App;
|
||||||
LWP::Protocol::PSGI::App;
|
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
|
@ -118,16 +122,20 @@ sub new {
|
||||||
|
|
||||||
sub app { $_[0]->{app} }
|
sub app { $_[0]->{app} }
|
||||||
sub options { $_[0]->{options} }
|
sub options { $_[0]->{options} }
|
||||||
|
|
||||||
sub match {
|
sub match {
|
||||||
my ( $self, $request ) = @_;
|
my ( $self, $request ) = @_;
|
||||||
my $options = $self->options;
|
my $options = $self->options;
|
||||||
|
|
||||||
if ( $options->{host} ) {
|
if ( $options->{host} ) {
|
||||||
my $matcher = $self->_matcher( $options->{host} );
|
my $matcher = $self->_matcher( $options->{host} );
|
||||||
$matcher->($request->uri->host) || $matcher->($request->uri->host_port);
|
$matcher->( $request->uri->host )
|
||||||
} elsif ($options->{uri}) {
|
|| $matcher->( $request->uri->host_port );
|
||||||
|
}
|
||||||
|
elsif ( $options->{uri} ) {
|
||||||
$self->_matcher( $options->{uri} )->( $request->uri );
|
$self->_matcher( $options->{uri} )->( $request->uri );
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
1;
|
1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,11 +144,14 @@ sub _matcher {
|
||||||
my ( $self, $stuff ) = @_;
|
my ( $self, $stuff ) = @_;
|
||||||
if ( ref $stuff eq 'Regexp' ) {
|
if ( ref $stuff eq 'Regexp' ) {
|
||||||
sub { $_[0] =~ $stuff };
|
sub { $_[0] =~ $stuff };
|
||||||
} elsif (ref $stuff eq 'CODE') {
|
}
|
||||||
|
elsif ( ref $stuff eq 'CODE' ) {
|
||||||
$stuff;
|
$stuff;
|
||||||
} elsif (!ref $stuff) {
|
}
|
||||||
|
elsif ( !ref $stuff ) {
|
||||||
sub { $_[0] eq $stuff };
|
sub { $_[0] eq $stuff };
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
Carp::croak( "Don't know how to match: ", ref $stuff );
|
Carp::croak( "Don't know how to match: ", ref $stuff );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,7 +213,8 @@ sub run {
|
||||||
}
|
}
|
||||||
my ( $err, $error ) = $self->loadUser($req);
|
my ( $err, $error ) = $self->loadUser($req);
|
||||||
if ( $err == -1 ) {
|
if ( $err == -1 ) {
|
||||||
return $self->p->sendError( $req, "U2F loading error: $error", 500 );
|
return $self->p->sendError( $req, "U2F loading error: $error",
|
||||||
|
500 );
|
||||||
}
|
}
|
||||||
elsif ( $err == 0 ) {
|
elsif ( $err == 0 ) {
|
||||||
return $self->p->sendError( $req, "noU2FKeyFound" );
|
return $self->p->sendError( $req, "noU2FKeyFound" );
|
||||||
|
|
|
@ -100,7 +100,8 @@ sub params {
|
||||||
$req->error_type( $res{AUTH_ERROR} = $req->menuError );
|
$req->error_type( $res{AUTH_ERROR} = $req->menuError );
|
||||||
|
|
||||||
# Display menu 2fRegisters link only if at least a 2F device is registered
|
# Display menu 2fRegisters link only if at least a 2F device is registered
|
||||||
$res{SFAManagment} = $self->p->_sfEngine->display2fRegisters($req, $req->userData);
|
$res{SFAManagment} =
|
||||||
|
$self->p->_sfEngine->display2fRegisters( $req, $req->userData );
|
||||||
$self->logger->debug( "Display 2fRegisters link ? " . $res{SFAManagment} );
|
$self->logger->debug( "Display 2fRegisters link ? " . $res{SFAManagment} );
|
||||||
|
|
||||||
return %res;
|
return %res;
|
||||||
|
|
|
@ -158,8 +158,7 @@ count(1);
|
||||||
# Verify UTF-8
|
# Verify UTF-8
|
||||||
ok(
|
ok(
|
||||||
$res = $op->_get(
|
$res = $op->_get(
|
||||||
'/oauth2/userinfo',
|
'/oauth2/userinfo', query => 'access_token=' . $access_token,
|
||||||
query => 'access_token=' . $access_token,
|
|
||||||
),
|
),
|
||||||
'Get userinfo'
|
'Get userinfo'
|
||||||
);
|
);
|
||||||
|
|
|
@ -20,7 +20,8 @@ my $client;
|
||||||
LWP::Protocol::PSGI->register(
|
LWP::Protocol::PSGI->register(
|
||||||
sub {
|
sub {
|
||||||
my $req = Plack::Request->new(@_);
|
my $req = Plack::Request->new(@_);
|
||||||
ok( $req->uri =~ m#http://auth.example.com(.*?)(?:\?(.*))?$#, " @ REST REQUEST @" );
|
ok( $req->uri =~ m#http://auth.example.com(.*?)(?:\?(.*))?$#,
|
||||||
|
" @ REST REQUEST @" );
|
||||||
count(1);
|
count(1);
|
||||||
my $url = $1;
|
my $url = $1;
|
||||||
my $query = $2;
|
my $query = $2;
|
||||||
|
@ -87,8 +88,7 @@ LWP::Protocol::PSGI->register(
|
||||||
'Unauth CDA request'
|
'Unauth CDA request'
|
||||||
);
|
);
|
||||||
my ( $host, $url, $query ) = expectForm( $res, undef, undef, 'url' );
|
my ( $host, $url, $query ) = expectForm( $res, undef, undef, 'url' );
|
||||||
ok( $query =~ /\burl=aHR0cDovL3Rlc3QuZXhhbXBsZS5vcmcv\b/,
|
ok( $query =~ /\burl=aHR0cDovL3Rlc3QuZXhhbXBsZS5vcmcv\b/, ' check url value' );
|
||||||
' check url value' );
|
|
||||||
|
|
||||||
# Authentification
|
# Authentification
|
||||||
$query .= '&user=dwho&password=dwho';
|
$query .= '&user=dwho&password=dwho';
|
||||||
|
@ -102,8 +102,7 @@ LWP::Protocol::PSGI->register(
|
||||||
);
|
);
|
||||||
|
|
||||||
($query) =
|
($query) =
|
||||||
expectRedirection( $res,
|
expectRedirection( $res, qr#^http://test.example.org/\?(lemonldapcda=.*)$# );
|
||||||
qr#^http://test.example.org/\?(lemonldapcda=.*)$# );
|
|
||||||
|
|
||||||
# Handler part
|
# Handler part
|
||||||
use_ok('Lemonldap::NG::Handler::Server');
|
use_ok('Lemonldap::NG::Handler::Server');
|
||||||
|
|
Loading…
Reference in New Issue
Block a user