Auto generate handler wrapper when possible (#1718)

This commit is contained in:
Xavier Guimard 2019-04-23 14:16:31 +02:00
parent c968b39715
commit 5af27967c6
21 changed files with 25 additions and 250 deletions

View File

@ -5,27 +5,13 @@ eg/scripts/purgeLocalCache
eg/scripts/purgeLocalCache.cron.d
lib/Lemonldap/NG/Handler.pm
lib/Lemonldap/NG/Handler/ApacheMP2.pm
lib/Lemonldap/NG/Handler/ApacheMP2/AuthBasic.pm
lib/Lemonldap/NG/Handler/ApacheMP2/CDA.pm
lib/Lemonldap/NG/Handler/ApacheMP2/DevOps.pm
lib/Lemonldap/NG/Handler/ApacheMP2/DevOpsST.pm
lib/Lemonldap/NG/Handler/ApacheMP2/FCGIClient.pm
lib/Lemonldap/NG/Handler/ApacheMP2/Main.pm
lib/Lemonldap/NG/Handler/ApacheMP2/Menu.pm
lib/Lemonldap/NG/Handler/ApacheMP2/OAuth2.pm
lib/Lemonldap/NG/Handler/ApacheMP2/Request.pm
lib/Lemonldap/NG/Handler/ApacheMP2/SecureToken.pm
lib/Lemonldap/NG/Handler/ApacheMP2/ServiceToken.pm
lib/Lemonldap/NG/Handler/ApacheMP2/ZimbraPreAuth.pm
lib/Lemonldap/NG/Handler/Lib/AuthBasic.pm
lib/Lemonldap/NG/Handler/Lib/CDA.pm
lib/Lemonldap/NG/Handler/Lib/DevOps.pm
lib/Lemonldap/NG/Handler/Lib/OAuth2.pm
lib/Lemonldap/NG/Handler/Lib/PSGI.pm
lib/Lemonldap/NG/Handler/Lib/SecureToken.pm
lib/Lemonldap/NG/Handler/Lib/ServiceToken.pm
lib/Lemonldap/NG/Handler/Lib/Status.pm
lib/Lemonldap/NG/Handler/Lib/ZimbraPreAuth.pm
lib/Lemonldap/NG/Handler/Main.pm
lib/Lemonldap/NG/Handler/Main/Init.pm
lib/Lemonldap/NG/Handler/Main/Jail.pm
@ -33,23 +19,13 @@ lib/Lemonldap/NG/Handler/Main/Reload.pm
lib/Lemonldap/NG/Handler/Main/Run.pm
lib/Lemonldap/NG/Handler/Main/SharedVariables.pm
lib/Lemonldap/NG/Handler/PSGI.pm
lib/Lemonldap/NG/Handler/PSGI/AuthBasic.pm
lib/Lemonldap/NG/Handler/PSGI/CDA.pm
lib/Lemonldap/NG/Handler/PSGI/Main.pm
lib/Lemonldap/NG/Handler/PSGI/Router.pm
lib/Lemonldap/NG/Handler/PSGI/ServiceToken.pm
lib/Lemonldap/NG/Handler/PSGI/Try.pm
lib/Lemonldap/NG/Handler/Server.pm
lib/Lemonldap/NG/Handler/Server/AuthBasic.pm
lib/Lemonldap/NG/Handler/Server/CDA.pm
lib/Lemonldap/NG/Handler/Server/DevOps.pm
lib/Lemonldap/NG/Handler/Server/DevOpsST.pm
lib/Lemonldap/NG/Handler/Server/Main.pm
lib/Lemonldap/NG/Handler/Server/Nginx.pm
lib/Lemonldap/NG/Handler/Server/OAuth2.pm
lib/Lemonldap/NG/Handler/Server/SecureToken.pm
lib/Lemonldap/NG/Handler/Server/ServiceToken.pm
lib/Lemonldap/NG/Handler/Server/ZimbraPreAuth.pm
lib/Plack/Middleware/Auth/LemonldapNG.pm
Makefile.PL
MANIFEST This list of files

View File

@ -41,8 +41,7 @@ sub launch {
$type = $t;
}
my $class = "Lemonldap::NG::Handler::ApacheMP2::$type";
eval "require $class";
die $@ if ($@);
Lemonldap::NG::Handler::Apache2::Main->buildAndLoadType($class);
my ($res) = $class->$sub($req);
return $res;
}

View File

@ -1,13 +0,0 @@
# LLNG wrapper class to enable AuthBasic handler with Apache-2/ModPerl-2
#
# See https://lemonldap-ng.org/documentation/latest/handlerarch
package Lemonldap::NG::Handler::ApacheMP2::AuthBasic;
use strict;
use base 'Lemonldap::NG::Handler::Lib::AuthBasic',
'Lemonldap::NG::Handler::ApacheMP2::Main';
our $VERSION = '2.1.0';
1;

