Commit f648bddc authored by Christophe Maudoux's avatar Christophe Maudoux

Improve code (#1636)

parent 08647bb9
......@@ -25,19 +25,12 @@ sub _authCancel {
sub extractFormInfo {
my ( $self, $req ) = @_;
unless ( $self->checkChoice($req) ) {
$self->logger->debug("Searching for Auth module AJAX init/script...");
foreach my $mod ( values %{ $self->modules } ) {
$self->logger->debug("Auth module -> $mod");
if ( $mod =~ /::Auth::SSL/
and $self->conf->{sslByAjax}
and not $req->param('nossl') )
{
$self->logger->debug('Send SSL javascript');
$req->data->{customScript}
.= '<script type="application/init">{"sslHost":"'
. $self->conf->{sslHost}
. '"}</script>';
if ( $mod->{AjaxInitScript} and $mod->{Name} ) {
$self->logger->debug(
"Send JS -> " . $req->data->{customScript} );
'Append ' . $mod->Name . ' init/script' );
$req->data->{customScript} .= $mod->AjaxInitScript;
}
}
foreach my $mod ( values %{ $self->modules } ) {
......@@ -46,6 +39,8 @@ sub extractFormInfo {
last;
}
}
$self->logger->debug(
"Send init/script -> " . $req->data->{customScript} );
return PE_FIRSTACCESS;
}
my $res = $req->data->{enabledMods0}->[0]->extractFormInfo($req);
......
......@@ -3,10 +3,10 @@ package Lemonldap::NG::Portal::Auth::SSL;
use strict;
use Mouse;
use Lemonldap::NG::Portal::Main::Constants qw(
PE_BADCERTIFICATE
PE_CERTIFICATEREQUIRED
PE_FIRSTACCESS
PE_OK
PE_BADCERTIFICATE
PE_CERTIFICATEREQUIRED
PE_FIRSTACCESS
PE_OK
);
our $VERSION = '2.0.1';
......@@ -15,7 +15,15 @@ extends 'Lemonldap::NG::Portal::Main::Auth';
# INITIALIZATION
has AjaxInitScript => ( is => 'rw', default => '' );
has Name => ( is => 'ro', default => 'SSL' );
sub init {
my ($self) = @_;
$self->AjaxInitScript( '<script type="application/init">{"sslHost":"'
. $self->conf->{sslHost}
. '"}</script>' )
if $self->conf->{sslByAjax};
return 1;
}
......@@ -25,13 +33,14 @@ sub extractFormInfo {
my ( $self, $req ) = @_;
my $field = $self->conf->{SSLVar};
if ( $req->env->{SSL_CLIENT_I_DN}
and my $tmp =
$self->conf->{SSLVarIf}->{ $req->env->{SSL_CLIENT_I_DN} } )
and my $tmp
= $self->conf->{SSLVarIf}->{ $req->env->{SSL_CLIENT_I_DN} } )
{
$field = $tmp;
}
if ( $req->user( $req->env->{$field} ) ) {
$self->userLogger->notice( "GoodSSL authentication for " . $req->user );
$self->userLogger->notice(
"GoodSSL authentication for " . $req->user );
return PE_OK;
}
elsif ( $req->env->{SSL_CLIENT_S_DN} ) {
......@@ -39,12 +48,10 @@ sub extractFormInfo {
return PE_BADCERTIFICATE;
}
elsif ( $self->conf->{sslByAjax} and not $req->param('nossl') ) {
$self->logger->debug('Send SSL javascript');
$req->data->{customScript} .=
'<script type="application/init">{"sslHost":"'
. $self->conf->{sslHost}
. '"}</script>';
$self->logger->debug("Send JS -> " . $req->data->{customScript});
$self->logger->debug( 'Append ' . $self->Name . ' init/script' );
$req->data->{customScript} .= $self->AjaxInitScript;
$self->logger->debug(
"Send init/script -> " . $req->data->{customScript} );
return PE_FIRSTACCESS;
}
else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment