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' => {
|
'grantSessionRules' => {
|
||||||
'keyTest' => sub { "DUMMY" },
|
'keyTest' => sub { "DUMMY" },
|
||||||
'type' => 'keyTextContainer'
|
'type' => 'grantContainer'
|
||||||
},
|
},
|
||||||
'groups' => {
|
'groups' => {
|
||||||
'default' => {},
|
'default' => {},
|
||||||
|
|
|
@ -355,7 +355,7 @@ sub attributes {
|
||||||
documentation => 'Check XSS',
|
documentation => 'Check XSS',
|
||||||
},
|
},
|
||||||
grantSessionRules => {
|
grantSessionRules => {
|
||||||
type => 'keyTextContainer',
|
type => 'grantContainer',
|
||||||
keyTest => $perlExpr,
|
keyTest => $perlExpr,
|
||||||
},
|
},
|
||||||
hiddenAttributes => {
|
hiddenAttributes => {
|
||||||
|
|
|
@ -35,7 +35,7 @@ sub addRoutes {
|
||||||
->addRoute(
|
->addRoute(
|
||||||
confs => {
|
confs => {
|
||||||
':cfgNum' => [
|
':cfgNum' => [
|
||||||
qw(virtualHosts samlIDPMetaDataNodes samlSPMetaDataNodes applicationList oidcOPMetaDataNodes oidcRPMetaDataNodes authChoiceModules)
|
qw(virtualHosts samlIDPMetaDataNodes samlSPMetaDataNodes applicationList oidcOPMetaDataNodes oidcRPMetaDataNodes authChoiceModules grantSessionRules)
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
['GET']
|
['GET']
|
||||||
|
@ -441,9 +441,10 @@ sub oidcRPMetaDataNodes {
|
||||||
return $self->_oidcMetaDataNodes( 'RP', $req, @path );
|
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
|
# Returns authChoiceModules keys splitted in arrays
|
||||||
#
|
#
|
||||||
|
#@param $req Lemonldap::NG::PSGI::Request
|
||||||
#@param key optional subkey
|
#@param key optional subkey
|
||||||
#@return PSGI JSON response
|
#@return PSGI JSON response
|
||||||
sub authChoiceModules {
|
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)
|
## @method PSGI-JSON-response metadatas($req)
|
||||||
#Respond to `/conf/:cfgNum` requests by sending configuration metadatas
|
#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
|
# "message" fields: note that words enclosed by "__" (__word__) will be translated
|
||||||
$res->{message} = $parser->{message};
|
$res->{message} = $parser->{message};
|
||||||
foreach my $t (qw(errors warnings changes)) {
|
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 ( $res->{result} ) {
|
||||||
if ( $self->{demoMode} ) {
|
if ( $self->{demoMode} ) {
|
||||||
|
|
|
@ -432,6 +432,51 @@ sub _scanNodes {
|
||||||
}
|
}
|
||||||
next;
|
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 #
|
# 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">
|
<table class="table table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th width="20%" trspan="comment"/>
|
<th width="20%" trspan="comments"/>
|
||||||
<th width="30%" trspan="regexps"/>
|
<th width="30%" trspan="regexps"/>
|
||||||
<th width="50%" trspan="rules"/>
|
<th width="50%" trspan="rules"/>
|
||||||
<th />
|
<th />
|
||||||
|
|
|
@ -232,6 +232,21 @@
|
||||||
return cs;
|
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 */
|
/* Add rules entry */
|
||||||
$scope.newRule = function() {
|
$scope.newRule = function() {
|
||||||
var node = $scope._findContainer();
|
var node = $scope._findContainer();
|
||||||
|
|
|
@ -100,6 +100,7 @@
|
||||||
"chooseLogo": "Choose logo",
|
"chooseLogo": "Choose logo",
|
||||||
"chooseSkin": "Choose skin",
|
"chooseSkin": "Choose skin",
|
||||||
"comment": "Comment",
|
"comment": "Comment",
|
||||||
|
"comments": "Comments",
|
||||||
"condition": "Condition",
|
"condition": "Condition",
|
||||||
"conf": "Configuration",
|
"conf": "Configuration",
|
||||||
"Configuration": "Configuration",
|
"Configuration": "Configuration",
|
||||||
|
@ -288,6 +289,8 @@
|
||||||
"mandatory": "Mandatory",
|
"mandatory": "Mandatory",
|
||||||
"markAsDone": "Mark as done",
|
"markAsDone": "Mark as done",
|
||||||
"memberOfSSOGroups": "Member of SSO groups",
|
"memberOfSSOGroups": "Member of SSO groups",
|
||||||
|
"message": "Message",
|
||||||
|
"messages": "Messages",
|
||||||
"menuCategory": "Menu category",
|
"menuCategory": "Menu category",
|
||||||
"modulesTitle": "Used modules",
|
"modulesTitle": "Used modules",
|
||||||
"multiAuthStack": "Authentication stack string",
|
"multiAuthStack": "Authentication stack string",
|
||||||
|
@ -304,6 +307,7 @@
|
||||||
"newCat": "New category",
|
"newCat": "New category",
|
||||||
"newCfgAvailable": "A new configuration is available",
|
"newCfgAvailable": "A new configuration is available",
|
||||||
"newEntry": "New entry",
|
"newEntry": "New entry",
|
||||||
|
"newGrantRule": "New grant rule",
|
||||||
"newPost": "New form replay",
|
"newPost": "New form replay",
|
||||||
"newRSAKey": "New keys",
|
"newRSAKey": "New keys",
|
||||||
"newRule": "New rule",
|
"newRule": "New rule",
|
||||||
|
|
|
@ -100,6 +100,7 @@
|
||||||
"chooseLogo": "Choisir le logo",
|
"chooseLogo": "Choisir le logo",
|
||||||
"chooseSkin": "Choisir le thème",
|
"chooseSkin": "Choisir le thème",
|
||||||
"comment": "Commentaire",
|
"comment": "Commentaire",
|
||||||
|
"comments": "Commentaires",
|
||||||
"condition": "Condition",
|
"condition": "Condition",
|
||||||
"conf": "Configuration",
|
"conf": "Configuration",
|
||||||
"Configuration": "Configuration",
|
"Configuration": "Configuration",
|
||||||
|
@ -288,6 +289,8 @@
|
||||||
"mandatory": "Obligatoire",
|
"mandatory": "Obligatoire",
|
||||||
"markAsDone": "Marquer comme validée",
|
"markAsDone": "Marquer comme validée",
|
||||||
"memberOfSSOGroups": "Membre des groupes SSO",
|
"memberOfSSOGroups": "Membre des groupes SSO",
|
||||||
|
"message": "Message",
|
||||||
|
"messages": "Messages",
|
||||||
"menuCategory": "Catégorie du menu",
|
"menuCategory": "Catégorie du menu",
|
||||||
"modulesTitle": "Modules utilisés",
|
"modulesTitle": "Modules utilisés",
|
||||||
"multiAuthStack": "Pile d'authentification",
|
"multiAuthStack": "Pile d'authentification",
|
||||||
|
@ -304,6 +307,7 @@
|
||||||
"newCat": "Nouvelle catégorie",
|
"newCat": "Nouvelle catégorie",
|
||||||
"newCfgAvailable": "Une nouvelle configuration est disponible",
|
"newCfgAvailable": "Une nouvelle configuration est disponible",
|
||||||
"newEntry": "Nouvelle entrée",
|
"newEntry": "Nouvelle entrée",
|
||||||
|
"newGrantRule": "Nouvelle règle d'accès",
|
||||||
"newPost": "Nouveau rejeu de formulaire",
|
"newPost": "Nouveau rejeu de formulaire",
|
||||||
"newRSAKey": "Nouvelles clefs",
|
"newRSAKey": "Nouvelles clefs",
|
||||||
"newRule": "Nouvelle règle",
|
"newRule": "Nouvelle règle",
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user