View File

@ -1,13 +0,0 @@
# LLNG wrapper class to enable CDA handler with Apache-2/ModPerl-2
#
# See https://lemonldap-ng.org/documentation/latest/handlerarch
package Lemonldap::NG::Handler::ApacheMP2::CDA;
use strict;
use base 'Lemonldap::NG::Handler::Lib::CDA',
'Lemonldap::NG::Handler::ApacheMP2::Main';
our $VERSION = '2.1.0';
1;

View File

@ -1,13 +0,0 @@
# LLNG wrapper class to enable DevOps handler with Apache-2/ModPerl-2
#
# See https://lemonldap-ng.org/documentation/latest/handlerarch
package Lemonldap::NG::Handler::ApacheMP2::DevOps;
use strict;
use base 'Lemonldap::NG::Handler::Lib::DevOps',
'Lemonldap::NG::Handler::ApacheMP2::Main';
our $VERSION = '2.1.0';
1;

View File

@ -1,13 +0,0 @@
# LLNG wrapper class to enable OAuth2 handler with Apache-2/ModPerl-2
#
# See https://lemonldap-ng.org/documentation/latest/handlerarch
package Lemonldap::NG::Handler::ApacheMP2::OAuth2;
use strict;
use base 'Lemonldap::NG::Handler::Lib::OAuth2',
'Lemonldap::NG::Handler::ApacheMP2::Main';
our $VERSION = '2.0.4';
1;

View File

@ -1,13 +0,0 @@
# LLNG wrapper class to enable SecureToken handler with Apache-2/ModPerl-2
#
# See https://lemonldap-ng.org/documentation/latest/handlerarch
package Lemonldap::NG::Handler::ApacheMP2::SecureToken;
use strict;
use base 'Lemonldap::NG::Handler::Lib::SecureToken',
'Lemonldap::NG::Handler::ApacheMP2::Main';
our $VERSION = '2.1.0';
1;

View File

@ -1,13 +0,0 @@
# LLNG wrapper class to enable ServiceToken handler with Apache-2/ModPerl-2
#
# See https://lemonldap-ng.org/documentation/latest/handlerarch
package Lemonldap::NG::Handler::ApacheMP2::ServiceToken;
use strict;
use base 'Lemonldap::NG::Handler::Lib::ServiceToken',
'Lemonldap::NG::Handler::ApacheMP2::Main';
our $VERSION = '2.1.0';
1;

View File

@ -1,13 +0,0 @@
# LLNG wrapper class to enable ZimbraPreAuth handler with Apache-2/ModPerl-2
#
# See https://lemonldap-ng.org/documentation/latest/handlerarch
package Lemonldap::NG::Handler::ApacheMP2::ZimbraPreAuth;
use strict;
use base 'Lemonldap::NG::Handler::Lib::ZimbraPreAuth',
'Lemonldap::NG::Handler::ApacheMP2::Main';
our $VERSION = '2.1.0';
1;

View File

