Repository: incubator-ranger Updated Branches: refs/heads/master aa0159f41 -> 17f40be4d
RANGER-1069 : If a user permissions are removed from a policy through revoke operation then also users is shown Signed-off-by: Velmurugan Periasamy <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/incubator-ranger/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ranger/commit/17f40be4 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/17f40be4 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/17f40be4 Branch: refs/heads/master Commit: 17f40be4d4a8203ed32cfa61a247550b56aec14a Parents: aa0159f Author: Mehul Parikh <[email protected]> Authored: Tue Jun 28 13:50:59 2016 +0530 Committer: Velmurugan Periasamy <[email protected]> Committed: Wed Jun 29 10:30:30 2016 -0700 ---------------------------------------------------------------------- .../src/main/webapp/scripts/utils/XAUtils.js | 25 +++++++++++++++++--- .../scripts/views/policies/RangerPolicyForm.js | 16 ++++++------- .../views/policies/RangerPolicyTableLayout.js | 4 ++-- .../templates/policies/PermissionList.html | 13 +--------- .../policies/RangerPolicyForm_tmpl.html | 4 ++-- 5 files changed, 35 insertions(+), 27 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/17f40be4/security-admin/src/main/webapp/scripts/utils/XAUtils.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/utils/XAUtils.js b/security-admin/src/main/webapp/scripts/utils/XAUtils.js index 0b7fb04..7c4e445 100644 --- a/security-admin/src/main/webapp/scripts/utils/XAUtils.js +++ b/security-admin/src/main/webapp/scripts/utils/XAUtils.js @@ -465,10 +465,19 @@ define(function(require) { } else return '--'; }; - XAUtils.showGroupsOrUsersForPolicy = function(rawValue, model, showGroups) { + XAUtils.showGroupsOrUsersForPolicy = function(rawValue, model, showGroups, rangerServiceDefModel) { var showMoreLess = false, groupArr = [], items = []; var itemList = ['policyItems','allowExceptions','denyPolicyItems','denyExceptions','dataMaskPolicyItems','rowFilterPolicyItems'] - var type = _.isUndefined(showGroups) ? 'groups' : 'users'; + if(!_.isUndefined(rangerServiceDefModel)){ + if(!this.showAllPolicyItems(rangerServiceDefModel, model)){ + itemList = _.difference(itemList, ["allowExceptions", "denyPolicyItems", "denyExceptions"]); + } + } + itemList = this.isAccessPolicy(model.get('policyType')) ? _.difference(itemList, ["dataMaskPolicyItems", "rowFilterPolicyItems"]) + : this.isMaskingPolicy(model.get('policyType')) ? _.difference(itemList, ["rowFilterPolicyItems"]) + : this.isRowFilterPolicy(model.get('policyType')) ? _.difference(itemList, ["dataMaskPolicyItems"]) : itemList; + + var type = _.isUndefined(showGroups) || showGroups ? 'groups' : 'users'; _.each(itemList, function(item){ if(!_.isUndefined(model.get(item)) && !_.isEmpty(model.get(item))) { items =_.union(items, model.get(item)) @@ -1212,6 +1221,16 @@ define(function(require) { return (!_.isUndefined(rowFilterDef) && !_.isUndefined(rowFilterDef.resources) && rowFilterDef.resources.length > 0) ? true : false; }; - + XAUtils.showAllPolicyItems = function(rangerServiceDefModel, model){ + var enableDenyAndExceptionsInPolicies = false,serviceDefOptions = rangerServiceDefModel.get('options'); + if((!_.isUndefined(serviceDefOptions) && !_.isUndefined(serviceDefOptions.enableDenyAndExceptionsInPolicies))){ + enableDenyAndExceptionsInPolicies = this.isAccessPolicy(model.get('policyType')) && $.parseJSON(serviceDefOptions.enableDenyAndExceptionsInPolicies); + } else { + if(rangerServiceDefModel.get('name') == XAEnums.ServiceType.SERVICE_TAG.label){ + enableDenyAndExceptionsInPolicies = true; + } + } + return enableDenyAndExceptionsInPolicies; + }; return XAUtils; }); http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/17f40be4/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js b/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js index d910187..4f5b26f 100644 --- a/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js +++ b/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyForm.js @@ -163,7 +163,12 @@ define(function(require){ var wrap = $(this).next(); // If next element is a wrap and hasn't .non-collapsible class if (wrap.hasClass('wrap') && ! wrap.hasClass('non-collapsible')){ - $(this).append('<a href="#" class="wrap-expand pull-right">show <i class="icon-caret-down"></i></a>').append('<a href="#" class="wrap-collapse pull-right" style="display: none">hide <i class="icon-caret-up"></i></a>'); + $(this).append('<a href="#" class="wrap-expand pull-right" >show <i class="icon-caret-down"></i></a>') + .append('<a href="#" class="wrap-collapse pull-right" style="display: none">hide <i class="icon-caret-up"></i></a>'); + if( i === 0 ) { + $(this).find('.wrap-expand').hide(); + $(this).find('.wrap-collapse').show(); + } } }); // Collapse wrap @@ -249,13 +254,8 @@ define(function(require){ serviceDefOptions = this.rangerServiceDefModel.get('options'), enableDenyAndExceptionsInPolicies = false; //By default hide the PolicyItems for all component except tag component - if((!_.isUndefined(serviceDefOptions) && !_.isUndefined(serviceDefOptions.enableDenyAndExceptionsInPolicies))){ - enableDenyAndExceptionsInPolicies = XAUtil.isAccessPolicy(this.model.get('policyType')) && $.parseJSON(serviceDefOptions.enableDenyAndExceptionsInPolicies); - } else { - if(this.rangerServiceDefModel.get('name') == XAEnums.ServiceType.SERVICE_TAG.label){ - enableDenyAndExceptionsInPolicies = true; - } - } + //show all policyItems if enableDenyAndExceptionsInPolicies is set to true + enableDenyAndExceptionsInPolicies = XAUtil.showAllPolicyItems(this.rangerServiceDefModel, this.model); if( !enableDenyAndExceptionsInPolicies ){ this.$el.find(this.ui.allowExcludePerm).hide(); this.$el.find(this.ui.denyConditionItems).remove(); http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/17f40be4/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyTableLayout.js ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyTableLayout.js b/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyTableLayout.js index cd4d99e..8306a47 100644 --- a/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyTableLayout.js +++ b/security-admin/src/main/webapp/scripts/views/policies/RangerPolicyTableLayout.js @@ -210,7 +210,7 @@ define(function(require){ formatter: _.extend({}, Backgrid.CellFormatter.prototype, { fromRaw: function (rawValue, model) { if(!_.isUndefined(rawValue)){ - return XAUtil.showGroupsOrUsersForPolicy(rawValue, model); + return XAUtil.showGroupsOrUsersForPolicy(rawValue, model, true, that.rangerServiceDefModel); } return '--'; } @@ -225,7 +225,7 @@ define(function(require){ label : localization.tt("lbl.users"), formatter: _.extend({}, Backgrid.CellFormatter.prototype, { fromRaw: function (rawValue, model) { - return XAUtil.showGroupsOrUsersForPolicy(model.get('policyItems'), model, false); + return XAUtil.showGroupsOrUsersForPolicy(model.get('policyItems'), model, false, that.rangerServiceDefModel); } }), editable : false, http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/17f40be4/security-admin/src/main/webapp/templates/policies/PermissionList.html ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/templates/policies/PermissionList.html b/security-admin/src/main/webapp/templates/policies/PermissionList.html index 9216376..9972d48 100644 --- a/security-admin/src/main/webapp/templates/policies/PermissionList.html +++ b/security-admin/src/main/webapp/templates/policies/PermissionList.html @@ -15,14 +15,6 @@ limitations under the License. --}} -<!-- - -<h3 class="wrap-header bold reportSearchHeader" > {{headerTitle}} - <span class="label label-yellow pull-right" ></span> -</h3> -<div class="wrap well position-relative"> ---> - <div class="control-group"> <!--label class="control-label">{{headerTitle}}</label--> <div class="controls"> @@ -48,7 +40,4 @@ <i class="icon-plus"></i> </button> </div> -</div> -<!-- -</div> ---> +</div> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/17f40be4/security-admin/src/main/webapp/templates/policies/RangerPolicyForm_tmpl.html ---------------------------------------------------------------------- diff --git a/security-admin/src/main/webapp/templates/policies/RangerPolicyForm_tmpl.html b/security-admin/src/main/webapp/templates/policies/RangerPolicyForm_tmpl.html index 71aad5f..865ea72 100644 --- a/security-admin/src/main/webapp/templates/policies/RangerPolicyForm_tmpl.html +++ b/security-admin/src/main/webapp/templates/policies/RangerPolicyForm_tmpl.html @@ -36,9 +36,9 @@ language governing permissions and limitations under the License. --}} {{conditionType}} Conditions : <span class="label label-yellow pull-right"></span> </p> - <div class=" wrap position-relative"> + <div class="wrap position-relative"> - <div class="" data-customfields="groupPerms"> + <div data-customfields="groupPerms"> <div class="control-group"> <label class="control-label">{{tt 'lbl.permissions'}}</label> <div class="controls">
