Condition on Choice tab (#1413)

environments/ppa-mbqj77/deployments/1
Clément OUDOT 7 years ago
parent cc100316f5
commit 2d388c174a
  1. 2
      lemonldap-ng-manager/site/htdocs/static/css/manager.css
  2. 2
      lemonldap-ng-manager/site/htdocs/static/css/manager.min.css
  3. 6
      lemonldap-ng-manager/site/htdocs/static/forms/authChoice.html
  4. 4
      lemonldap-ng-manager/site/htdocs/static/forms/authChoiceContainer.html
  5. 86
      lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Lib/Choice.pm

@ -44,7 +44,7 @@
/* Tables */
.panel .table th {
width: 20%;
width: 10%;
vertical-align: middle;
}

@ -1 +1 @@
.tree-node{border-width:1px;border-style:solid;border-radius:4px;margin-bottom:8px}.tree-node-default{background:#fff}.angular-ui-tree-handle{cursor:pointer}#pleaseWait{background-color:#fff;width:100%;min-height:9.9%;height:auto;z-index:5000;position:absolute;left:0;top:0;margin-left:auto;margin-right:auto;padding:30% 20%;text-align:center;opacity:.8;filter:alpha(opacity=80)}.panel .table th{width:20%;vertical-align:middle}ul.cat-tree{list-style-type:square}p.cat-tree-category{font-weight:bold}html,body{margin:0;padding:0;height:100vh;background:radial-gradient(circle at 50% 0,#fff 0,#ddd 100%) no-repeat scroll 0 0 #ddd}header#navbar{height:9vh;margin-bottom:1vh;padding-bottom:0vh}#content{max-height:86vh;height:86vh;margin:0;padding:0;position:relative}header#navbar .navbar-brand{padding:10px 15px}header#navbar .navbar-brand img{background:#fff}textarea{width:100%}textarea#privateKey,textarea#publicKey,textarea#filetext{font-size:8pt}dl,.panel{margin-bottom:8px}.panel-body{padding:5px}.input-group-solid{border:1px solid #CCC;border-radius:4px;padding:6px 12px}.input-group>.input-group-solid:last-child{border-bottom-left-radius:0;border-top-left-radius:0}#cfgnum{position:relative}#cfgnum.label-warning:hover:after{content:attr(comment);padding:4px 8px;color:rgba(0,0,0,0.5);position:absolute;left:100%;bottom:100%;white-space:nowrap;z-index:2;border-radius:5px;background:#f0ad4e}.link{cursor:pointer}#bottom .panel{height:100%;margin-top:8px}#bottom .panel-body{height:100%}#right{display:flex;flex-direction:column}#bottom{flex:1}@media(min-width:768px){.scrollable-sm{max-height:86vh!important;overflow:auto}#right,#left{max-height:86vh!important;height:86vh}#top{overflow-x:hidden}#bottom{height:43vh;overflow:hidden}}#top,#bottom,#right,#left{position:relative}@media(max-width:767px){#right{position:absolute;top:0;z-index:1000}.lmmenu{position:static;float:left;width:100%;min-height:200px;margin-top:0;border:1px solid #ccc;box-shadow:none}#content{position:relative}}.scrollable{overflow:auto}.container{padding-bottom:15px}.hresizer{position:absolute;width:6px;top:0;bottom:0;right:0;background-color:#EEE;cursor:e-resize}.vresizer{position:absolute;height:6px;left:0;right:0;top:0;background-color:#EEE;cursor:n-resize}.angular-ui-tree-empty{min-height:auto;border:0}.old{color:#A00}.new{color:#0A0}.maxw{width:100%}.center{text-align:center}.backgrounddiv{margin-top:10px}.llcontainer{position:relative;margin-bottom:10px}
.tree-node{border-width:1px;border-style:solid;border-radius:4px;margin-bottom:8px}.tree-node-default{background:#fff}.angular-ui-tree-handle{cursor:pointer}#pleaseWait{background-color:#fff;width:100%;min-height:9.9%;height:auto;z-index:5000;position:absolute;left:0;top:0;margin-left:auto;margin-right:auto;padding:30% 20%;text-align:center;opacity:.8;filter:alpha(opacity=80)}.panel .table th{width:10%;vertical-align:middle}ul.cat-tree{list-style-type:square}p.cat-tree-category{font-weight:bold}html,body{margin:0;padding:0;height:100vh;background:radial-gradient(circle at 50% 0,#fff 0,#ddd 100%) no-repeat scroll 0 0 #ddd}header#navbar{height:9vh;margin-bottom:1vh;padding-bottom:0vh}#content{max-height:86vh;height:86vh;margin:0;padding:0;position:relative}header#navbar .navbar-brand{padding:10px 15px}header#navbar .navbar-brand img{background:#fff}textarea{width:100%}textarea#privateKey,textarea#publicKey,textarea#filetext{font-size:8pt}dl,.panel{margin-bottom:8px}.panel-body{padding:5px}.input-group-solid{border:1px solid #CCC;border-radius:4px;padding:6px 12px}.input-group>.input-group-solid:last-child{border-bottom-left-radius:0;border-top-left-radius:0}#cfgnum{position:relative}#cfgnum.label-warning:hover:after{content:attr(comment);padding:4px 8px;color:rgba(0,0,0,0.5);position:absolute;left:100%;bottom:100%;white-space:nowrap;z-index:2;border-radius:5px;background:#f0ad4e}.link{cursor:pointer}#bottom .panel{height:100%;margin-top:8px}#bottom .panel-body{height:100%}#right{display:flex;flex-direction:column}#bottom{flex:1}@media(min-width:768px){.scrollable-sm{max-height:86vh!important;overflow:auto}#right,#left{max-height:86vh!important;height:86vh}#top{overflow-x:hidden}#bottom{height:43vh;overflow:hidden}}#top,#bottom,#right,#left{position:relative}@media(max-width:767px){#right{position:absolute;top:0;z-index:1000}.lmmenu{position:static;float:left;width:100%;min-height:200px;margin-top:0;border:1px solid #ccc;box-shadow:none}#content{position:relative}}.scrollable{overflow:auto}.container{padding-bottom:15px}.hresizer{position:absolute;width:6px;top:0;bottom:0;right:0;background-color:#EEE;cursor:e-resize}.vresizer{position:absolute;height:6px;left:0;right:0;top:0;background-color:#EEE;cursor:n-resize}.angular-ui-tree-empty{min-height:auto;border:0}.old{color:#A00}.new{color:#0A0}.maxw{width:100%}.center{text-align:center}.backgrounddiv{margin-top:10px}.llcontainer{position:relative;margin-bottom:10px}

@ -24,6 +24,12 @@
<input class="form-control" ng-model="currentNode.data[3]" id="urli" aria-describedby="urllabel">
</td>
</tr>
<tr>
<td id="condlabel" for="condi" trspan="condition"></td>
<td>
<input class="form-control" ng-model="currentNode.data[4]" id="condi" aria-describedby="condlabel">
</td>
</tr>
</tbody>
</table>
</div>

@ -10,6 +10,7 @@
<th id="userdblabel" trspan="userDB"></th>
<th id="pwdlabel" trspan="passwordDB"></th>
<th id="urllabel" trspan="url"></th>
<th id="condlabel" trspan="condition"></th>
</tr>
</thead>
<tbody>
@ -25,6 +26,9 @@
<td>
<input class="form-control" ng-model="c.data[3]" aria-describedby="urllabel">
</td>
<td>
<input class="form-control" ng-model="c.data[4]" aria-describedby="condlabel">
</td>
<td>
<span class="link text-danger glyphicon glyphicon-minus-sign" ng-click="del(currentNode.nodes,$index)"/>
</td>

@ -2,6 +2,7 @@ package Lemonldap::NG::Portal::Lib::Choice;
use strict;
use Mouse;
use Safe;
extends 'Lemonldap::NG::Portal::Lib::Wrapper';
@ -89,6 +90,7 @@ package Lemonldap::NG::Portal::Main;
sub _buildAuthLoop {
my ( $self, $req ) = @_;
my @authLoop;
my $safe = Safe->new;
# Test authentication choices
unless ( ref $self->conf->{authChoiceModules} eq 'HASH' ) {
@ -112,34 +114,44 @@ sub _buildAuthLoop {
$name =~ s/\_/ /g;
# Find modules associated to authChoice
my ( $auth, $userDB, $passwordDB, $url ) =
my ( $auth, $userDB, $passwordDB, $url, $condition ) =
split( /[;\|]/, $self->conf->{authChoiceModules}->{$_} );
if ( $auth and $userDB and $passwordDB ) {
# Default URL
if ( defined $url
and not $self->p->checkXSSAttack( 'URI',
$req->env->{'REQUEST_URI'} ) )
{
$url .= $req->env->{'REQUEST_URI'};
}
else {
$url .= '#';
}
$self->logger->debug("Use URL $url");
# Options to store in the loop
my $optionsLoop =
{ name => $name, key => $_, module => $auth, url => $url };
# Get displayType for this module
no strict 'refs';
my $displayType = "Lemonldap::NG::Portal::Auth::${auth}"
->can('getDisplayType')->( undef, $req );
$self->logger->debug("Display type $displayType for module $auth");
$optionsLoop->{$displayType} = 1;
if ( defined $condition and !$safe->reval($condition) ) {
$self->logger->debug(
"Condition returns false, authentication choice $name will not be displayed"
);
}
else {
if ( $auth and $userDB and $passwordDB ) {
# Default URL
if (
defined $url
and not $self->p->checkXSSAttack(
'URI', $req->env->{'REQUEST_URI'}
)
)
{
$url .= $req->env->{'REQUEST_URI'};
}
else {
$url .= '#';
}
$self->logger->debug("Use URL $url");
# Options to store in the loop
my $optionsLoop =
{ name => $name, key => $_, module => $auth, url => $url };
# Get displayType for this module
no strict 'refs';
my $displayType = "Lemonldap::NG::Portal::Auth::${auth}"
->can('getDisplayType')->( undef, $req );
$self->logger->debug(
"Display type $displayType for module $auth");
$optionsLoop->{$displayType} = 1;
# If displayType is logo, check if key.png is available
# TODO:
@ -149,20 +161,20 @@ sub _buildAuthLoop {
# $optionsLoop->{logoFile} = $_ . ".png";
#}
#else {
$optionsLoop->{logoFile} = $auth . ".png";
#}
$optionsLoop->{logoFile} = $auth . ".png";
# Register item in loop
push @authLoop, $optionsLoop;
#}
$self->logger->debug(
"Authentication choice $name will be displayed");
}
# Register item in loop
push @authLoop, $optionsLoop;
else {
$req->error("Authentication choice $_ value is invalid");
return 0;
$self->logger->debug(
"Authentication choice $name will be displayed");
}
else {
$req->error("Authentication choice $_ value is invalid");
return 0;
}
}
}

Loading…
Cancel
Save