mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-01-13 09:41:55 -06:00
Added group association table for SUDO command.
A section has been added to the SUDO command details page for managing the association with SUDO command groups. New test data has been added as well.
This commit is contained in:
parent
9d0dc89b03
commit
308b7b3a49
@ -107,8 +107,167 @@ function ipa_sudocmd_details_facet(spec) {
|
||||
section.create_field({'name': 'sudocmd'});
|
||||
section.create_field({'name': 'description'});
|
||||
|
||||
section = ipa_details_section({
|
||||
'name': 'groups',
|
||||
'label': 'Groups'
|
||||
});
|
||||
that.add_section(section);
|
||||
|
||||
var field = ipa_sudocmd_member_sudocmdgroup_table_widget({
|
||||
'name': 'memberof',
|
||||
'label': 'Groups',
|
||||
'other_entity': 'sudocmdgroup',
|
||||
'save_values': false
|
||||
});
|
||||
section.add_field(field);
|
||||
|
||||
that.details_facet_init();
|
||||
};
|
||||
|
||||
return that;
|
||||
}
|
||||
|
||||
function ipa_sudocmd_member_sudocmdgroup_table_widget(spec) {
|
||||
|
||||
spec = spec || {};
|
||||
|
||||
var that = ipa_association_table_widget(spec);
|
||||
|
||||
that.init = function() {
|
||||
|
||||
var column = that.create_column({
|
||||
name: 'cn',
|
||||
primary_key: true,
|
||||
width: '150px'
|
||||
});
|
||||
|
||||
column.setup = function(container, record) {
|
||||
container.empty();
|
||||
|
||||
var value = record[column.name];
|
||||
value = value ? value.toString() : '';
|
||||
|
||||
$('<a/>', {
|
||||
'href': '#'+value,
|
||||
'html': value,
|
||||
'click': function (value) {
|
||||
return function() {
|
||||
var state = IPA.tab_state(that.other_entity);
|
||||
state[that.other_entity + '-facet'] = 'details';
|
||||
state[that.other_entity + '-pkey'] = value;
|
||||
$.bbq.pushState(state);
|
||||
return false;
|
||||
}
|
||||
}(value)
|
||||
}).appendTo(container);
|
||||
};
|
||||
|
||||
that.create_column({
|
||||
name: 'description',
|
||||
label: 'Description',
|
||||
width: '150px'
|
||||
});
|
||||
|
||||
that.create_adder_column({
|
||||
name: 'cn',
|
||||
primary_key: true,
|
||||
width: '100px'
|
||||
});
|
||||
|
||||
that.create_adder_column({
|
||||
name: 'description',
|
||||
width: '100px'
|
||||
});
|
||||
|
||||
that.association_table_widget_init();
|
||||
};
|
||||
|
||||
that.get_records = function(on_success, on_error) {
|
||||
|
||||
if (!that.values.length) return;
|
||||
|
||||
var batch = ipa_batch_command({
|
||||
'name': that.entity_name+'_'+that.name+'_show',
|
||||
'on_success': on_success,
|
||||
'on_error': on_error
|
||||
});
|
||||
|
||||
for (var i=0; i<that.values.length; i++) {
|
||||
var dn = that.values[i];
|
||||
var j = dn.indexOf('=');
|
||||
var k = dn.indexOf(',');
|
||||
var value = dn.substring(j+1, k);
|
||||
|
||||
var command = ipa_command({
|
||||
'method': that.other_entity+'_show',
|
||||
'args': [value],
|
||||
'options': {
|
||||
'all': true,
|
||||
'rights': true
|
||||
}
|
||||
});
|
||||
|
||||
batch.add_command(command);
|
||||
}
|
||||
|
||||
batch.execute();
|
||||
};
|
||||
|
||||
that.add = function(values, on_success, on_error) {
|
||||
|
||||
if (!values.length) return;
|
||||
|
||||
var batch = ipa_batch_command({
|
||||
'name': that.entity_name+'_'+that.name+'_add',
|
||||
'on_success': on_success,
|
||||
'on_error': on_error
|
||||
});
|
||||
|
||||
var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
|
||||
|
||||
for (var i=0; i<values.length; i++) {
|
||||
var value = values[i];
|
||||
|
||||
var command = ipa_command({
|
||||
'method': that.other_entity+'_add_member',
|
||||
'args': [value]
|
||||
});
|
||||
|
||||
command.set_option('sudocmd', pkey);
|
||||
|
||||
batch.add_command(command);
|
||||
}
|
||||
|
||||
batch.execute();
|
||||
};
|
||||
|
||||
that.remove = function(values, on_success, on_error) {
|
||||
|
||||
if (!values.length) return;
|
||||
|
||||
var batch = ipa_batch_command({
|
||||
'name': that.entity_name+'_'+that.name+'_remove',
|
||||
'on_success': on_success,
|
||||
'on_error': on_error
|
||||
});
|
||||
|
||||
var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
|
||||
|
||||
for (var i=0; i<values.length; i++) {
|
||||
var value = values[i];
|
||||
|
||||
var command = ipa_command({
|
||||
'method': that.other_entity+'_remove_member',
|
||||
'args': [value]
|
||||
});
|
||||
|
||||
command.set_option('sudocmd', pkey);
|
||||
|
||||
batch.add_command(command);
|
||||
}
|
||||
|
||||
batch.execute();
|
||||
};
|
||||
|
||||
return that;
|
||||
}
|
@ -169,6 +169,7 @@ function ipa_sudocmdgroup_member_sudocmd_table_widget(spec) {
|
||||
};
|
||||
|
||||
that.create_column({
|
||||
name: 'description',
|
||||
label: 'Description',
|
||||
width: '150px'
|
||||
});
|
||||
|
53
install/static/test/data/sudocmd_memberof_add.json
Normal file
53
install/static/test/data/sudocmd_memberof_add.json
Normal file
@ -0,0 +1,53 @@
|
||||
{
|
||||
"error": null,
|
||||
"id": 0,
|
||||
"result": {
|
||||
"count": 2,
|
||||
"results": [
|
||||
{
|
||||
"completed": 1,
|
||||
"error": null,
|
||||
"failed": {
|
||||
"member": {
|
||||
"sudocmd": [],
|
||||
"sudocmdgroup": []
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"cn": [
|
||||
"group1"
|
||||
],
|
||||
"description": [
|
||||
"Group 1"
|
||||
],
|
||||
"dn": "cn=group1,cn=sudocmdgroups,cn=accounts,dc=ipa",
|
||||
"member_sudocmd": [
|
||||
"/usr/bin/less"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"completed": 1,
|
||||
"error": null,
|
||||
"failed": {
|
||||
"member": {
|
||||
"sudocmd": [],
|
||||
"sudocmdgroup": []
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"cn": [
|
||||
"group2"
|
||||
],
|
||||
"description": [
|
||||
"Group 2"
|
||||
],
|
||||
"dn": "cn=group2,cn=sudocmdgroups,cn=accounts,dc=ipa",
|
||||
"member_sudocmd": [
|
||||
"/usr/bin/more"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
50
install/static/test/data/sudocmd_memberof_remove.json
Normal file
50
install/static/test/data/sudocmd_memberof_remove.json
Normal file
@ -0,0 +1,50 @@
|
||||
{
|
||||
"error": null,
|
||||
"id": 0,
|
||||
"result": {
|
||||
"count": 2,
|
||||
"results": [
|
||||
{
|
||||
"completed": 1,
|
||||
"error": null,
|
||||
"failed": {
|
||||
"member": {
|
||||
"sudocmd": [],
|
||||
"sudocmdgroup": []
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"cn": [
|
||||
"group1"
|
||||
],
|
||||
"description": [
|
||||
"Group 1"
|
||||
],
|
||||
"dn": "cn=group1,cn=sudocmdgroups,cn=accounts,dc=ipa"
|
||||
}
|
||||
},
|
||||
{
|
||||
"completed": 1,
|
||||
"error": null,
|
||||
"failed": {
|
||||
"member": {
|
||||
"sudocmd": [],
|
||||
"sudocmdgroup": []
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"cn": [
|
||||
"group2"
|
||||
],
|
||||
"description": [
|
||||
"Group 2"
|
||||
],
|
||||
"dn": "cn=group2,cn=sudocmdgroups,cn=accounts,dc=ipa",
|
||||
"memberindirect_sudocmd": [
|
||||
"/usr/bin/more"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
61
install/static/test/data/sudocmd_memberof_show.json
Normal file
61
install/static/test/data/sudocmd_memberof_show.json
Normal file
@ -0,0 +1,61 @@
|
||||
{
|
||||
"error": null,
|
||||
"id": 0,
|
||||
"result": {
|
||||
"count": 2,
|
||||
"results": [
|
||||
{
|
||||
"error": null,
|
||||
"result": {
|
||||
"cn": [
|
||||
"group1"
|
||||
],
|
||||
"description": [
|
||||
"Group 1"
|
||||
],
|
||||
"dn": "cn=group1,cn=sudocmdgroups,cn=accounts,dc=ipa",
|
||||
"ipauniqueid": [
|
||||
"fc775d2e-1d56-11e0-b7cd-00163e2fe6de"
|
||||
],
|
||||
"member_sudocmd": [
|
||||
"/usr/bin/less"
|
||||
],
|
||||
"objectclass": [
|
||||
"ipaobject",
|
||||
"ipasudocmdgrp",
|
||||
"groupOfNames",
|
||||
"top"
|
||||
]
|
||||
},
|
||||
"summary": null,
|
||||
"value": "group1"
|
||||
},
|
||||
{
|
||||
"error": null,
|
||||
"result": {
|
||||
"cn": [
|
||||
"group2"
|
||||
],
|
||||
"description": [
|
||||
"Group 2"
|
||||
],
|
||||
"dn": "cn=group2,cn=sudocmdgroups,cn=accounts,dc=ipa",
|
||||
"ipauniqueid": [
|
||||
"b90c1930-1d5b-11e0-ac89-00163e2fe6de"
|
||||
],
|
||||
"member_sudocmd": [
|
||||
"/usr/bin/more"
|
||||
],
|
||||
"objectclass": [
|
||||
"ipaobject",
|
||||
"ipasudocmdgrp",
|
||||
"groupOfNames",
|
||||
"top"
|
||||
]
|
||||
},
|
||||
"summary": null,
|
||||
"value": "group2"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
@ -15,6 +15,10 @@
|
||||
"ipauniqueid": [
|
||||
"06708d0e-f454-11df-9273-00163e72f2d9"
|
||||
],
|
||||
"memberof": [
|
||||
"cn=group1,cn=sudocmdgroups,cn=accounts,dc=dev,dc=example,dc=com",
|
||||
"cn=group2,cn=sudocmdgroups,cn=accounts,dc=dev,dc=example,dc=com"
|
||||
],
|
||||
"objectclass": [
|
||||
"ipaobject",
|
||||
"ipasudocmd"
|
||||
|
Loading…
Reference in New Issue
Block a user