Commit 15308411 authored by Christophe Maudoux's avatar Christophe Maudoux

Fix SSL/Kerberos Auth with Choice & Improve unit tests (#1636)

parent d70d7e11
......@@ -3,6 +3,7 @@ package Lemonldap::NG::Portal::Auth::Choice;
use strict;
use Mouse;
use Lemonldap::NG::Portal::Main::Constants qw(PE_OK PE_FIRSTACCESS PE_ERROR);
use Data::Dumper;
our $VERSION = '2.0.2';
......@@ -29,19 +30,24 @@ sub extractFormInfo {
foreach my $mod ( values %{ $self->modules } ) {
if ( $mod->{AjaxInitScript} ) {
$self->logger->debug(
'Append ' . $mod->{Name} . ' init/script' ) if $mod->{Name};
'Append ' . $mod->{Name} . ' init/script' )
if $mod->{Name};
$req->data->{customScript} .= $mod->AjaxInitScript;
}
if ( $mod->{InitCmd} ) {
$self->logger->debug(
'Launch ' . $mod->{Name} . ' init command' ) if $mod->{Name};
'Launch ' . $mod->{Name} . ' init command' )
if $mod->{Name};
my $res = eval( $mod->{InitCmd} );
if ($@) {
$self->logger("Auth error: $@");
return PE_ERROR;
}
}
}
}
$self->logger->debug("@@@@ Req -> " . Dumper($req) );
foreach my $mod ( values %{ $self->modules } ) {
if ( $mod->can('setSecurity') ) {
$mod->setSecurity($req);
......
......@@ -55,6 +55,13 @@ sub extractFormInfo {
return PE_FIRSTACCESS;
}
else {
if ( $self->conf->{sslByAjax} ) {
$self->logger->debug(
'Append ' . $self->{Name} . ' init/script' );
$req->data->{customScript} .= $self->{AjaxInitScript};
$self->logger->debug(
"Send init/script -> " . $req->data->{customScript} );
}
$self->userLogger->warn('No certificate found');
return PE_CERTIFICATEREQUIRED;
}
......
......@@ -460,8 +460,9 @@ sub buildHiddenForm {
if $self->checkXSSAttack( $_, $req->{portalHiddenFormValues}->{$_} );
# Build hidden input HTML code
# 'id' is removed to avoid warning with Choice
#$val .= qq{<input type="hidden" name="$_" id="$_" value="}
$val .= qq{<input type="hidden" name="$_" id="$_" value="}
$val .= qq{<input type="hidden" name="$_" value="}
. $req->{portalHiddenFormValues}->{$_} . '" />';
}
......
......@@ -48,7 +48,7 @@ SKIP: {
expectForm( $res, '#', undef, 'kerberos' );
ok( $res->[2]->[0]
=~ m%<input type="hidden" name="kerberos" id="kerberos" value="0" />%,
=~ m%<input type="hidden" name="kerberos" value="0" />%,
'Found hidden attribut "kerberos" with value="0"'
) or print STDERR Dumper( $res->[2]->[0] );
ok( $res->[2]->[0] =~ /kerberos\.(?:min\.)?js/,
......
......@@ -83,7 +83,7 @@ SKIP: {
) or print STDERR Dumper( $res->[2]->[0] );
expectForm( $res, '#', undef, 'kerberos' );
ok( $res->[2]->[0]
=~ m%<input type="hidden" name="kerberos" id="kerberos" value="0" />%,
=~ m%<input type="hidden" name="kerberos" value="0" />%,
'Found hidden attribut "kerberos" with value="0"'
) or print STDERR Dumper( $res->[2]->[0] );
ok( $res->[2]->[0] =~ /kerberosChoice\.(?:min\.)?js/,
......
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