Lemonldap-NG-Portal
view release on metacpan or search on metacpan
lib/Lemonldap/NG/Portal/Main/Display.pm view on Meta::CPAN
"Lemonldap::NG::Portal::Plugins::FindUser"};
my ( $fields, $slogin, $mandatory ) = ( [], '', 0 );
if ( $plugin
&& $self->conf->{findUser}
&& $self->conf->{impersonationRule}
&& $self->conf->{findUserSearchingAttributes} )
{
$slogin = $req->data->{findUser};
( $fields, $mandatory ) = $plugin->buildForm();
}
# 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,
DISPLAY_FINDUSER => scalar @$fields,
MANDATORY => $mandatory,
FIELDS => $fields,
SPOOFID => $slogin,
# Hidden inputs and custom scripts may have been modified
# by _buildAuthLoop so we need to update them
HIDDEN_INPUTS => $self->buildHiddenForm($req),
(
$req->data->{customScript}
? ( CUSTOM_SCRIPT => $req->data->{customScript} )
: ()
),
);
}
# Choose which form to display if not in a loop
else {
my $displayType =
eval { $self->_authentication->getDisplayType($req) }
|| 'logo';
$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_WEBAUTHN_FORM => $displayType =~ /webauthnform/ ? 1
: 0,
DISPLAY_GPG_FORM => $displayType =~ /gpgform/ ? 1 : 0,
DISPLAY_LOGO_FORM => $displayType eq "logo" ? 1 : 0,
DISPLAY_FINDUSER => scalar @$fields,
module => $displayType eq "logo"
? $self->getModule( $req, 'auth' )
: "",
AUTH_LOOP => [],
PORTAL_URL => ( $displayType eq "logo" ? $req->portal : 0 ),
MSG => $req->info(),
MANDATORY => $mandatory,
FIELDS => $fields,
SPOOFID => $slogin
);
}
}
}
if ( $req->data->{waitingMessage} ) {
$templateParams{WAITING_MESSAGE} = 1;
}
$self->logger->debug("Skin returned: $skinfile");
return ( $skinfile, \%templateParams );
}
##@method public void printImage(string file, string type)
# Print image to STDOUT
# @param $file The path to the file to print
# @param $type The content-type to use (ie: image/png)
# @return void
sub staticFile {
my ( $self, $req, $file, $type ) = @_;
require Plack::Util;
require Cwd;
require HTTP::Date;
open my $fh, '<:raw', $self->conf->{templateDir} . "/$file"
or return $self->sendError( $req,
$self->conf->{templateDir} . "/$file: $!", 403 );
my @stat = stat $file;
Plack::Util::set_io_path( $fh, Cwd::realpath($file) );
return [
200,
[
'Content-Type' => $type,
'Content-Length' => $stat[7],
'Last-Modified' => HTTP::Date::time2str( $stat[9] )
],
$fh,
];
}
sub buildOutgoingHiddenForm {
my ( $self, $req, $method ) = @_;
my @extra_keys;
if ( lc $method eq 'get' ) {
my $uri = URI->new( $req->{urldc} );
@extra_keys = $uri->query_form;
}
return $self->buildHiddenForm( $req, @extra_keys );
( run in 0.762 second using v1.01-cache-2.11-cpan-df04353d9ac )