Modularize Display/login (#1652)

This commit is contained in:
Xavier 2019-03-19 05:56:36 +01:00 committed by Xavier Guimard
parent 5a1c090a18
commit 8c562c7817
59 changed files with 530 additions and 546 deletions

View File

@ -37,7 +37,7 @@ our $authParameters = {
apacheParams => [qw(apacheAuthnLevel)],
casParams => [qw(casAuthnLevel)],
choiceParams => [qw(authChoiceParam authChoiceModules)],
combinationParams => [qw(combination combModules)],
combinationParams => [qw(combination combModules combinationForms)],
customParams => [qw(customAuth customUserDB customPassword customRegister customAddParams)],
dbiParams => [qw(dbiAuthnLevel dbiExportedVars dbiAuthChain dbiAuthUser dbiAuthPassword dbiUserChain dbiUserUser dbiUserPassword dbiAuthTable dbiUserTable dbiAuthLoginCol dbiAuthPasswordCol dbiPasswordMailCol userPivot dbiAuthPasswordHash dbiDynamicHashEnabled dbiDynamicHashValidSchemes dbiDynamicHashValidSaltedSchemes dbiDynamicHashNewPasswordScheme)],
demoParams => [qw(demoExportedVars)],

View File

@ -0,0 +1,171 @@
# IO::Handle filter. Used to transform HTML::Template on the fly.
package Lemonldap::NG::Common::IO::Filter;
use strict;
use IO::File;
use Symbol;
#our @ISA = ('IO::File');
sub new {
my ( $class, $file, $opt ) = @_;
$opt->{_i} = ( ref $file ? $file : IO::File->new($file) )
or die("Unable to build IO::File object $!");
my $self = ref $class ? $class : bless gensym, $class;
tie( *$self, $class, $opt );
return $self;
}
sub TIEHANDLE {
my ( $class, $data ) = @_;
return bless( $data, $class );
}
sub READLINE {
my ($self) = shift;
my $res = $self->{_i}->getline;
foreach my $key ( keys %$self ) {
next if ( $key eq '_i' );
if ( ref( $self->{$key} ) eq 'CODE' ) {
$res =~ s/__LLNG_${key}__/$self->{$key}->()/gse;
}
elsif ( ref $self->{$key} eq 'ARRAY' ) {
next;
}
elsif ( ref $self->{$key} ) {
local $/ = undef;
$res =~ s/__LLNG_${key}__/$self->{$key}->getline/gse;
}
}
# Parse strings after code/IO
foreach my $key ( keys %$self ) {
die "Undefined value for __LLNG_${key}__ substitution" unless $self->{$key};
my $v = (ref $self->{$key} and ref $self->{$key} eq 'ARRAY') ?$self->{$key}:[$self->{$key}];
$v = join "\n", map {ref $_ ? () : qq'<TMPL_INCLUDE NAME="$_.tpl">'} @$v;
$res =~ s/__LLNG_${key}__/$v/gs;
}
return $res;
}
sub DESTROY {
my ($self) = @_;
$self->close() if ( ref($self) eq 'SCALAR' );
}
sub AUTOLOAD {
no strict;
my $self = shift;
$AUTOLOAD =~ s/^.*:://;
$AUTOLOAD = lc $AUTOLOAD;
return tied( ${$self} )->{_i}->$AUTOLOAD(@_);
}
1;
__END__
=head1 NAME
Lemonldap::NG::Common::IO::Filter - IO::Handle filter
=head1 SYNOPSIS
use HTML::Template;
my $fh = Lemonldap::NG::Common::IO::Filter->new(
'template.tpl',
{
# Replace all __LLNG_AUTH__ by:
# <TMPL_INCLUDE NAME="login.tpl">
AUTH => 'login',
# Replace all __LLNG_CODE__ by the result of the given function
CODE => sub {return "INCLUDED STRING"}
}
);
my $h = HTML::Template->new( filehandle => $fh );
print $h->output;
Input:
<html><body>
__LLNG_AUTH__
<hr>
__LLNG_CODE__
</body></html>
Output:
<html><body>
<TMPL_INCLUDE NAME="login.tpl">
<hr>
INCLUDED STRING
</body></html>
Same but with a L<IO::Handle> file:
use HTML::Template;
my $file = IO::File->new('test.tpl');
my $fh = Lemonldap::NG::Common::IO::Filter->new_from_io(
$file,
{
# Replace all __LLNG_AUTH__ by:
# <TMPL_INCLUDE NAME="login.tpl">
AUTH => 'login',
# Replace all __LLNG_CODE__ by the result of the given function
CODE => sub {return "INCLUDED STRING"}
}
);
my $h = HTML::Template->new( filehandle => $fh );
print $h->output;
Or with an array:
use HTML::Template;
my $fh = Lemonldap::NG::Common::IO::Filter->new_from_io(
'template.tpl',
{
# Replace all __LLNG_AUTH__ by:
# <TMPL_INCLUDE NAME="login.tpl"> <TMPL_INCLUDE NAME="login2.tpl">
AUTH => [ 'login', 'login2' ],
}
);
my $h = HTML::Template->new( filehandle => $fh );
print $h->output;
=head1 DESCRIPTION
IO::Handle filter used to transform HTML::Template files on the fly.
=head1 AUTHORS
=over
=item LemonLDAP::NG team L<http://lemonldap-ng.org/team>
=back
=head1 BUG REPORT
Use OW2 system to report bug or ask for features:
L<https://gitlab.ow2.org/lemonldap-ng/lemonldap-ng/issues>
=head1 DOWNLOAD
Lemonldap::NG is available at
L<http://forge.objectweb.org/project/showfiles.php?group_id=274>
=head1 COPYRIGHT AND LICENSE
See COPYING file for details.
This library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see L<http://www.gnu.org/licenses/>.
=cut

View File

@ -3,6 +3,7 @@ package Lemonldap::NG::Common::PSGI;
use 5.10.0;
use Mouse;
use JSON;
use Lemonldap::NG::Common::IO::Filter;
use Lemonldap::NG::Common::PSGI::Constants;
use Lemonldap::NG::Common::PSGI::Request;
@ -241,14 +242,23 @@ sub sendHtml {
$args{code} ||= 200;
$args{headers} ||= $req->respHeaders || [];
my $htpl;
$template = ( $args{templateDir} // $self->templateDir ) . "/$template.tpl";
return $self->sendError( $req, "Unable to read $template", 500 )
unless ( -r $template and -f $template );
eval {
unless ( ref $template ) {
$template =
( $args{templateDir} // $self->templateDir ) . "/$template.tpl";
return $self->sendError( $req, "Unable to read $template", 500 )
unless ( -r $template and -f $template );
$self->logger->debug("Starting HTML generation using $template");
}
eval {
require HTML::Template;
my $io =
$args{filter}
? Lemonldap::NG::Common::IO::Filter->new( $template, $args{filter} )
: ref $template ? $template
: IO::File->new($template);
$htpl = HTML::Template->new(
filehandle => IO::File->new($template),
filehandle => $io,
path => $self->templateDir,
search_path_on_include => 1,
die_on_bad_params => 0,
@ -269,6 +279,7 @@ sub sendHtml {
? %{ $args{params} }
: ()
),
%{ $req->{tplParams} },
);
};
if ($@) {

View File

@ -36,11 +36,14 @@ sub new {
$self->{data} = {};
$self->{error} = 0;
$self->{respHeaders} = [];
$self->{tplParams} = {};
return bless( $self, $_[0] );
}
sub data { $_[0]->{data} }
sub tplParams { $_[0]->{tplParams} }
sub uri { $_[0]->{uri} }
sub userData {

View File

@ -0,0 +1,45 @@
use Test::More tests => 10;
use strict;
use HTML::Template;
use IO::String;
use_ok('Lemonldap::NG::Common::IO::Filter');
my ( $b, $t );
# Template name
ok(
$b = Lemonldap::NG::Common::IO::Filter->new(
't/test.tpl', { FORM => 't/inc' }
),
'Build IO filter (file.tpl)'
);
ok( $t = HTML::Template->new( filehandle => $b ),
'Build HTML::Template object' );
ok( $t->output =~ /XX\s+YY\s+ZZ/s, 'Substitution works' );
# Code ref
my $s = IO::String->new('XX __LLNG_AUTH__ ZZ');
ok(
$b = Lemonldap::NG::Common::IO::Filter->new(
$s,
{
AUTH => sub { 'YY' }
}
),
'Build IO filter (code ref)'
);
ok( $t = HTML::Template->new( filehandle => $b ),
'Build HTML::Template object' );
ok( $t->output eq 'XX YY ZZ', 'Substitution works' );
# IO ref
ok(
$b = Lemonldap::NG::Common::IO::Filter->new(
't/test.tpl', { FORM => IO::File->new('t/inc.tpl'), AUTH => 't/inc' }
),
'Build IO filter (IO ref)'
);
ok( $t = HTML::Template->new( filehandle => $b ),
'Build HTML::Template object' );
ok( $t->output =~ /XX\s+YY\s+ZZ/s, 'Substitution works' );

View File

@ -0,0 +1,3 @@
YY

View File

@ -0,0 +1 @@
XX __LLNG_FORM__ ZZ

View File

@ -811,6 +811,9 @@ qr/(?:(?:https?):\/\/(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.]
'combination' => {
'type' => 'text'
},
'combinationForms' => {
'type' => 'text'
},
'combModules' => {
'keyTest' => qr/^\w+$/,
'select' => [ {

View File

@ -3132,6 +3132,10 @@ m{^(?:ldapi://[^/]*/?|\w[\w\-\.]*(?::\d{1,5})?|ldap(?:s|\+tls)?://\w[\w\-\.]*(?:
type => 'text',
documentation => 'Combination rule'
},
combinationForms => {
type => 'text',
documentation => 'List of forms to display'
},
combModules => {
type => 'cmbModuleContainer',
keyTest => qr/^\w+$/,

View File

@ -304,7 +304,10 @@ sub tree {
{
title => 'combinationParams',
help => 'authcombination.html',
nodes => [ 'combination', 'combModules' ]
nodes => [
'combination', 'combModules',
'combinationForms'
]
},
{
title => 'nullParams',

View File

@ -163,6 +163,7 @@
"chooseLogo":"اختيار الشعار",
"chooseSkin":"اختيار الغلاف",
"combination":"دمج",
"combinationForms":"Forms to display",
"combinationParams":"دمج المعلومات",
"combineMods":"دمج الوحدات",
"combModules":"قائمة الوحدات",

View File

@ -163,6 +163,7 @@
"chooseLogo":"Choose logo",
"chooseSkin":"Choose skin",
"combination":"Combination",
"combinationForms":"Forms to display",
"combinationParams":"Combination parameters",
"combineMods":"Combination of modules",
"combModules":"Module list",

View File

@ -163,6 +163,7 @@
"chooseLogo":"Choose logo",
"chooseSkin":"Choose skin",
"combination":"Combination",
"combinationForms":"Forms to display",
"combinationParams":"Combination parameters",
"combineMods":"Combination of modules",
"combModules":"Module list",

View File

@ -163,6 +163,7 @@
"chooseLogo":"Choisir le logo",
"chooseSkin":"Choisir le thème",
"combination":"Combinaison",
"combinationForms":"Formulaires à afficher",
"combinationParams":"Paramètres de combinaison",
"combineMods":"Combinaison de modules",
"combModules":"Liste des modules",

View File

@ -163,6 +163,7 @@
"chooseLogo":"Scegli logo",
"chooseSkin":"Scegli interfaccia",
"combination":"Combinazione",
"combinationForms":"Forms to display",
"combinationParams":"Parametri di combinazione",
"combineMods":"Combinazione di moduli",
"combModules":"Elenco dei moduli",

View File

@ -164,6 +164,7 @@
"chooseLogo":"Chọn logo",
"chooseSkin":"Chọn giao diện",
"combination":"Kết hợp",
"combinationForms":"Forms to display",
"combinationParams":"Tham số kết hợp",
"combineMods":"Kết hợp các mô-đun",
"combModules":"Danh sách mô-đun",

View File

@ -163,6 +163,7 @@
"chooseLogo":"Choose logo",
"chooseSkin":"Choose skin",
"combination":"Combination",
"combinationForms":"Forms to display",
"combinationParams":"Combination parameters",
"combineMods":"Combination of modules",
"combModules":"模块列表",

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -25,7 +25,6 @@
"Convert::Base32" : "0",
"Email::Sender" : "0",
"HTTP::Message" : "0",
"IO::String" : "0",
"LWP::UserAgent" : "0",
"MIME::Entity" : "0",
"SOAP::Lite" : "0",
@ -45,6 +44,7 @@
"GD::SecurityImage" : "0",
"Glib" : "0",
"HTTP::Message" : "0",
"IO::String" : "0",
"IPC::Run" : "0",
"Image::Magick" : "0",
"LWP::Protocol::https" : "0",

View File

@ -6,7 +6,6 @@ build_requires:
Convert::Base32: '0'
Email::Sender: '0'
HTTP::Message: '0'
IO::String: '0'
LWP::UserAgent: '0'
MIME::Entity: '0'
SOAP::Lite: '0'
@ -31,6 +30,7 @@ recommends:
GD::SecurityImage: '0'
Glib: '0'
HTTP::Message: '0'
IO::String: '0'
IPC::Run: '0'
Image::Magick: '0'
LWP::Protocol::https: '0'

View File

@ -16,6 +16,7 @@ WriteMakefile(
'Glib' => 0,
'HTTP::Message' => 0,
'Image::Magick' => 0,
'IO::String' => 0,
'IPC::Run' => 0,
'Lasso' => '2.3.0',
'LWP::UserAgent' => 0,
@ -51,7 +52,6 @@ WriteMakefile(
'Convert::Base32' => 0,
'Email::Sender' => 0,
'HTTP::Message' => 0,
'IO::String' => 0,
'LWP::UserAgent' => 0,
'MIME::Entity' => 0,
'SOAP::Lite' => 0,

View File

@ -44,7 +44,7 @@ Lemonldap:NG::Portal::Auth - Writing authentication modules for LemonLDAP::NG.
...
}
sub getDisplayType {
sub getForm {
return ...;
}

View File

@ -43,7 +43,7 @@ sub authLogout {
PE_OK;
}
sub getDisplayType {
sub getForm {
return 'logo';
}

View File

@ -272,7 +272,7 @@ sub authLogout {
PE_OK;
}
sub getDisplayType {
sub getForm {
return "logo";
}

View File

@ -26,24 +26,6 @@ sub extractFormInfo {
my ( $self, $req ) = @_;
unless ( $self->checkChoice($req) ) {
$self->logger->debug("Initializing Auth modules...");
foreach my $mod ( values %{ $self->modules } ) {
if ( $mod->{AjaxInitScript} ) {
$self->logger->debug(
'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};
my $res = eval( $mod->{InitCmd} );
if ($@) {
$self->logger("Auth error: $@");
return PE_ERROR;
}
}
}
foreach my $mod ( values %{ $self->modules } ) {
if ( $mod->can('setSecurity') ) {

View File

@ -124,15 +124,15 @@ sub setGroups {
return $_[0]->try( 1, 'setGroups', $_[1] );
}
sub getDisplayType {
sub getForm {
my ( $self, $req ) = @_;
return $self->conf->{combinationForms}
return [ split /[, ]\s*/, $self->conf->{combinationForms} ]
if ( $self->conf->{combinationForms} );
my ( $nb, $stack ) = (
$req->data->{dataKeep}->{combinationTry},
$req->data->{combinationStack}
);
my ( $res, $name ) = $stack->[$nb]->[0]->( 'getDisplayType', $req );
my ( $res, $name ) = $stack->[$nb]->[0]->( 'getForm', $req );
return $res;
}

View File

@ -15,10 +15,10 @@ sub new {
return $res;
}
sub getDisplayType {
sub getForm {
# Warning : $self passed here is the Portal itself
my ($self) = @_;
my ( $self, $req ) = @_;
my $logo = ( $self->{conf}->{customAuth} =~ /::(\w+)$/ )[0];
if ( -e $self->{conf}->{templateDir}
@ -27,6 +27,7 @@ sub getDisplayType {
. ".png" )
{
$self->logger->debug("CustomAuth $logo.png found");
$req->tplParams->{CUSTOM_LOGO} = "common/modules/$logo.png";
return "logo";
}
return "standardform";

View File

@ -151,7 +151,7 @@ sub authLogout {
PE_OK;
}
sub getDisplayType {
sub getForm {
return "logo";
}

View File

@ -151,7 +151,7 @@ sub authLogout {
PE_OK;
}
sub getDisplayType {
sub getForm {
return "gpgform";
}

View File

@ -17,12 +17,7 @@ our $VERSION = '2.1.0';
extends 'Lemonldap::NG::Portal::Main::Auth';
has keytab => ( is => 'rw' );
has AjaxInitScript => ( is => 'rw', default => '' );
has Name => ( is => 'ro', default => 'Kerberos' );
has InitCmd => (
is => 'ro',
default => q@$self->p->setHiddenFormValue( $req, kerberos => 0, '', 0 )@
);
# INITIALIZATION
@ -34,10 +29,6 @@ sub init {
return 0;
}
$self->keytab("FILE:$file");
$self->AjaxInitScript( '<script type="text/javascript" src="'
. $self->p->staticPrefix
. '/common/js/kerberosChoice.js"></script>' )
if $self->conf->{krbByJs};
return 1;
}
@ -75,16 +66,12 @@ sub extractFormInfo {
# Case 1.2: HTML request: display error and initiate Kerberos
# dialog
else {
# TODO
$req->error(PE_BADCREDENTIALS);
push @{ $req->respHeaders }, 'WWW-Authenticate' => 'Negotiate';
my ( $tpl, $prms ) = $self->p->display($req);
$req->response(
$self->p->sendHtml(
$req, $tpl,
params => $prms,
code => 401
)
);
my $resp = $self->p->display($req);
$resp->[0] = 401;
$req->response($resp);
}
return PE_SENDRESPONSE;
}
@ -102,25 +89,6 @@ sub extractFormInfo {
# Case 3: Display kerberos auth page (with javascript)
else {
$self->logger->debug( 'Append ' . $self->Name . ' init/script' );
# Call kerberos.js if Kerberos is the only Auth module
# kerberosChoice.js is used by Choice
$self->{AjaxInitScript} =~ s/kerberosChoice/kerberos/;
# In some Combination scenarios, Kerberos may be called multiple
# times but we only want to add the JS once
unless ( $req->data->{_krbJsAlreadySent} ) {
$req->data->{customScript} .= $self->{AjaxInitScript};
$self->logger->debug(
"Send init/script -> " . $req->data->{customScript} );
$req->data->{_krbJsAlreadySent} = 1;
}
#$self->p->setHiddenFormValue( $req, kerberos => 0, '', 0 );
eval( $self->InitCmd );
die 'Unable to launch init commmand ' . $self->{InitCmd} if ($@);
$req->data->{waitingMessage} = 1;
return PE_FIRSTACCESS;
}
@ -191,8 +159,8 @@ sub setAuthSessionInfo {
PE_OK;
}
sub getDisplayType {
return "logo";
sub getForm {
return "kerberos";
}
1;

View File

@ -237,7 +237,7 @@ sub authForce {
return 0;
}
sub getDisplayType {
sub getForm {
return "logo";
}

View File

@ -37,7 +37,7 @@ sub authLogout {
PE_OK;
}
sub getDisplayType {
sub getForm {
return '';
}

View File

@ -205,7 +205,7 @@ sub authLogout {
PE_OK;
}
sub getDisplayType {
sub getForm {
return "openidform";
}

View File

@ -328,7 +328,7 @@ sub authLogout {
PE_OK;
}
sub getDisplayType {
sub getForm {
return "logo";
}

View File

@ -32,7 +32,7 @@ sub setAuthSessionInfo {
PE_OK;
}
sub getDisplayType {
sub getForm {
return "standardform";
}

View File

@ -40,7 +40,7 @@ sub authLogout {
PE_OK;
}
sub getDisplayType {
sub getForm {
return "logo";
}

View File

@ -1479,7 +1479,7 @@ sub handleAuthRequests {
# TODO: authForce
sub getDisplayType {
sub getForm {
return "logo";
}

View File

@ -15,15 +15,10 @@ 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;
}
@ -47,17 +42,12 @@ sub extractFormInfo {
return PE_BADCERTIFICATE;
}
elsif ( $self->conf->{sslByAjax} and not $req->param('nossl') ) {
$self->logger->debug( 'Append ' . $self->{Name} . ' init/script' );
$req->data->{customScript} .= $self->{AjaxInitScript};
$self->logger->debug(
"Send init/script -> " . $req->data->{customScript} );
$req->data->{waitingMessage} = 1;
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} );
}
@ -76,9 +66,10 @@ sub setAuthSessionInfo {
PE_OK;
}
sub getDisplayType {
my ($self) = @_;
return ( $self->{conf}->{sslByAjax} ? "sslform" : "logo" );
sub getForm {
my ($self,$req) = @_;
$req->tplParams->{SSLHOST} = $self->conf->{sslHost};
return "sslform";
}
sub authLogout {

View File

@ -239,7 +239,7 @@ sub authLogout {
PE_OK;
}
sub getDisplayType {
sub getForm {
return "logo";
}

View File

@ -92,7 +92,7 @@ sub setAuthSessionInfo {
PE_OK;
}
sub getDisplayType {
sub getForm {
return "logo";
}

View File

@ -160,7 +160,7 @@ sub setAuthSessionInfo {
}
# @return display type
sub getDisplayType {
sub getForm {
return "standardform";
}

View File

@ -3,6 +3,7 @@ package Lemonldap::NG::Portal::Lib::Choice;
use strict;
use Mouse;
use Safe;
use IO::String;
extends 'Lemonldap::NG::Portal::Lib::Wrapper';
with 'Lemonldap::NG::Portal::Lib::OverConf';
@ -157,11 +158,7 @@ sub name {
return $n;
}
package Lemonldap::NG::Portal::Main;
# Build authentication loop displayed in template
# Return authLoop array reference
sub _buildAuthLoop {
sub getForm {
my ( $self, $req ) = @_;
my @authLoop;
@ -223,20 +220,25 @@ sub _buildAuthLoop {
# Options to store in the loop
my $optionsLoop = {
name => $name,
key => $_,
module => $auth,
url => $url
name => $name,
key => $_,
module => $auth,
url => $url,
CHOICE_VALUE => $req->data->{_authChoice},
CHOICE_PARAM => $self->conf->{authChoiceParam},
};
# Get displayType for this module
no strict 'refs';
my $displayType = "Lemonldap::NG::Portal::Auth::${auth}"
->can('getDisplayType')->( $self, $req );
->can('getForm')->( $self, $req );
$self->logger->debug(
"Display type $displayType for module $auth");
$optionsLoop->{$displayType} = 1;
$self->logger->debug( 'Display type '
. ( ref $displayType ? '[ref]' : $displayType )
. ' for module $auth' );
#$optionsLoop->{$displayType} = 1 unless(ref $displayType);
$optionsLoop->{form} = $displayType;
my $logo = $_;
if ( $auth eq 'Custom' ) {
$logo =
@ -269,9 +271,35 @@ sub _buildAuthLoop {
}
return \@authLoop;
open my $fh,
$self->conf->{templateDir} . '/'
. $self->p->getSkin($req)
. "/choice.tpl"
or die $!;
my $res;
{
local $/ = undef;
$res = readline $fh;
}
close $fh;
while ( $res =~ m#<TMPL_LOOP NAME="AUTH_LOOP">(.*?)</TMPL_LOOP>#s ) {
my $content = $1;
my $new = '';
foreach (@authLoop) {
my $tmp = $content;
if ( my @match = ( $tmp =~ m#<TMPL_VAR NAME="(\w+)">#gs ) ) {
foreach my $key (@match) {
$tmp =~ s#<TMPL_VAR NAME="$key">#$_->{$key}#gs
if defined $_->{$key};
}
}
$tmp =~ s#__LLNG_FORM__#<TMPL_INCLUDE NAME="$_->{form}.tpl">#gs;
$new .= $tmp;
}
$res =~ s#<TMPL_LOOP NAME="AUTH_LOOP">.*?</TMPL_LOOP>#$new#s;
}
$req->tplParams->{CHOICE_PARAM} = $self->conf->{authChoiceParam};
return IO::String->new($res);
}
1;

View File

@ -50,7 +50,7 @@ sub display {
my ( $self, $req ) = @_;
my $skin_dir = $self->conf->{templatesDir};
my ( $skinfile, %templateParams );
my ( $skinfile, %templateParams, $filter );
# 1. Authentication not complete
@ -285,8 +285,9 @@ sub display {
);
}
# 3 Authentication has been refused OR first access
else {
# 3 Authentication has been refused OR first access
$skinfile = 'login';
my $login = $self->userId($req);
$login = '' if ( $login eq 'anonymous' );
@ -311,134 +312,42 @@ sub display {
? ( CUSTOM_SCRIPT => $req->data->{customScript} )
: ()
),
( $req->token ? ( TOKEN => $req->token ) : () ),
(
$req->captcha
? (
CAPTCHA_SRC => $req->captcha,
CAPTCHA_SIZE => $self->{conf}->{captcha_size}
|| 6
)
: ()
),
( $req->data->{waitingMessage} ? ( WAITING_MESSAGE => 1 ) : () ),
);
# Display captcha if it's enabled
if ( $req->captcha ) {
%templateParams = (
%templateParams,
CAPTCHA_SRC => $req->captcha,
CAPTCHA_SIZE => $self->{conf}->{captcha_size} || 6
);
}
if ( $req->token ) {
%templateParams = ( %templateParams, TOKEN => $req->token, );
}
# Show password form if password policy error
if (
$req->{error} == PE_PP_CHANGE_AFTER_RESET
or $req->{error} == PE_PP_MUST_SUPPLY_OLD_PASSWORD
or $req->{error} == PE_PP_INSUFFICIENT_PASSWORD_QUALITY
or $req->{error} == PE_PP_PASSWORD_TOO_SHORT
or $req->{error} == PE_PP_PASSWORD_TOO_YOUNG
or $req->{error} == PE_PP_PASSWORD_IN_HISTORY
or $req->{error} == PE_PASSWORD_MISMATCH
or $req->{error} == PE_BADOLDPASSWORD
or $req->{error} == PE_PASSWORDFORMEMPTY
or ( $req->{error} == PE_PP_PASSWORD_EXPIRED
and $self->conf->{ldapAllowResetExpiredPassword} )
)
{
%templateParams = (
%templateParams,
REQUIRE_OLDPASSWORD =>
1, # Old password is required to check user credentials
DISPLAY_FORM => 0,
DISPLAY_OPENID_FORM => 0,
DISPLAY_YUBIKEY_FORM => 0,
DISPLAY_PASSWORD => 1,
DISPLAY_RESETPASSWORD => 0,
AUTH_LOOP => [],
CHOICE_PARAM => $self->conf->{authChoiceParam},
CHOICE_VALUE => $req->data->{_authChoice},
OLDPASSWORD => $self->checkXSSAttack( 'oldpassword',
$req->data->{oldpassword} )
? ""
: $req->data->{oldpassword},
HIDE_OLDPASSWORD => $self->conf->{hideOldPassword},
);
}
# Disable all forms on:
# * Logout message
# * Bad URL error
elsif ($req->{error} == PE_LOGOUT_OK
if ( $req->{error} == PE_LOGOUT_OK
or $req->{error} == PE_WAIT
or $req->{error} == PE_BADURL )
{
%templateParams = (
%templateParams,
DISPLAY_RESETPASSWORD => 0,
DISPLAY_FORM => 0,
DISPLAY_OPENID_FORM => 0,
DISPLAY_YUBIKEY_FORM => 0,
AUTH_LOOP => [],
MSG => $req->info(),
);
$skinfile = 'error';
%templateParams = ( %templateParams, MSG => $req->info(), );
}
# Display authentication form
else {
# Authentication loop
if ( $self->conf->{authentication} eq 'Choice'
and my $authLoop = $self->_buildAuthLoop($req) )
{
%templateParams = (
%templateParams,
AUTH_LOOP => $authLoop,
CHOICE_PARAM => $self->conf->{authChoiceParam},
CHOICE_VALUE => $req->data->{_authChoice},
DISPLAY_FORM => 0,
DISPLAY_OPENID_FORM => 0,
DISPLAY_YUBIKEY_FORM => 0,
);
}
# Choose what form to display if not in a loop
else {
my $displayType =
eval { $self->_authentication->getDisplayType($req) };
$self->logger->debug("Display type $displayType ");
%templateParams = (
%templateParams,
DISPLAY_FORM => $displayType =~ /\bstandardform\b/ ? 1
: 0,
DISPLAY_OPENID_FORM => $displayType =~ /\bopenidform\b/ ? 1
: 0,
DISPLAY_YUBIKEY_FORM => $displayType =~ /\byubikeyform\b/
? 1
: 0,
DISPLAY_SSL_FORM => $displayType =~ /sslform/ ? 1 : 0,
DISPLAY_GPG_FORM => $displayType =~ /gpgform/ ? 1 : 0,
DISPLAY_LOGO_FORM => $displayType eq "logo" ? 1 : 0,
module => $displayType eq "logo"
? $self->getModule( $req, 'auth' )
: "",
AUTH_LOOP => [],
PORTAL_URL =>
( $displayType eq "logo" ? $self->conf->{portal} : 0 ),
MSG => $req->info(),
);
}
my $form = $self->_authentication->getForm($req);
$filter->{LOGIN_FORM} = $form;
}
}
if ( $req->data->{waitingMessage} ) {
$templateParams{WAITING_MESSAGE} = 1;
}
$self->logger->debug("Skin returned: $skinfile");
return ( $skinfile, \%templateParams );
$self->logger->debug("Calling sendHtml with template $skinfile");
return $self->sendHtml(
$req, $skinfile,
params => \%templateParams,
filter => $filter
);
}
##@method public void printImage(string file, string type)

View File

@ -261,9 +261,7 @@ sub do {
)
)
{
my ( $tpl, $prms ) = $self->display($req);
$self->logger->debug("Calling sendHtml with template $tpl");
return $self->sendHtml( $req, $tpl, params => $prms );
return $self->display($req);
}
else {
$self->logger->debug('Calling autoredirect');
@ -322,9 +320,7 @@ sub autoRedirect {
[ Location => $req->{urldc}, @{ $req->respHeaders } ], [] ];
}
}
my ( $tpl, $prms ) = $self->display($req);
$self->logger->debug("Calling sendHtml with template $tpl");
return $self->sendHtml( $req, $tpl, params => $prms );
return $self->display($req);
}
# Try to recover the session corresponding to id and return session data.
@ -748,12 +744,14 @@ sub sendHtml {
# Check template
$args{templateDir} = $templateDir;
my $tmpl = $args{templateDir} . "/$template.tpl";
unless ( -f $tmpl ) {
$self->logger->debug("Template $tmpl not found");
$args{templateDir} = $self->conf->{templateDir} . '/bootstrap';
$tmpl = $args{templateDir} . "/$template.tpl";
$self->logger->debug("-> Trying to load $tmpl");
unless ( ref $template ) {
my $tmpl = $args{templateDir} . "/$template.tpl";
unless ( -f $tmpl ) {
$self->logger->debug("Template $tmpl not found");
$args{templateDir} = $self->conf->{templateDir} . '/bootstrap';
$tmpl = $args{templateDir} . "/$template.tpl";
$self->logger->debug("-> Trying to load $tmpl");
}
}
# Override messages

View File

@ -1,18 +1,24 @@
# Launch Kerberos request
_krbJsAlreadySent = false if _krbJsAlreadySent == null
$(document).ready ->
$.ajax portal + '?kerberos=1',
dataType: 'json'
# Called if browser can't find Kerberos ticket, will display
# PE_BADCREDENTIALS
statusCode:
401: () ->
unless _krbJsAlreadySent
_krbJsAlreadySent = 1
console.log 'Send Kerberos Ajax request'
$.ajax portal + '?kerberos=1',
dataType: 'json'
# Called if browser can't find Kerberos ticket, will display
# PE_BADCREDENTIALS
statusCode:
401: () ->
$('#lformKerberos').submit()
# If request succeed cookie is set, posting form to get redirection
# or menu
success: (data) ->
$('#lformKerberos').submit()
# If request succeed cookie is set, posting form to get redirection
# or menu
success: (data) ->
$('#lformKerberos').submit()
# Case else, will display PE_BADCREDENTIALS or fallback to next auth
# backend
error: () ->
$('#lformKerberos').submit()
# Case else, will display PE_BADCREDENTIALS or fallback to next auth
# backend
error: () ->
$('#lformKerberos').submit()
else
console.log 'Kerberos Ajax request already sent'

View File

@ -1,20 +1,32 @@
// Generated by CoffeeScript 1.12.8
(function() {
var _krbJsAlreadySent;
if (_krbJsAlreadySent === null) {
_krbJsAlreadySent = false;
}
$(document).ready(function() {
return $.ajax(portal + '?kerberos=1', {
dataType: 'json',
statusCode: {
401: function() {
if (!_krbJsAlreadySent) {
_krbJsAlreadySent = 1;
console.log('Send Kerberos Ajax request');
return $.ajax(portal + '?kerberos=1', {
dataType: 'json',
statusCode: {
401: function() {
return $('#lformKerberos').submit();
}
},
success: function(data) {
return $('#lformKerberos').submit();
},
error: function() {
return $('#lformKerberos').submit();
}
},
success: function(data) {
return $('#lformKerberos').submit();
},
error: function() {
return $('#lformKerberos').submit();
}
});
});
} else {
return console.log('Kerberos Ajax request already sent');
}
});
}).call(this);

View File

@ -1 +1 @@
(function(){$(document).ready(function(){return $.ajax(portal+"?kerberos=1",{dataType:"json",statusCode:{401:function(){return $("#lformKerberos").submit()}},success:function(data){return $("#lformKerberos").submit()},error:function(){return $("#lformKerberos").submit()}})})}).call(this);
(function(){var _krbJsAlreadySent;if(_krbJsAlreadySent===null){_krbJsAlreadySent=false}$(document).ready(function(){if(!_krbJsAlreadySent){_krbJsAlreadySent=1;console.log("Send Kerberos Ajax request");return $.ajax(portal+"?kerberos=1",{dataType:"json",statusCode:{401:function(){return $("#lformKerberos").submit()}},success:function(data){return $("#lformKerberos").submit()},error:function(){return $("#lformKerberos").submit()}})}else{return console.log("Kerberos Ajax request already sent")}})}).call(this);

View File

@ -0,0 +1,31 @@
</form>
<div id="authMenu" class="card">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="/"><i class="fa fa-user-circle"></i></a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<!-- Choice tabs -->
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<TMPL_LOOP NAME="AUTH_LOOP">
<li class="nav-item" title="<TMPL_VAR NAME="key">"><a class="nav-link" href="#<TMPL_VAR NAME="key">"><TMPL_VAR NAME="name"></a></li>
</TMPL_LOOP>
</ul>
</div>
</nav>
<div>
<TMPL_LOOP NAME="AUTH_LOOP">
<div id="<TMPL_VAR NAME="key">">
<form id="lform<TMPL_VAR NAME="module">" action="<TMPL_VAR NAME="url">" method="post" class="login <TMPL_VAR NAME="module">">
<TMPL_VAR NAME="HIDDEN_INPUTS">
<input type="hidden" name="url" value="<TMPL_VAR NAME="AUTH_URL">" />
<input type="hidden" name="timezone" />
<input type="hidden" name="<TMPL_VAR NAME="CHOICE_PARAM">" value="<TMPL_VAR NAME="key">" />
<input type="hidden" name="skin" value="<TMPL_VAR NAME="SKIN">" />
__LLNG_FORM__
</form>
</div>
</TMPL_LOOP>
<form>

View File

@ -0,0 +1,27 @@
<TMPL_IF NAME="CHOICE_PARAM">
<!-- //if:jsminified
<script type="text/javascript" src="<TMPL_VAR NAME="STATIC_PREFIX">common/js/kerberosChoice.min.js"></script>
//else -->
<script type="text/javascript" src="<TMPL_VAR NAME="STATIC_PREFIX">common/js/kerberosChoice.js"></script>
<!-- //endif -->
<TMPL_ELSE>
<!-- //if:jsminified
<script type="text/javascript" src="<TMPL_VAR NAME="STATIC_PREFIX">common/js/kerberos.min.js"></script>
//else -->
<script type="text/javascript" src="<TMPL_VAR NAME="STATIC_PREFIX">common/js/kerberos.js"></script>
<!-- //endif -->
</TMPL_IF>
<div class="form">
<input type="hidden" name="kerberos" value="0" />
<div class="sslclick">
<img src="<TMPL_VAR NAME="STATIC_PREFIX">common/modules/Kerberos.png" alt="<TMPL_VAR NAME="module">" class="img-thumbnail mb-3" />
</div>
<TMPL_INCLUDE NAME="impersonation.tpl">
<TMPL_INCLUDE NAME="checklogins.tpl">
<button type="submit" class="btn btn-success sslclick" >
<span class="fa fa-sign-in"></span>
<span trspan="connect">Connect</span>
</button>
</div>

View File

@ -8,248 +8,19 @@
<div class="message message-<TMPL_VAR NAME="AUTH_ERROR_TYPE"> alert"><span trmsg="<TMPL_VAR NAME="AUTH_ERROR">"></span></div>
</TMPL_IF>
<TMPL_IF AUTH_LOOP>
<div id="authMenu" class="card">
<!-- Authentication loop -->
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="/"><i class="fa fa-user-circle"></i></a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<!-- Choice tabs -->
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<TMPL_LOOP NAME="AUTH_LOOP">
<li class="nav-item" title="<TMPL_VAR NAME="key">"><a class="nav-link" href="#<TMPL_VAR NAME="key">"><TMPL_VAR NAME="name"></a></li>
</TMPL_LOOP>
</ul>
</div>
</nav>
<div>
<!-- Forms -->
<TMPL_LOOP NAME="AUTH_LOOP">
<div id="<TMPL_VAR NAME="key">">
<form id="lform<TMPL_VAR NAME="module">" action="<TMPL_VAR NAME="url">" method="post" class="login <TMPL_VAR NAME="module">">
<!-- Hidden fields -->
<TMPL_VAR NAME="HIDDEN_INPUTS">
<input type="hidden" name="url" value="<TMPL_VAR NAME="AUTH_URL">" />
<input type="hidden" name="timezone" />
<input type="hidden" name="<TMPL_VAR NAME="CHOICE_PARAM">" value="<TMPL_VAR NAME="key">" />
<input type="hidden" name="skin" value="<TMPL_VAR NAME="SKIN">" />
<TMPL_IF NAME="standardform">
<TMPL_INCLUDE NAME="standardform.tpl">
</TMPL_IF>
<TMPL_IF NAME="openidform">
<TMPL_INCLUDE NAME="openidform.tpl">
</TMPL_IF>
<TMPL_IF NAME="yubikeyform">
<TMPL_INCLUDE NAME="yubikeyform.tpl">
</TMPL_IF>
<TMPL_IF NAME="sslform">
<TMPL_INCLUDE NAME="sslformChoice.tpl">
</TMPL_IF>
<TMPL_IF NAME="gpgform">
<TMPL_INCLUDE NAME="gpgform.tpl">
</TMPL_IF>
<TMPL_IF NAME="logo">
<div class="form">
<TMPL_IF NAME="logoFile">
<img src="<TMPL_VAR NAME="STATIC_PREFIX">common/modules/<TMPL_VAR NAME="logoFile">" alt="<TMPL_VAR NAME="module">" class="img-thumbnail mb-3" />
</TMPL_IF>
<TMPL_INCLUDE NAME="impersonation.tpl">
<TMPL_INCLUDE NAME="checklogins.tpl">
<div class="buttons">
<button type="submit" class="btn btn-success">
<span class="fa fa-sign-in"></span>
<span trspan="connect">Connect</span>
</button>
</div>
</div>
</TMPL_IF>
</form>
</div>
</TMPL_LOOP>
</div>
</div> <!-- end authMenu -->
</TMPL_IF>
<TMPL_IF NAME="DISPLAY_FORM">
<div class="card">
<TMPL_IF NAME="module">
<form id="lform" action="#" method="post" class="login <TMPL_VAR NAME="module">" role="form">
<TMPL_ELSE>
<form id="lform" action="#" method="post" class="login" role="form">
</TMPL_IF>
<!-- Hidden fields -->
<TMPL_VAR NAME="HIDDEN_INPUTS">
<input type="hidden" name="url" value="<TMPL_VAR NAME="AUTH_URL">" />
<input type="hidden" name="timezone" />
<input type="hidden" name="skin" value="<TMPL_VAR NAME="SKIN">" />
<TMPL_INCLUDE NAME="standardform.tpl">
</form>
__LLNG_LOGIN_FORM__
</form>
</div>
</TMPL_IF>
<TMPL_IF NAME="DISPLAY_OPENID_FORM">
<div class="card">
<TMPL_IF NAME="module">
<form id="lform" action="#" method="post" class="login <TMPL_VAR NAME="module">" role="form">
<TMPL_ELSE>
<form id="lform" action="#" method="post" class="login" role="form">
</TMPL_IF>
<!-- Hidden fields -->
<TMPL_VAR NAME="HIDDEN_INPUTS">
<input type="hidden" name="url" value="<TMPL_VAR NAME="AUTH_URL">" />
<input type="hidden" name="timezone" />
<input type="hidden" name="skin" value="<TMPL_VAR NAME="SKIN">" />
<TMPL_INCLUDE NAME="openidform.tpl">
</form>
</div>
</TMPL_IF>
<TMPL_IF NAME="DISPLAY_SSL_FORM">
<div class="card">
<TMPL_IF NAME="module">
<form id="lform" action="#" method="post" class="login <TMPL_VAR NAME="module">" role="form">
<TMPL_ELSE>
<form id="lform" action="#" method="post" class="login" role="form">
</TMPL_IF>
<!-- Hidden fields -->
<TMPL_VAR NAME="HIDDEN_INPUTS">
<input type="hidden" name="url" value="<TMPL_VAR NAME="AUTH_URL">" />
<input type="hidden" name="timezone" />
<input type="hidden" name="skin" value="<TMPL_VAR NAME="SKIN">" />
<TMPL_INCLUDE NAME="sslform.tpl">
</form>
</div>
</TMPL_IF>
<TMPL_IF NAME="DISPLAY_GPG_FORM">
<div class="card">
<TMPL_IF NAME="module">
<form id="lform" action="#" method="post" class="login <TMPL_VAR NAME="module">" role="form">
<TMPL_ELSE>
<form id="lform" action="#" method="post" class="login" role="form">
</TMPL_IF>
<!-- Hidden fields -->
<TMPL_VAR NAME="HIDDEN_INPUTS">
<input type="hidden" name="url" value="<TMPL_VAR NAME="AUTH_URL">" />
<input type="hidden" name="timezone" />
<input type="hidden" name="skin" value="<TMPL_VAR NAME="SKIN">" />
<TMPL_INCLUDE NAME="gpgform.tpl">
</form>
</div>
</TMPL_IF>
<TMPL_IF NAME="DISPLAY_YUBIKEY_FORM">
<div class="card">
<TMPL_IF NAME="module">
<form id="lform" action="#" method="post" class="login <TMPL_VAR NAME="module">" role="form">
<TMPL_ELSE>
<form id="lform" action="#" method="post" class="login" role="form">
</TMPL_IF>
<!-- Hidden fields -->
<TMPL_VAR NAME="HIDDEN_INPUTS">
<input type="hidden" name="url" value="<TMPL_VAR NAME="AUTH_URL">" />
<input type="hidden" name="timezone" />
<input type="hidden" name="skin" value="<TMPL_VAR NAME="SKIN">" />
<TMPL_INCLUDE NAME="yubikeyform.tpl">
</form>
</div>
</TMPL_IF>
<TMPL_IF NAME="DISPLAY_LOGO_FORM">
<div class="card">
<TMPL_IF NAME="module">
<form id="lform" action="#" method="post" class="login <TMPL_VAR NAME="module">" role="form">
<TMPL_ELSE>
<form id="lform" action="#" method="post" class="login" role="form">
</TMPL_IF>
<!-- Hidden fields -->
<TMPL_VAR NAME="HIDDEN_INPUTS">
<input type="hidden" name="url" value="<TMPL_VAR NAME="AUTH_URL">" />
<input type="hidden" name="timezone" />
<input type="hidden" name="skin" value="<TMPL_VAR NAME="SKIN">" />
<div class="form">
<TMPL_IF NAME="module">
<img src="<TMPL_VAR NAME="STATIC_PREFIX">common/modules/<TMPL_VAR NAME="module">.png" alt="<TMPL_VAR NAME="module">" class="img-thumbnail" />
</TMPL_IF>
<TMPL_INCLUDE NAME="impersonation.tpl">
<TMPL_INCLUDE NAME="checklogins.tpl">
<div class="buttons">
<button type="submit" class="btn btn-success">
<span class="fa fa-sign-in"></span>
<span trspan="connect">Connect</span>
</button>
</div>
</div>
</form>
</div>
</TMPL_IF>
<TMPL_IF NAME="DISPLAY_PASSWORD">
<div id="password" class="card">
<TMPL_INCLUDE NAME="password.tpl">
</div>
</TMPL_IF>
<TMPL_IF NAME="LOGIN_INFO">
<div class="alert alert-info">
<TMPL_VAR NAME="LOGIN_INFO">
</div>
</TMPL_IF>
<TMPL_IF NAME="PORTAL_URL">
<div id="logout">
<div class="buttons">
<TMPL_IF NAME="MSG"><TMPL_VAR NAME="MSG"></TMPL_IF>
<a href="<TMPL_VAR NAME="PORTAL_URL">?cancel=1<TMPL_IF NAME="AUTH_URL">&url=<TMPL_VAR NAME="AUTH_URL"></TMPL_IF>" class="btn btn-primary" role="button">
<span class="fa fa-home"></span>
<span trspan="goToPortal">Go to portal</span>
</a>
</div>
</div>
</TMPL_IF>
<TMPL_IF NAME="LOGOUT_URL">
<div id="logout">
<div class="buttons">
<a href="<TMPL_VAR NAME="LOGOUT_URL">" class="btn btn-danger" role="button">
<span class="fa fa-sign-out"></span>&nbps;
<span trspan="logout">Logout</span>
</a>
</div>
</div>
</TMPL_IF>
<TMPL_INCLUDE NAME="customLoginFooter.tpl">

View File

@ -0,0 +1,14 @@
<div class="card">
<div class="form">
<TMPL_IF NAME="CUSTOM_LOGO">
<img src="<TMPL_VAR NAME="STATIC_PREFIX"><TMPL_VAR NAME="CUSTOM_LOGO">" class="img-thumbnail" />
</TMPL_IF>
<div class="buttons">
<button type="submit" class="btn btn-success">
<span class="fa fa-sign-in"></span>
<span trspan="connect">Connect</span>
</button>
</div>
</div>
</div>

View File

@ -1,9 +1,16 @@
<!-- //if:jsminified
<script type="text/javascript" src="<TMPL_VAR NAME="STATIC_PREFIX">common/js/ssl.min.js"></script>
//else -->
<script type="text/javascript" src="<TMPL_VAR NAME="STATIC_PREFIX">common/js/ssl.js"></script>
<!-- //endif -->
<TMPL_IF NAME="CHOICE_PARAM">
<!-- //if:jsminified
<script type="text/javascript" src="<TMPL_VAR NAME="STATIC_PREFIX">common/js/sslChoice.min.js"></script>
//else -->
<script type="text/javascript" src="<TMPL_VAR NAME="STATIC_PREFIX">common/js/sslChoice.js"></script>
<!-- //endif -->
<TMPL_ELSE>
<!-- //if:jsminified
<script type="text/javascript" src="<TMPL_VAR NAME="STATIC_PREFIX">common/js/ssl.min.js"></script>
//else -->
<script type="text/javascript" src="<TMPL_VAR NAME="STATIC_PREFIX">common/js/ssl.js"></script>
<!-- //endif -->
</TMPL_IF>
<div class="form">
<input type="hidden" name="nossl" value="1" />
<div class="sslclick">
@ -18,3 +25,6 @@
<span trspan="connect">Connect</span>
</button>
</div>
<script type="application/init">
{"sslHost":"<TMPL_VAR NAME="SSLHOST">"}
</script>

View File

@ -1,20 +0,0 @@
<!-- //if:jsminified
<script type="text/javascript" src="<TMPL_VAR NAME="STATIC_PREFIX">common/js/sslChoice.min.js"></script>
//else -->
<script type="text/javascript" src="<TMPL_VAR NAME="STATIC_PREFIX">common/js/sslChoice.js"></script>
<!-- //endif -->
<div class="form">
<input type="hidden" name="nossl" value="1" />
<div class="sslclick">
<img src="<TMPL_VAR NAME="STATIC_PREFIX">common/modules/SSL.png" alt="<TMPL_VAR NAME="module">" class="img-thumbnail mb-3" />
</div>
<TMPL_INCLUDE NAME="impersonation.tpl">
<TMPL_INCLUDE NAME="checklogins.tpl">
<button type="submit" class="btn btn-success sslclick" >
<span class="fa fa-sign-in"></span>
<span trspan="connect">Connect</span>
</button>
</div>

View File

@ -62,7 +62,10 @@ SKIP: {
# -------------------
ok( $res = $client->_get( '/', accept => 'text/html' ), 'Get menu' );
my @form = ( $res->[2]->[0] =~ m#<form.*?</form>#sg );
ok( @form == 2, 'Display 2 choices' );
pop @form;
shift @form;
ok( @form == 2, 'Display 2 choices' )
or explain( $res->[2]->[0], '2 forms' );
foreach (@form) {
expectForm( [ $res->[0], $res->[1], [$_] ], undef, undef, 'test' );
}

View File

@ -69,53 +69,53 @@ SKIP: {
ok( $res->[2]->[0] =~ /7_Kerberos/, '7_Kerberos displayed' );
ok( $res->[2]->[0] =~ qr%<img src="/static/common/modules/SSL.png"%,
'Found 5_ssl Logo' )
or print STDERR Dumper( $res->[2]->[0] );
or explain( $res->[2]->[0], '<img src="/static/common/modules/SSL.png' );
ok( $res->[2]->[0] =~ qr%img src="/static/common/modules/Apache.png"%,
'Found 6_FakeCustom Logo' )
or print STDERR Dumper( $res->[2]->[0] );
or explain( $res->[2]->[0], '<img src="/static/common/modules/Apache.png' );
ok( $res->[2]->[0] =~ qr%<img src="/static/common/modules/Kerberos.png"%,
'Found 7_Kerberos Logo' )
or print STDERR Dumper( $res->[2]->[0] );
or explain( $res->[2]->[0], '<img src="/static/common/modules/Kerberos.png' );
ok(
$res->[2]->[0] =~
m%<form id="lformDemo" action="https://test.example.com"%,
' Redirect URL found'
) or print STDERR Dumper( $res->[2]->[0] );
) or explain( $res->[2]->[0], '<form id="lformDemo" action="https://test.example.com"' );
ok(
$res->[2]->[0] =~
m%<script type="application/init">\{"sslHost":"https://authssl.example.com:19876"\}</script>%,
m%<script type="application/init">\s*\{"sslHost":"https://authssl.example.com:19876"\}\s*</script>%s,
' SSL AJAX URL found'
) or print STDERR Dumper( $res->[2]->[0] );
) or explain( $res->[2]->[0], '<script type="application/init">\{"sslHost"' );
expectForm( $res, '#', undef, 'kerberos' );
ok(
$res->[2]->[0] =~ m%<input type="hidden" name="kerberos" value="0" />%,
'Found hidden attribut "kerberos" with value="0"'
) or print STDERR Dumper( $res->[2]->[0] );
) or explain( $res->[2]->[0], '<input type="hidden" name="kerberos"' );
ok( $res->[2]->[0] =~ /kerberosChoice\.(?:min\.)?js/,
'Get Kerberos javascript' )
or print STDERR Dumper( $res->[2]->[0] );
or explain( $res->[2]->[0], 'kerberosChoice.(min.)?js' );
ok(
$res->[2]->[0] =~
m%<form id="lformKerberos" action="#" method="post" class="login Kerberos">%,
' Redirect URL found'
) or print STDERR Dumper( $res->[2]->[0] );
) or explain( $res->[2]->[0], '<form id="lformKerberos"' );
ok( $res->[2]->[0] =~ /sslChoice\.(?:min\.)?js/,
'Get sslChoice javascript' )
or print STDERR Dumper( $res->[2]->[0] );
or explain( $res->[2]->[0], 'sslChoice.(min.)?js' );
ok(
$res->[2]->[0] =~
m%<form id="lformSSL" action="#" method="post" class="login SSL">%,
' Action # found'
) or print STDERR Dumper( $res->[2]->[0] );
) or explain( $res->[2]->[0], '<form id="lformSSL"' );
my $header = getHeader( $res, 'Content-Security-Policy' );
ok( $header =~ m%;form-action \'self\' https://test.example.com;%,
' CSP URL found' )
or print STDERR Dumper( $res->[1] );
or explain( $res->[1], 'form-action \'self\' https://test.example.com;' );
ok( $res->[2]->[0] !~ /4_demo/, '4_Demo not displayed' );
ok(
$res->[2]->[0] =~ qr%<img src="/static/common/logos/logo_llng_old.png"%,
'Found custom Main Logo'
) or print STDERR Dumper( $res->[2]->[0] );
) or explain( $res->[2]->[0], '<img src="/static/common/logos/logo_llng_old.png"' );
# Test SQL
my $postString = 'user=dwho&password=dwho&test=2_sql';

View File

@ -21,7 +21,7 @@ my $client = LLNG::Manager::Test->new( {
ok( $res = $client->_get( '/', accept => 'text/html' ), 'Get Menu' );
ok(
$res->[2]->[0] =~
m%<script type="application/init">\{"sslHost":"https://authssl.example.com:19876"\}</script>%,
m%<script type="application/init">\s*\{"sslHost":"https://authssl.example.com:19876"\}\s*</script>%s,
' SSL AJAX URL found'
) or print STDERR Dumper( $res->[2]->[0] );
ok( $res->[2]->[0] =~ qr%<img src="/static/common/modules/SSL.png"%,

View File

@ -34,6 +34,7 @@ SKIP: {
type => 'Demo',
},
},
combinationForms => 'kerberos standardform',
demoExportedVars => {},
krbKeytab => '/etc/keytab',
krbByJs => 1,
@ -41,7 +42,8 @@ SKIP: {
}
);
ok( $res = $client->_get( '/', accept => 'text/html' ), 'Simple access' );
ok( $res->[2]->[0] =~ /script.*kerberos\.js/s, 'Found Kerberos JS' );
ok( $res->[2]->[0] =~ /script.*kerberos\.js/s, 'Found Kerberos JS' )
or explain( $res->[2]->[0], 'script.*kerberos.js' );
my ( $host, $url, $query ) = expectForm( $res, '#' );
# TODO

View File

@ -35,7 +35,7 @@ SKIP: {
my $token;
ok( $token = $1, ' Token value is defined' );
ok( $res->[2]->[0] =~ m#<img src="data:image/png;base64#,
' Captcha image inserted' );
' Captcha image inserted' ) or explain($res->[2]->[0], '<img src="data:image/png;base64');
# Try to get captcha value