@ -125,8 +125,7 @@ sub _authAndTrace {
my $tmp = $self->api;
$tmp =~ s/::\w+$/::/;
$type = $tmp . $type;
eval "require $type";
die $@ if ($@);
Lemonldap::NG::Handler::Main->buildAndLoadType($type);
my ( $res, $session ) = $type->run( $req, $self->{rule} );
$self->portal( $type->tsv->{portal}->() );
$req->userData($session) if ($session);

View File

@ -446,7 +446,8 @@ sub retrieveSession {
# 2. Get the session from cache or backend
my $session = $req->data->{session} = (
Lemonldap::NG::Common::Session->new( {
Lemonldap::NG::Common::Session->new(
{
storageModule => $class->tsv->{sessionStorageModule},
storageModuleOptions => $class->tsv->{sessionStorageOptions},
cacheModule => $class->tsv->{sessionCacheModule},
@ -748,6 +749,27 @@ sub localUnlog {
}
}
## @rmethod buildAndLoadType(string package)
# Try to load type or build it
sub buildAndLoadType {
my ( $class, $package ) = @_;
eval "require $package";
if ($@) {
my $lastError = $@;
my $main = $package;
$main =~ s/::([^:]*)$/::Main/;
my $type = $2 or die "Malformed package $package";
eval <<EOF;
package $package;
use base 'Lemonldap::NG::Handler::Lib::$type',
'$main';
1;
EOF
die "Unable to build wrapper.\n First try: $lastError\n Auto-build: $@"
if ($@);
}
}
## @rmethod protected postOutputFilter(string uri)
# Add a javascript to html page in order to fill html form with fake data
# @param uri URI to catch

View File

@ -1,13 +0,0 @@
# LLNG wrapper class to enable AuthBasic handler with auto-protected PSGI
#
# See https://lemonldap-ng.org/documentation/latest/handlerarch
package Lemonldap::NG::Handler::PSGI::AuthBasic;
use strict;
use base 'Lemonldap::NG::Handler::Lib::AuthBasic',
'Lemonldap::NG::Handler::PSGI::Main';
our $VERSION = '2.1.0';
1;

View File

@ -1,13 +0,0 @@
# LLNG wrapper class to enable CDA handler with auto-protected PSGI
#
# See https://lemonldap-ng.org/documentation/latest/handlerarch
package Lemonldap::NG::Handler::PSGI::CDA;
use strict;
use base 'Lemonldap::NG::Handler::Lib::CDA',
'Lemonldap::NG::Handler::PSGI::Main';
our $VERSION = '2.1.0';
1;

View File

@ -1,13 +0,0 @@
# LLNG wrapper class to enable ServiceToken handler with FastCGI handler
#
# See https://lemonldap-ng.org/documentation/latest/handlerarch
package Lemonldap::NG::Handler::PSGI::ServiceToken;
use strict;
use base 'Lemonldap::NG::Handler::Lib::ServiceToken',
'Lemonldap::NG::Handler::PSGI::Main';
our $VERSION = '2.1.0';
1;

View File

@ -1,13 +0,0 @@
# LLNG wrapper class to enable AuthBasic handler with FastCGI handler
#
# See https://lemonldap-ng.org/documentation/latest/handlerarch
package Lemonldap::NG::Handler::Server::AuthBasic;
use strict;
use base 'Lemonldap::NG::Handler::Lib::AuthBasic',
'Lemonldap::NG::Handler::Server::Main';
our $VERSION = '2.1.0';
1;

View File

@ -1,13 +0,0 @@
# LLNG wrapper class to enable CDA handler with FastCGI handler
#
# See https://lemonldap-ng.org/documentation/latest/handlerarch
package Lemonldap::NG::Handler::Server::CDA;
use strict;
use base 'Lemonldap::NG::Handler::Lib::CDA',
'Lemonldap::NG::Handler::Server::Main';
our $VERSION = '2.1.0';
1;

View File

@ -1,13 +0,0 @@
# LLNG wrapper class to enable DevOps handler with FastCGI handler
#
# See https://lemonldap-ng.org/documentation/latest/handlerarch
package Lemonldap::NG::Handler::Server::DevOps;
use strict;
use base 'Lemonldap::NG::Handler::Lib::DevOps',
'Lemonldap::NG::Handler::Server::Main';
our $VERSION = '2.1.0';
1;

View File

@ -1,13 +0,0 @@
# LLNG wrapper class to enable OAuth2 handler with FastCGI handler
#
# See https://lemonldap-ng.org/documentation/latest/handlerarch
package Lemonldap::NG::Handler::Server::OAuth2;
use strict;
use base 'Lemonldap::NG::Handler::Lib::OAuth2',
'Lemonldap::NG::Handler::Server::Main';
our $VERSION = '2.0.4';
1;

View File

@ -1,13 +0,0 @@
# LLNG wrapper class to enable SecureToken handler with FastCGI handler
#
# See https://lemonldap-ng.org/documentation/latest/handlerarch
package Lemonldap::NG::Handler::Server::SecureToken;
use strict;
use base 'Lemonldap::NG::Handler::Lib::SecureToken',
'Lemonldap::NG::Handler::Server::Main';
our $VERSION = '2.1.0';
1;

View File

@ -1,13 +0,0 @@
# LLNG wrapper class to enable ServiceToken handler with FastCGI handler
#
# See https://lemonldap-ng.org/documentation/latest/handlerarch
package Lemonldap::NG::Handler::Server::ServiceToken;
use strict;
use base 'Lemonldap::NG::Handler::Lib::ServiceToken',
'Lemonldap::NG::Handler::Server::Main';
our $VERSION = '2.1.0';
1;

View File

@ -1,13 +0,0 @@
# LLNG wrapper class to enable ZimbraPreAuth handler with FastCGI handler
#
# See https://lemonldap-ng.org/documentation/latest/handlerarch
package Lemonldap::NG::Handler::Server::ZimbraPreAuth;
use strict;
use base 'Lemonldap::NG::Handler::Lib::ZimbraPreAuth',
'Lemonldap::NG::Handler::Server::Main';
our $VERSION = '2.1.0';
1;