Skip to content

Commit

Permalink
RANGER-4419 : In Tag-based policy from Ranger Admin UI, Allow Conditi…
Browse files Browse the repository at this point in the history
…ons permissions item is not showing services permissions which have enableDenyAndExceptionsInPolicies flag false.

Signed-off-by: Dineshkumar Yadav <[email protected]>
  • Loading branch information
dhavaljrajpara authored and dineshkumar-yadav committed Oct 3, 2023
1 parent ee7bf69 commit e23d09f
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ export default function PolicyPermissionItem(props) {
formValues={formValues}
dataMaskIndex={index}
serviceCompDetails={serviceCompDetails}
attrName={attrName}
/>
</div>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,22 @@ import {
findIndex,
isEmpty,
includes,
difference
difference,
map
} from "lodash";
import { RangerPolicyType } from "Utils/XAEnums";
import { getServiceDef } from "../../utils/appState";

export default function TagBasePermissionItem(props) {
const serviceDefs = getServiceDef();
const { options, inputVal, formValues, serviceCompDetails, dataMaskIndex } =
props;
const {
options,
inputVal,
formValues,
serviceCompDetails,
dataMaskIndex,
attrName
} = props;
const [showTagPermissionItem, tagPermissionItem] = useState(false);

const msgStyles = {
Expand Down Expand Up @@ -133,39 +140,47 @@ export default function TagBasePermissionItem(props) {
}));
}
} else {
let enableDenyAndExceptions = [];
let filterAccessOptions = [];
enableDenyAndExceptions = serviceCompDetails?.accessTypes?.filter(
(access) => {
if (
includes(
serviceDefs?.allServiceDefs
?.map((servicedef) => {
if (
servicedef?.options?.enableDenyAndExceptionsInPolicies ==
"false"
) {
return servicedef.name;
}
})
.filter(Boolean),
access.name.substr(0, access.name.indexOf(":"))
)
) {
return access;
if (attrName === "policyItems") {
return map(keys(tagServicePerms), (m) => ({
value: m,
label: m.toUpperCase()
}));
} else {
let enableDenyAndExceptions = [];
let filterAccessOptions = [];
enableDenyAndExceptions = serviceCompDetails?.accessTypes?.filter(
(access) => {
if (
includes(
serviceDefs?.allServiceDefs
?.map((servicedef) => {
if (
servicedef?.options?.enableDenyAndExceptionsInPolicies ==
"false"
) {
return servicedef.name;
}
})
.filter(Boolean),
access.name.substr(0, access.name.indexOf(":"))
)
) {
return access;
}
}
}
);
filterAccessOptions = groupBy(enableDenyAndExceptions, function (obj) {
let val = obj.name;
return val.substr(0, val.indexOf(":"));
});
return difference(keys(tagServicePerms), keys(filterAccessOptions))?.map(
(m) => ({
);
filterAccessOptions = groupBy(enableDenyAndExceptions, function (obj) {
let val = obj.name;
return val.substr(0, val.indexOf(":"));
});
return difference(
keys(tagServicePerms),
keys(filterAccessOptions)
)?.map((m) => ({
value: m,
label: m.toUpperCase()
})
);
}));
}
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const SecurityZoneForm = () => {
if (isEmpty(values.adminUsers) && isEmpty(values.adminUserGroups)) {
errors.adminUserGroups = {
required: true,
text: "Please provide atleast one audit user or group!"
text: "Please provide atleast one admin user or group!"
};
errors.adminUsers = {
required: true,
Expand Down

0 comments on commit e23d09f

Please sign in to comment.