New forms for grantSessionRule
This commit is contained in:
parent
c303fba294
commit
5c7cc89610
|
@ -437,7 +437,7 @@ qr/^(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-zA-Z0-
|
|||
},
|
||||
'grantSessionRules' => {
|
||||
'keyTest' => sub { "DUMMY" },
|
||||
'type' => 'keyTextContainer'
|
||||
'type' => 'grantContainer'
|
||||
},
|
||||
'groups' => {
|
||||
'default' => {},
|
||||
|
|
|
@ -355,7 +355,7 @@ sub attributes {
|
|||
documentation => 'Check XSS',
|
||||
},
|
||||
grantSessionRules => {
|
||||
type => 'keyTextContainer',
|
||||
type => 'grantContainer',
|
||||
keyTest => $perlExpr,
|
||||
},
|
||||
hiddenAttributes => {
|
||||
|
|
|
@ -35,7 +35,7 @@ sub addRoutes {
|
|||
->addRoute(
|
||||
confs => {
|
||||
':cfgNum' => [
|
||||
qw(virtualHosts samlIDPMetaDataNodes samlSPMetaDataNodes applicationList oidcOPMetaDataNodes oidcRPMetaDataNodes authChoiceModules)
|
||||
qw(virtualHosts samlIDPMetaDataNodes samlSPMetaDataNodes applicationList oidcOPMetaDataNodes oidcRPMetaDataNodes authChoiceModules grantSessionRules)
|
||||
]
|
||||
},
|
||||
['GET']
|
||||
|
@ -441,9 +441,10 @@ sub oidcRPMetaDataNodes {
|
|||
return $self->_oidcMetaDataNodes( 'RP', $req, @path );
|
||||
}
|
||||
|
||||
## @method PSGI-JSON-response authChoiceModules(key)
|
||||
## @method PSGI-JSON-response authChoiceModules($req,$key)
|
||||
# Returns authChoiceModules keys splitted in arrays
|
||||
#
|
||||
#@param $req Lemonldap::NG::PSGI::Request
|
||||
#@param key optional subkey
|
||||
#@return PSGI JSON response
|
||||
sub authChoiceModules {
|
||||
|
@ -468,6 +469,41 @@ sub authChoiceModules {
|
|||
}
|
||||
}
|
||||
|
||||
## @method PSGI-JSON-response $grantSessionRules($req)
|
||||
#Respond to `/conf/:cfgNum` requests by sending configuration metadatas
|
||||
#
|
||||
#@param $req Lemonldap::NG::PSGI::Request
|
||||
#@return PSGI JSON response
|
||||
sub grantSessionRules {
|
||||
my ( $self, $req, $key ) = splice @_;
|
||||
return $self->sendError( 'Subkeys forbidden for grantSessionRules', 400 )
|
||||
if ($key);
|
||||
my $value = $self->getConfKey( $req, 'grantSessionRules' );
|
||||
my @res;
|
||||
|
||||
sub _sort {
|
||||
my $A = ( $a =~ /^.*?##(.*)$/ )[0];
|
||||
my $B = ( $b =~ /^.*?##(.*)$/ )[0];
|
||||
return !$A ? 1 : !$B ? -1 : $A cmp $B;
|
||||
}
|
||||
my $id = 0;
|
||||
foreach my $k ( sort _sort keys %$value ) {
|
||||
my $r = $k;
|
||||
my $c = ( $r =~ s/^(.*)?##(.*)$/$1/ ? $2 : '' );
|
||||
$id++;
|
||||
push @res,
|
||||
{
|
||||
id => "grantSessionRules/$id",
|
||||
title => $c || $r,
|
||||
re => $r,
|
||||
comment => $c,
|
||||
data => $value->{$k},
|
||||
type => 'grant'
|
||||
};
|
||||
}
|
||||
return $self->sendJSONresponse( $req, \@res );
|
||||
}
|
||||
|
||||
## @method PSGI-JSON-response metadatas($req)
|
||||
#Respond to `/conf/:cfgNum` requests by sending configuration metadatas
|
||||
#
|
||||
|
@ -659,7 +695,8 @@ sub newConf {
|
|||
# "message" fields: note that words enclosed by "__" (__word__) will be translated
|
||||
$res->{message} = $parser->{message};
|
||||
foreach my $t (qw(errors warnings changes)) {
|
||||
$res->{details}->{'__'.$t.'__'} = $parser->$t if ( @{ $parser->$t } );
|
||||
$res->{details}->{ '__' . $t . '__' } = $parser->$t
|
||||
if ( @{ $parser->$t } );
|
||||
}
|
||||
if ( $res->{result} ) {
|
||||
if ( $self->{demoMode} ) {
|
||||
|
|
|
@ -432,6 +432,51 @@ sub _scanNodes {
|
|||
}
|
||||
next;
|
||||
}
|
||||
elsif ( $leaf->{id} eq 'grantSessionRules' ) {
|
||||
hdebug('grantSessionRules');
|
||||
if ( $leaf->{cnodes} ) {
|
||||
hdebug(' unopened');
|
||||
$self->newConf->{$name} = $self->refConf->{$name} // {};
|
||||
}
|
||||
else {
|
||||
hdebug(' opened');
|
||||
$subNodes //= [];
|
||||
my $count = 0;
|
||||
my $ref = $self->refConf->{grantSessionRules};
|
||||
my $new = $self->newConf->{grantSessionRules};
|
||||
my @old = ref $ref ? keys %$ref : ();
|
||||
$self->newConf->{grantSessionRules} = {};
|
||||
foreach my $n (@$subNodes) {
|
||||
hdebug(" looking at $n subnode");
|
||||
my $k =
|
||||
$n->{re} . ( $n->{comment} ? "##$n->{comment}" : '' );
|
||||
$self->newConf->{grantSessionRules}->{$k} = $n->{data};
|
||||
$count++;
|
||||
unless ( defined $ref->{$k} ) {
|
||||
$self->confChanged(1);
|
||||
push @{ $self->changes },
|
||||
{ keys => 'grantSessionRules', new => $k };
|
||||
}
|
||||
elsif ( $ref->{$k} ne $n->{data} ) {
|
||||
$self->confChanged(1);
|
||||
push @{ $self->changes },
|
||||
{
|
||||
key => "grantSessionRules, $k",
|
||||
old => $self->refConf->{grantSessionRules}->{$k},
|
||||
new => $n->{data}
|
||||
};
|
||||
}
|
||||
@old = grep { $_ ne $k } @old;
|
||||
}
|
||||
if (@old) {
|
||||
$self->confChanged(1);
|
||||
push @{ $self->changes },
|
||||
{ key => 'grantSessionRules', old => $_, }
|
||||
foreach (@old);
|
||||
}
|
||||
}
|
||||
next;
|
||||
}
|
||||
|
||||
####################
|
||||
# Other hash nodes #
|
||||
|
|
29
lemonldap-ng-manager/site/static/forms/grant.html
Normal file
29
lemonldap-ng-manager/site/static/forms/grant.html
Normal file
|
@ -0,0 +1,29 @@
|
|||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title" trspan="rule"/>
|
||||
</div>
|
||||
<table class="table">
|
||||
<tr>
|
||||
<th><span trspan="comment" /></th>
|
||||
<td ng-if="currentNode.re!='default'"><input id="rulecomment" class="form-control" ng-model="currentNode.comment" ng-change="changeRuleTitle(currentNode)"/></td>
|
||||
<td ng-if="currentNode.re=='default'"><p><strong><span trspan="defaultRule" /></strong></p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><span trspan="rule" /></th>
|
||||
<td><input id="rule" class="form-control"ng-model="currentNode.re" ng-change="changeRuleTitle(currentNode)"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><span trspan="message" /></th>
|
||||
<td><textarea rows="3" id="rulemessage" class="form-control" ng-model="currentNode.data"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
buttons=[{
|
||||
'title': 'newGrantRule',
|
||||
'icon': 'plus-sign'
|
||||
},{
|
||||
'title': 'deleteEntry',
|
||||
'icon': 'minus-sign'
|
||||
}];
|
||||
</script>
|
38
lemonldap-ng-manager/site/static/forms/grantContainer.html
Normal file
38
lemonldap-ng-manager/site/static/forms/grantContainer.html
Normal file
|
@ -0,0 +1,38 @@
|
|||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">{{translateTitle(currentNode)}}</h3>
|
||||
</div>
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="20%" trspan="comments"/>
|
||||
<th width="30%" trspan="rules"/>
|
||||
<th width="50%" trspan="messages"/>
|
||||
<th />
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="s in currentNode.nodes">
|
||||
<td>
|
||||
<input class="form-control" ng-model="s.comment" ng-change="changeRuleTitle(s)"/>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" ng-model="s.re" ng-change="changeRuleTitle(s)"/>
|
||||
</td>
|
||||
<td>
|
||||
<input class="form-control" ng-model="s.data"/>
|
||||
</td>
|
||||
<td>
|
||||
<span ng-if="s.re!='default'" class="link text-danger glyphicon glyphicon-minus-sign" ng-click="del(currentNode.nodes,$index)"/>
|
||||
<span ng-if="$last" class="link text-success glyphicon glyphicon-plus-sign" ng-click="menuClick({title:'newRule'})"/>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
buttons=[{
|
||||
'title': 'newGrantRule',
|
||||
'icon': 'plus-sign'
|
||||
}];
|
||||
</script>
|
|
@ -5,7 +5,7 @@
|
|||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="20%" trspan="comment"/>
|
||||
<th width="20%" trspan="comments"/>
|
||||
<th width="30%" trspan="regexps"/>
|
||||
<th width="50%" trspan="rules"/>
|
||||
<th />
|
||||
|
|
|
@ -232,6 +232,21 @@
|
|||
return cs;
|
||||
}
|
||||
|
||||
/* Add grant rule entry */
|
||||
$scope.newGrantRule = function() {
|
||||
var node = $scope._findContainer();
|
||||
var l = node.nodes.length;
|
||||
var n = l > 0 ? l - 1 : 0;
|
||||
node.nodes.splice(n, 0, {
|
||||
"id": node.id + '/n' + (id++),
|
||||
"title": 'New rule',
|
||||
"re": '1',
|
||||
"comment": 'New rule',
|
||||
"data": 'Message',
|
||||
"type": "grant"
|
||||
});
|
||||
}
|
||||
|
||||
/* Add rules entry */
|
||||
$scope.newRule = function() {
|
||||
var node = $scope._findContainer();
|
||||
|
@ -772,4 +787,4 @@
|
|||
};
|
||||
}]);
|
||||
|
||||
})();
|
||||
})();
|
||||
|
|
|
@ -100,6 +100,7 @@
|
|||
"chooseLogo": "Choose logo",
|
||||
"chooseSkin": "Choose skin",
|
||||
"comment": "Comment",
|
||||
"comments": "Comments",
|
||||
"condition": "Condition",
|
||||
"conf": "Configuration",
|
||||
"Configuration": "Configuration",
|
||||
|
@ -288,6 +289,8 @@
|
|||
"mandatory": "Mandatory",
|
||||
"markAsDone": "Mark as done",
|
||||
"memberOfSSOGroups": "Member of SSO groups",
|
||||
"message": "Message",
|
||||
"messages": "Messages",
|
||||
"menuCategory": "Menu category",
|
||||
"modulesTitle": "Used modules",
|
||||
"multiAuthStack": "Authentication stack string",
|
||||
|
@ -304,6 +307,7 @@
|
|||
"newCat": "New category",
|
||||
"newCfgAvailable": "A new configuration is available",
|
||||
"newEntry": "New entry",
|
||||
"newGrantRule": "New grant rule",
|
||||
"newPost": "New form replay",
|
||||
"newRSAKey": "New keys",
|
||||
"newRule": "New rule",
|
||||
|
|
|
@ -100,6 +100,7 @@
|
|||
"chooseLogo": "Choisir le logo",
|
||||
"chooseSkin": "Choisir le thème",
|
||||
"comment": "Commentaire",
|
||||
"comments": "Commentaires",
|
||||
"condition": "Condition",
|
||||
"conf": "Configuration",
|
||||
"Configuration": "Configuration",
|
||||
|
@ -288,6 +289,8 @@
|
|||
"mandatory": "Obligatoire",
|
||||
"markAsDone": "Marquer comme validée",
|
||||
"memberOfSSOGroups": "Membre des groupes SSO",
|
||||
"message": "Message",
|
||||
"messages": "Messages",
|
||||
"menuCategory": "Catégorie du menu",
|
||||
"modulesTitle": "Modules utilisés",
|
||||
"multiAuthStack": "Pile d'authentification",
|
||||
|
@ -304,6 +307,7 @@
|
|||
"newCat": "Nouvelle catégorie",
|
||||
"newCfgAvailable": "Une nouvelle configuration est disponible",
|
||||
"newEntry": "Nouvelle entrée",
|
||||
"newGrantRule": "Nouvelle règle d'accès",
|
||||
"newPost": "Nouveau rejeu de formulaire",
|
||||
"newRSAKey": "Nouvelles clefs",
|
||||
"newRule": "Nouvelle règle",
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user