Ticket https://fedorahosted.org/freeipa/ticket/2509 bans using non existent options. If such option is supplied command ends with error. It uncovered several cases in Web UI. This patch is fixing these cases.

Automember, Self-service and Delegation don't support 'pkey-only', 'size-limit' and 'rights' option. Pagination and rights check were disabled for them.

Automount map adder dialog was sending options for indirect map even if chosen type was direct (when those for indirect was filled earlier), also it was sending non-existant 'method' option.

https://fedorahosted.org/freeipa/ticket/2760

Note for reviewing: #2509 is partially done in Petr Viktorin's patch #35. At this time it has a small issue regarding automountmap_add_indirect command.

--
Petr Vobornik
From aaa2066e0885b6c856edbf6ee65c6e9ebeeece2d Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Fri, 25 May 2012 08:57:47 +0200
Subject: [PATCH] Removal of illegal options in JSON-RPC calls

Ticket https://fedorahosted.org/freeipa/ticket/2509 bans using non existent options. If such option is supplied command ends with error. It uncovered several cases in Web UI. This patch is fixing these cases.

Automember, Self-service and Delegation don't support 'pkey-only', 'size-limit' and 'rights' option. Pagination and rights check were disabled for them.

Automount map adder dialog was sending options for indirect map even if chosen type was direct (when those for indirect was filled earlier), also it was sending non-existant 'method' option.

https://fedorahosted.org/freeipa/ticket/2760
---
 install/ui/aci.js        |    8 ++++++--
 install/ui/automember.js |    4 ++++
 install/ui/automount.js  |    8 ++++++++
 install/ui/details.js    |   15 ++++++++++-----
 4 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/install/ui/aci.js b/install/ui/aci.js
index 27d9589aae551f76957066e22e79e2ac475ae488..953116c3f1e6f8450c0f8b308f1f2851b704e203 100644
--- a/install/ui/aci.js
+++ b/install/ui/aci.js
@@ -343,9 +343,11 @@ IPA.aci.selfservice_entity = function(spec) {
         that.entity_init();
 
         that.builder.search_facet({
-            columns: [ 'aciname' ]
+            columns: [ 'aciname' ],
+            pagination: false
         }).
         details_facet({
+            check_rights: false,
             sections: [
                 {
                     name: 'general',
@@ -386,9 +388,11 @@ IPA.aci.delegation_entity = function(spec) {
         that.entity_init();
 
         that.builder.search_facet({
-            columns: [ 'aciname' ]
+            columns: [ 'aciname' ],
+            pagination: false
         }).
         details_facet({
+            check_rights: false,
             sections: [
                 {
                     name: 'general',
diff --git a/install/ui/automember.js b/install/ui/automember.js
index df285973d0e51f5610406e6866eb76ec1f8ae088..6f8eba956b6631011c3bf0bde63615e2e8a6a046 100644
--- a/install/ui/automember.js
+++ b/install/ui/automember.js
@@ -58,6 +58,7 @@ IPA.automember.entity = function(spec) {
             group_type: 'group',
             label: IPA.messages.objects.automember.usergrouprules,
             details_facet: 'usergrouprule',
+            pagination: false,
             columns: [
                 'cn',
                 'description'
@@ -69,6 +70,7 @@ IPA.automember.entity = function(spec) {
             group_type: 'hostgroup',
             label: IPA.messages.objects.automember.hostgrouprules,
             details_facet: 'hostgrouprule',
+            pagination: false,
             columns: [
                 'cn',
                 'description'
@@ -80,6 +82,7 @@ IPA.automember.entity = function(spec) {
             group_type: 'group',
             label: IPA.messages.objects.automember.usergrouprule,
             disable_facet_tabs: true,
+            check_rights: false,
             redirect_info: { tab: 'amgroup' }
         }).
         details_facet({
@@ -88,6 +91,7 @@ IPA.automember.entity = function(spec) {
             group_type: 'hostgroup',
             label: IPA.messages.objects.automember.hostgrouprule,
             disable_facet_tabs: true,
+            check_rights: false,
             redirect_info: { tab: 'amhostgroup' }
         }).
         adder_dialog({
diff --git a/install/ui/automount.js b/install/ui/automount.js
index 5a4d5978f6e5215a3d9d7e25ab983f4c4bc30f36..3a4491d8b3325324ff8cc53b0ad606fb37e636d8 100644
--- a/install/ui/automount.js
+++ b/install/ui/automount.js
@@ -112,6 +112,7 @@ IPA.automount.map_entity = function(spec) {
                         {
                             type: 'radio',
                             name: 'method',
+                            enabled: false, //don't use value in add command
                             label: IPA.messages.objects.automountmap.map_type,
                             options: [
                                 {
@@ -285,11 +286,15 @@ IPA.automountmap_adder_dialog = function(spec) {
         var method_widget = that.widgets.get_widget('general.method');
         var indirect_section = that.widgets.get_widget('indirect');
         var key_field = that.fields.get_field('key');
+        var parentmap_field = that.fields.get_field('parentmap');
 
         var direct_input = $('input[value="add"]', method_widget.container);
         direct_input.change(function() {
             that.method = 'add';
 
+            key_field.set_enabled(false);
+            parentmap_field.set_enabled(false);
+
             key_field.set_required(false);
             indirect_section.set_visible(false);
         });
@@ -298,6 +303,9 @@ IPA.automountmap_adder_dialog = function(spec) {
         indirect_input.change(function() {
             that.method = 'add_indirect';
 
+            key_field.set_enabled(true);
+            parentmap_field.set_enabled(true);
+
             key_field.set_required(true);
             indirect_section.set_visible(true);
         });
diff --git a/install/ui/details.js b/install/ui/details.js
index f1f13f0b46b8a5276ebafde41853c94315687b09..373b3f33bf7b74a1d5f2cefc13c7b37a0b2a5c3b 100644
--- a/install/ui/details.js
+++ b/install/ui/details.js
@@ -288,6 +288,7 @@ IPA.details_facet = function(spec, no_init) {
     that.entity = IPA.get_entity(spec.entity);
     that.update_command_name = spec.update_command_name || 'mod';
     that.command_mode = spec.command_mode || 'save'; // [save, info]
+    that.check_rights = spec.check_rights !== undefined ? spec.check_rights : true;
 
     that.label = spec.label || IPA.messages && IPA.messages.facets && IPA.messages.facets.details;
     that.facet_group = spec.facet_group || 'settings';
@@ -553,14 +554,15 @@ IPA.details_facet = function(spec, no_init) {
     that.create_fields_update_command = function(update_info) {
 
         var args = that.get_primary_key();
+
+        var options = { all: true };
+        if (that.check_rights) options.rights = true;
+
         var command = IPA.command({
             entity: that.entity.name,
             method: that.update_command_name,
             args: args,
-            options: {
-                all: true,
-                rights: true
-            }
+            options: options
         });
 
         //set command options
@@ -645,11 +647,14 @@ IPA.details_facet = function(spec, no_init) {
 
     that.create_refresh_command = function() {
 
+        var options = { all: true };
+        if (that.check_rights) options.rights = true;
+
         var command = IPA.command({
             name: that.get_refresh_command_name(),
             entity: that.entity.name,
             method: 'show',
-            options: { all: true, rights: true }
+            options: options
         });
 
         if (that.pkey) {
-- 
1.7.7.6

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to