You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by dh...@apache.org on 2023/09/25 14:06:26 UTC
[ranger] branch master updated (1438644b7 -> f740ad332)
This is an automated email from the ASF dual-hosted git repository.
dhavalshah9131 pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/ranger.git
from 1438644b7 RANGER-4234: simplify condition/row-filter expressions that deal with delimited strings
new 622a1dacb RANGER-4383: In Audit, Plugin Status tab if the record of respective service is in second page then Service Type filter for that service would show no result
new 6b3bd1c85 RANGER-4381 : Difference in user lookup API request in permissions module page between React UI and BackBone UI
new 0f70a24f4 RANGER-4407 : Add server side validation for service audit filter
new f740ad332 RANGER-4358: Keep the usersync details popup names same as the backbone js names
The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../java/org/apache/ranger/biz/ServiceDBStore.java | 7 +-
.../react-webapp/src/components/Editable.jsx | 16 ++---
.../react-webapp/src/components/XATableLayout.jsx | 9 ++-
.../main/webapp/react-webapp/src/styles/style.css | 3 +-
.../main/webapp/react-webapp/src/utils/XAEnums.js | 13 ++++
.../main/webapp/react-webapp/src/utils/fetchAPI.js | 2 +-
.../src/views/AuditEvent/AdminLogs/UserLogs.jsx | 6 +-
.../src/views/AuditEvent/PluginStatusLogs.jsx | 9 +--
.../src/views/Encryption/KeyManager.jsx | 72 ++++++++++----------
.../src/views/PermissionsModule/EditPermission.jsx | 61 +++++++++++------
.../views/PolicyListing/AddUpdatePolicyForm.jsx | 2 +-
.../src/views/SecurityZone/SecurityZoneForm.jsx | 74 +++++++++++---------
.../src/views/ServiceManager/ServiceDefinition.jsx | 21 ++++--
.../src/views/ServiceManager/ServiceForm.jsx | 79 +++++++++++-----------
.../views/ServiceManager/ServiceViewDetails.jsx | 23 +++++--
.../UserGroupRoleListing/SyncSourceDetails.jsx | 4 +-
.../groups_details/GroupListing.jsx | 3 +-
.../role_details/RoleListing.jsx | 8 +--
.../users_details/UserFormComp.jsx | 26 +++----
.../users_details/UserListing.jsx | 3 +-
20 files changed, 248 insertions(+), 193 deletions(-)
[ranger] 04/04: RANGER-4358: Keep the usersync details popup names same as the backbone js names
Posted by dh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
dhavalshah9131 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ranger.git
commit f740ad33208618fd47f5d2b314c4978300cbd7c2
Author: princeap173 <pr...@gmail.com>
AuthorDate: Mon Sep 11 15:14:56 2023 +0530
RANGER-4358: Keep the usersync details popup names same as the backbone js names
---
.../src/main/webapp/react-webapp/src/utils/XAEnums.js | 13 +++++++++++++
.../src/views/UserGroupRoleListing/SyncSourceDetails.jsx | 4 +++-
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/security-admin/src/main/webapp/react-webapp/src/utils/XAEnums.js b/security-admin/src/main/webapp/react-webapp/src/utils/XAEnums.js
index 6e5eb0d5b..194cf3bef 100644
--- a/security-admin/src/main/webapp/react-webapp/src/utils/XAEnums.js
+++ b/security-admin/src/main/webapp/react-webapp/src/utils/XAEnums.js
@@ -808,3 +808,16 @@ export const ServiceRequestDataRangerAcl = [
];
export const ServiceRequestDataHadoopAcl = [ServiceType.Service_HDFS.label];
+
+export const UsersyncDetailsKeyDisplayMap = {
+ 'unixBackend': 'Unix',
+ 'fileName': 'File Name',
+ 'syncTime': 'Sync time',
+ 'lastModified': 'Last modified time',
+ 'minUserId': 'Minimum user id',
+ 'minGroupId': 'Minimum group id',
+ 'totalUsersSynced': 'Total number of users synced',
+ 'totalGroupsSynced': 'Total number of groups synced',
+ 'totalUsersDeleted': 'Total number of users marked for delete',
+ 'totalGroupsDeleted': 'Total number of groups marked for delete'
+}
\ No newline at end of file
diff --git a/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/SyncSourceDetails.jsx b/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/SyncSourceDetails.jsx
index 42a886ef3..105659759 100644
--- a/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/SyncSourceDetails.jsx
+++ b/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/SyncSourceDetails.jsx
@@ -19,6 +19,8 @@
import React, { useState, useCallback, useRef } from "react";
import { Table } from "react-bootstrap";
+import { UsersyncDetailsKeyDisplayMap } from "../../utils/XAEnums"
+
export function SyncSourceDetails(props) {
const { syncDetails } = props;
return Object.keys(props.syncDetails).length == 0 ? (
@@ -51,7 +53,7 @@ export function SyncSourceDetails(props) {
<tbody>
{Object.entries(props.syncDetails).map(([key, value]) => (
<tr key={key}>
- <td>{key}</td>
+ <td>{UsersyncDetailsKeyDisplayMap[key]? UsersyncDetailsKeyDisplayMap[key]: key}</td>
<td>{value}</td>
</tr>
))}
[ranger] 01/04: RANGER-4383: In Audit, Plugin Status tab if the record of respective service is in second page then Service Type filter for that service would show no result
Posted by dh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
dhavalshah9131 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ranger.git
commit 622a1dacbdd39ec08783fd3d411bedb66f1407b1
Author: Brijesh Bhalala <br...@gmail.com>
AuthorDate: Wed Sep 6 19:33:29 2023 +0530
RANGER-4383: In Audit, Plugin Status tab if the record of respective service is in second page then Service Type filter for that service would show no result
---
.../react-webapp/src/components/Editable.jsx | 16 ++---
.../react-webapp/src/components/XATableLayout.jsx | 9 ++-
.../main/webapp/react-webapp/src/utils/fetchAPI.js | 2 +-
.../src/views/AuditEvent/AdminLogs/UserLogs.jsx | 6 +-
.../src/views/AuditEvent/PluginStatusLogs.jsx | 9 +--
.../src/views/Encryption/KeyManager.jsx | 72 +++++++++++-----------
.../role_details/RoleListing.jsx | 8 +--
.../users_details/UserFormComp.jsx | 26 +++-----
8 files changed, 65 insertions(+), 83 deletions(-)
diff --git a/security-admin/src/main/webapp/react-webapp/src/components/Editable.jsx b/security-admin/src/main/webapp/react-webapp/src/components/Editable.jsx
index 4e98134ab..4d6d7d265 100644
--- a/security-admin/src/main/webapp/react-webapp/src/components/Editable.jsx
+++ b/security-admin/src/main/webapp/react-webapp/src/components/Editable.jsx
@@ -17,13 +17,7 @@
* under the License.
*/
-import React, {
- useEffect,
- useReducer,
- useRef,
- useState,
- useCallback
-} from "react";
+import React, { useEffect, useReducer, useRef, useState } from "react";
import {
OverlayTrigger,
Popover,
@@ -33,7 +27,7 @@ import {
Col,
Badge
} from "react-bootstrap";
-import { find, findIndex, isArray, isEmpty, map } from "lodash";
+import { find, findIndex, isArray, isEmpty, sortBy } from "lodash";
import { isObject } from "Utils/XAUtils";
import CreatableSelect from "react-select/creatable";
import Select from "react-select";
@@ -82,7 +76,7 @@ const CheckboxComp = (props) => {
return (
<>
- {options.map((obj, index) => (
+ {options.map((obj) => (
<Form.Group className="mb-3" controlId={obj.label} key={obj.label}>
<Form.Check
checked={isChecked(obj)}
@@ -409,7 +403,7 @@ const Editable = (props) => {
const policyConditionDisplayValue = () => {
let ipRangVal, uiHintVal;
if (selectVal) {
- return _.sortBy(Object.keys(selectVal)).map((property, index) => {
+ return sortBy(Object.keys(selectVal)).map((property, index) => {
let conditionObj = find(conditionDefVal, function (m) {
if (m.name == property) {
return m;
@@ -651,7 +645,7 @@ const Editable = (props) => {
const handleApply = (e) => {
let errors, uiHintVal;
if (selectValRef?.current) {
- _.sortBy(Object.keys(selectValRef.current)).map((property) => {
+ sortBy(Object.keys(selectValRef.current)).map((property) => {
let conditionObj = find(conditionDefVal, function (m) {
if (m.name == property) {
return m;
diff --git a/security-admin/src/main/webapp/react-webapp/src/components/XATableLayout.jsx b/security-admin/src/main/webapp/react-webapp/src/components/XATableLayout.jsx
index d275598ce..71a33f1c7 100644
--- a/security-admin/src/main/webapp/react-webapp/src/components/XATableLayout.jsx
+++ b/security-admin/src/main/webapp/react-webapp/src/components/XATableLayout.jsx
@@ -59,6 +59,7 @@ function XATableLayout({
loading,
data,
fetchData,
+ showPagination = true,
pageCount: controlledPageCount,
currentpageIndex,
currentpageSize,
@@ -85,6 +86,7 @@ function XATableLayout({
: [];
return filterColVal;
};
+
const {
getTableProps,
getTableBodyProps,
@@ -160,6 +162,7 @@ function XATableLayout({
});
}
);
+
const currentPageValRef = useRef();
const [currentPageVal, setCurrentPageVal] = useState("");
@@ -317,7 +320,7 @@ function XATableLayout({
</tbody>
) : (
<tbody {...getTableBodyProps()}>
- {rows.map((row, index) => {
+ {rows.map((row) => {
prepareRow(row);
return (
<tr
@@ -339,7 +342,7 @@ function XATableLayout({
</>
</Table>
</div>
- {totalCount > 25 && (
+ {showPagination && totalCount > 25 && (
<div className="row mt-2">
<div className="col-md-12 m-b-sm">
<div className="text-center d-flex justify-content-end align-items-center pb-2">
@@ -406,7 +409,7 @@ function XATableLayout({
currPage > pageOptions.length ||
!Number.isInteger(Number(currPage))
) {
- return (currPage = currPage);
+ return currPage;
} else {
const page = currPage ? Number(currPage) - 1 : 0;
gotoPage(page);
diff --git a/security-admin/src/main/webapp/react-webapp/src/utils/fetchAPI.js b/security-admin/src/main/webapp/react-webapp/src/utils/fetchAPI.js
index 135182b40..fbdd91737 100644
--- a/security-admin/src/main/webapp/react-webapp/src/utils/fetchAPI.js
+++ b/security-admin/src/main/webapp/react-webapp/src/utils/fetchAPI.js
@@ -89,7 +89,7 @@ async function fetchApi(axiosConfig = {}, otherConf = {}) {
window.location.replace("login.jsp?sessionTimeout=true");
}
}
- if (config.skipNavigate !== undefined && config.skipNavigate) {
+ if (config?.skipNavigate) {
throw error;
}
if (
diff --git a/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/AdminLogs/UserLogs.jsx b/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/AdminLogs/UserLogs.jsx
index a856187af..5eb26825c 100644
--- a/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/AdminLogs/UserLogs.jsx
+++ b/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/AdminLogs/UserLogs.jsx
@@ -21,7 +21,7 @@ import React from "react";
import { Table, Badge } from "react-bootstrap";
import dateFormat from "dateformat";
import { ClassTypes, UserRoles } from "../../../utils/XAEnums";
-import { isEmpty, unionBy, difference, isEqual } from "lodash";
+import { isEmpty, unionBy, difference, isEqual, without } from "lodash";
export const UserLogs = ({ data, reportdata }) => {
const { objectName, objectClassType, createDate, owner, action } = data;
@@ -48,11 +48,11 @@ export const UserLogs = ({ data, reportdata }) => {
return obj.attributeName == "Group Name";
});
- const updateGrpOld = _.without(
+ const updateGrpOld = without(
updateUserGrp.map((obj) => obj.previousValue),
""
);
- const updateGrpNew = _.without(
+ const updateGrpNew = without(
updateUserGrp.map((obj) => obj.newValue),
""
);
diff --git a/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/PluginStatusLogs.jsx b/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/PluginStatusLogs.jsx
index ea0e550a7..cf4727514 100644
--- a/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/PluginStatusLogs.jsx
+++ b/security-admin/src/main/webapp/react-webapp/src/views/AuditEvent/PluginStatusLogs.jsx
@@ -39,7 +39,7 @@ import {
} from "../../components/CommonComponents";
import StructuredFilter from "../../components/structured-filter/react-typeahead/tokenizer";
import { fetchApi } from "Utils/fetchAPI";
-import { isEmpty, isUndefined, map, sortBy, toUpper, filter } from "lodash";
+import { isUndefined, map, sortBy, toUpper, filter } from "lodash";
import { getServiceDef } from "../../utils/appState";
function Plugin_Status() {
@@ -48,7 +48,6 @@ function Plugin_Status() {
const servicesAvailable = context.servicesAvailable;
const [pluginStatusListingData, setPluginStatusLogs] = useState([]);
const [loader, setLoader] = useState(true);
- const [pageCount, setPageCount] = React.useState(0);
const [entries, setEntries] = useState([]);
const [updateTable, setUpdateTable] = useState(moment.now());
const fetchIdRef = useRef(0);
@@ -90,11 +89,9 @@ function Plugin_Status() {
if (servicesAvailable !== null) {
let logsResp = [];
let logs = [];
- let totalCount = 0;
const fetchId = ++fetchIdRef.current;
let params = { ...searchFilterParams };
if (fetchId === fetchIdRef.current) {
- params["pageSize"] = pageSize;
params["startIndex"] = pageIndex * pageSize;
try {
logsResp = await fetchApi({
@@ -102,7 +99,6 @@ function Plugin_Status() {
params: params
});
logs = logsResp.data.pluginInfoList;
- totalCount = logsResp.data.totalCount;
} catch (error) {
serverError(error);
console.error(
@@ -111,7 +107,6 @@ function Plugin_Status() {
}
setPluginStatusLogs(logs);
setEntries(logsResp.data);
- setPageCount(Math.ceil(totalCount / pageSize));
setResetpage({ page: gotoPage });
setLoader(false);
}
@@ -576,9 +571,9 @@ function Plugin_Status() {
loading={loader}
totalCount={entries && entries.totalCount}
fetchData={fetchPluginStatusInfo}
- pageCount={pageCount}
columnSort={true}
clientSideSorting={true}
+ showPagination={false}
/>
</React.Fragment>
</div>
diff --git a/security-admin/src/main/webapp/react-webapp/src/views/Encryption/KeyManager.jsx b/security-admin/src/main/webapp/react-webapp/src/views/Encryption/KeyManager.jsx
index 401c960b2..98ea88280 100644
--- a/security-admin/src/main/webapp/react-webapp/src/views/Encryption/KeyManager.jsx
+++ b/security-admin/src/main/webapp/react-webapp/src/views/Encryption/KeyManager.jsx
@@ -30,7 +30,7 @@ import { Row, Col, Button, Modal } from "react-bootstrap";
import { fetchApi } from "Utils/fetchAPI";
import dateFormat from "dateformat";
import moment from "moment-timezone";
-import { find, sortBy, isUndefined, isEmpty } from "lodash";
+import { find, sortBy, isUndefined, isEmpty, reject } from "lodash";
import StructuredFilter from "../../components/structured-filter/react-typeahead/tokenizer";
import AsyncSelect from "react-select/async";
import { isKeyAdmin, parseSearchFilter } from "../../utils/XAUtils";
@@ -140,7 +140,7 @@ function reducer(state, action) {
}
}
-const KeyManager = (props) => {
+const KeyManager = () => {
const navigate = useNavigate();
const { state } = useLocation();
const params = useParams();
@@ -505,40 +505,36 @@ const KeyManager = (props) => {
Header: "Action",
accessor: "action",
Cell: (rawValue) => {
- if (isKeyAdmin()) {
- return (
- <div className="text-center">
- <Button
- className="btn btn-outline-dark btn-sm m-r-5"
- size="sm"
- title="Edit"
- onClick={() => {
- editModal(rawValue.row.original.name);
- }}
- data-name="rolloverKey"
- data-id={rawValue.row.original.name}
- data-cy={rawValue.row.original.name}
- >
- <i className="fa-fw fa fa-edit"></i>
- </Button>
- <Button
- variant="danger"
- size="sm"
- title="Delete"
- onClick={() => {
- deleteModal(rawValue.row.original.name);
- }}
- data-name="deleteKey"
- data-id={rawValue.row.original.name}
- data-cy={rawValue.row.original.name}
- >
- <i className="fa-fw fa fa-trash"></i>
- </Button>
- </div>
- );
- } else {
- return <div className="text-center">--</div>;
- }
+ return (
+ <div className="text-center">
+ <Button
+ className="btn btn-outline-dark btn-sm m-r-5"
+ size="sm"
+ title="Edit"
+ onClick={() => {
+ editModal(rawValue.row.original.name);
+ }}
+ data-name="rolloverKey"
+ data-id={rawValue.row.original.name}
+ data-cy={rawValue.row.original.name}
+ >
+ <i className="fa-fw fa fa-edit"></i>
+ </Button>
+ <Button
+ variant="danger"
+ size="sm"
+ title="Delete"
+ onClick={() => {
+ deleteModal(rawValue.row.original.name);
+ }}
+ data-name="deleteKey"
+ data-id={rawValue.row.original.name}
+ data-cy={rawValue.row.original.name}
+ >
+ <i className="fa-fw fa fa-trash"></i>
+ </Button>
+ </div>
+ );
},
width: 80
}
@@ -622,7 +618,9 @@ const KeyManager = (props) => {
<XATableLayout
loading={loader}
data={keydata || []}
- columns={columns}
+ columns={
+ isKeyAdmin() ? columns : reject(columns, ["Header", "Action"])
+ }
fetchData={selectServices}
pageCount={pagecount}
currentPageIndex={currentPageIndex}
diff --git a/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/role_details/RoleListing.jsx b/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/role_details/RoleListing.jsx
index dbd195c1d..8caecf058 100644
--- a/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/role_details/RoleListing.jsx
+++ b/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/role_details/RoleListing.jsx
@@ -28,7 +28,7 @@ import {
useSearchParams
} from "react-router-dom";
import moment from "moment-timezone";
-import { find, isEmpty } from "lodash";
+import { find, isEmpty, map } from "lodash";
import { fetchApi } from "Utils/fetchAPI";
import { toast } from "react-toastify";
import {
@@ -267,7 +267,7 @@ function Roles() {
Header: "Users",
accessor: "users",
accessor: (raw) => {
- let usersList = _.map(raw.users, "name");
+ let usersList = map(raw.users, "name");
return !isEmpty(usersList) ? (
<MoreLess data={usersList} key={raw.id} />
) : (
@@ -279,7 +279,7 @@ function Roles() {
Header: "Groups",
accessor: "groups",
accessor: (raw) => {
- let groupsList = _.map(raw.groups, "name");
+ let groupsList = map(raw.groups, "name");
return !isEmpty(groupsList) ? (
<MoreLess data={groupsList} key={raw.id} />
) : (
@@ -291,7 +291,7 @@ function Roles() {
Header: "Roles",
accessor: "roles",
accessor: (raw) => {
- let rolesList = _.map(raw.roles, "name");
+ let rolesList = map(raw.roles, "name");
return !isEmpty(rolesList) ? (
<MoreLess data={rolesList} key={raw.id} />
diff --git a/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/users_details/UserFormComp.jsx b/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/users_details/UserFormComp.jsx
index 23bc1b169..64a536c0c 100644
--- a/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/users_details/UserFormComp.jsx
+++ b/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/users_details/UserFormComp.jsx
@@ -33,16 +33,15 @@ import {
import { toast } from "react-toastify";
import { getUserAccessRoleList, serverError } from "Utils/XAUtils";
import { getUserProfile } from "Utils/appState";
-import _, { isEmpty, isUndefined } from "lodash";
+import { has, isEmpty, isUndefined } from "lodash";
import { SyncSourceDetails } from "../SyncSourceDetails";
import { BlockUi } from "../../../components/CommonComponents";
-import { InfoIcon, commonBreadcrumb } from "../../../utils/XAUtils";
+import { InfoIcon } from "../../../utils/XAUtils";
import { RegexMessage, roleChngWarning } from "../../../utils/XAMessages";
-import { useLocation, useNavigate, useParams } from "react-router-dom";
+import { useLocation, useNavigate } from "react-router-dom";
import usePrompt from "Hooks/usePrompt";
const initialState = {
- loader: true,
blockUI: false
};
@@ -54,11 +53,6 @@ const PromtDialog = (props) => {
function reducer(state, action) {
switch (action.type) {
- case "SET_LOADER":
- return {
- ...state,
- loader: action.loader
- };
case "SET_BLOCK_UI":
return {
...state,
@@ -70,11 +64,10 @@ function reducer(state, action) {
}
function UserFormComp(props) {
- const params = useParams();
const { state } = useLocation();
const navigate = useNavigate();
const [userFormState, dispatch] = useReducer(reducer, initialState);
- const { loader, blockUI } = userFormState;
+ const { blockUI } = userFormState;
const { isEditView, userInfo } = props;
const [preventUnBlock, setPreventUnblock] = useState(false);
const toastId = React.useRef(null);
@@ -178,8 +171,8 @@ function UserFormComp(props) {
navigate("/users/usertab");
};
- const groupNameList = ({ input, ...rest }) => {
- const loadOptions = async (inputValue, callback) => {
+ const groupNameList = ({ input }) => {
+ const loadOptions = async (inputValue) => {
let params = {},
op = [];
if (inputValue) {
@@ -354,7 +347,7 @@ function UserFormComp(props) {
if (
values &&
- _.has(values, "password") &&
+ has(values, "password") &&
!RegexValidation.PASSWORD.regexExpression.test(values.password)
) {
errors.password = RegexValidation.PASSWORD.message;
@@ -362,8 +355,8 @@ function UserFormComp(props) {
if (
values &&
- _.has(values, "password") &&
- _.has(values, "passwordConfirm") &&
+ has(values, "password") &&
+ has(values, "passwordConfirm") &&
values.password !== values.passwordConfirm
) {
errors.passwordConfirm = "Password must be match with new password";
@@ -393,7 +386,6 @@ function UserFormComp(props) {
values,
invalid,
errors,
- pristine,
dirty
}) => (
<div className="wrap user-role-grp-form">
[ranger] 02/04: RANGER-4381 : Difference in user lookup API request in permissions module page between React UI and BackBone UI
Posted by dh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
dhavalshah9131 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ranger.git
commit 6b3bd1c85ccb5ed2c13e398e118c65484f92be58
Author: Brijesh Bhalala <br...@gmail.com>
AuthorDate: Fri Sep 15 11:09:43 2023 +0530
RANGER-4381 : Difference in user lookup API request in permissions module page between React UI and BackBone UI
---
.../main/webapp/react-webapp/src/styles/style.css | 3 +-
.../src/views/PermissionsModule/EditPermission.jsx | 61 +++++++++++------
.../views/PolicyListing/AddUpdatePolicyForm.jsx | 2 +-
.../src/views/SecurityZone/SecurityZoneForm.jsx | 74 +++++++++++---------
.../src/views/ServiceManager/ServiceForm.jsx | 79 +++++++++++-----------
.../groups_details/GroupListing.jsx | 3 +-
.../users_details/UserListing.jsx | 3 +-
7 files changed, 127 insertions(+), 98 deletions(-)
diff --git a/security-admin/src/main/webapp/react-webapp/src/styles/style.css b/security-admin/src/main/webapp/react-webapp/src/styles/style.css
index aaa54a380..6e8678a57 100644
--- a/security-admin/src/main/webapp/react-webapp/src/styles/style.css
+++ b/security-admin/src/main/webapp/react-webapp/src/styles/style.css
@@ -2529,7 +2529,8 @@ li.list-group-item:hover {
background-color: #e9ecef;
}
.manage-service .dropdown-toggle:focus,
-.manage-export .dropdown-toggle:focus {
+.manage-export .dropdown-toggle:focus,
+.manage-visibility .dropdown-toggle:focus {
color: #0b7fad;
background-color: #fff;
border-color: #0062cc;
diff --git a/security-admin/src/main/webapp/react-webapp/src/views/PermissionsModule/EditPermission.jsx b/security-admin/src/main/webapp/react-webapp/src/views/PermissionsModule/EditPermission.jsx
index a3e55dfbd..5e51faf27 100755
--- a/security-admin/src/main/webapp/react-webapp/src/views/PermissionsModule/EditPermission.jsx
+++ b/security-admin/src/main/webapp/react-webapp/src/views/PermissionsModule/EditPermission.jsx
@@ -32,7 +32,7 @@ import { Loader } from "Components/CommonComponents";
import { fetchApi } from "Utils/fetchAPI";
import AsyncSelect from "react-select/async";
import { toast } from "react-toastify";
-import { cloneDeep, find, findIndex, reverse } from "lodash";
+import { cloneDeep, find, findIndex, isEmpty, map, reverse } from "lodash";
import { AccessResult } from "Utils/XAEnums";
import {
CustomInfinteScroll,
@@ -88,7 +88,7 @@ function reducer(state, action) {
throw new Error();
}
}
-const EditPermission = (props) => {
+const EditPermission = () => {
let { permissionId } = useParams();
const navigate = useNavigate();
const toastId = useRef(null);
@@ -211,18 +211,27 @@ const EditPermission = (props) => {
};
const fetchGroups = async (inputValue) => {
- let params = {};
+ let params = { isVisible: 1 };
+ let groupsOp = [];
+
if (inputValue) {
params["name"] = inputValue || "";
}
- const groupResp = await fetchApi({
- url: "xusers/groups",
- params: params
+
+ try {
+ const groupResp = await fetchApi({
+ url: "xusers/groups",
+ params: params
+ });
+ groupsOp = groupResp.data?.vXGroups;
+ } catch (error) {
+ console.error(`Error occurred while fetching Groups ! ${error}`);
+ serverError(error);
+ }
+
+ return map(groupsOp, function (group) {
+ return { label: group.name, value: group.id };
});
- return groupResp.data.vXGroups.map(({ name, id }) => ({
- label: name,
- value: id
- }));
};
const filterGrpOp = ({ data }) => {
@@ -255,19 +264,27 @@ const EditPermission = (props) => {
};
const fetchUsers = async (inputValue) => {
- let params = {};
+ let params = { isVisible: 1 };
+ let usersOp = [];
+
if (inputValue) {
params["name"] = inputValue || "";
}
- const userResp = await fetchApi({
- url: "xusers/users",
- params: params
- });
- return userResp.data.vXUsers.map(({ name, id }) => ({
- label: name,
- value: id
- }));
+ try {
+ const userResp = await fetchApi({
+ url: "xusers/users",
+ params: params
+ });
+ usersOp = userResp.data?.vXUsers;
+ } catch (error) {
+ console.error(`Error occurred while fetching Users ! ${error}`);
+ serverError(error);
+ }
+
+ return map(usersOp, function (user) {
+ return { label: user.name, value: user.id };
+ });
};
const filterUsrOp = ({ data }) => {
@@ -375,7 +392,7 @@ const EditPermission = (props) => {
<Field
className="form-control"
name="selectGroups"
- render={({ input, meta }) => (
+ render={({ input }) => (
<div>
{" "}
<AsyncSelect
@@ -469,7 +486,7 @@ const EditPermission = (props) => {
</td>
</tr>
<tr>
- {!_.isEmpty(selectedGrp) ? (
+ {!isEmpty(selectedGrp) ? (
<td>
{grploading ? (
<div className="permission-infinite-scroll text-center">
@@ -495,7 +512,7 @@ const EditPermission = (props) => {
</td>
)}
- {!_.isEmpty(selectedUsr) ? (
+ {!isEmpty(selectedUsr) ? (
<td>
{usrloading ? (
<div className="permission-infinite-scroll text-center">
diff --git a/security-admin/src/main/webapp/react-webapp/src/views/PolicyListing/AddUpdatePolicyForm.jsx b/security-admin/src/main/webapp/react-webapp/src/views/PolicyListing/AddUpdatePolicyForm.jsx
index 688831ea5..60cc1f268 100644
--- a/security-admin/src/main/webapp/react-webapp/src/views/PolicyListing/AddUpdatePolicyForm.jsx
+++ b/security-admin/src/main/webapp/react-webapp/src/views/PolicyListing/AddUpdatePolicyForm.jsx
@@ -198,7 +198,7 @@ export default function AddUpdatePolicyForm(props) {
};
const fetchRolesData = async (inputValue) => {
- let params = { roleNamePartial: inputValue || "", isVisible: 1 };
+ let params = { roleNamePartial: inputValue || "" };
let op = [];
const roleResp = await fetchApi({
diff --git a/security-admin/src/main/webapp/react-webapp/src/views/SecurityZone/SecurityZoneForm.jsx b/security-admin/src/main/webapp/react-webapp/src/views/SecurityZone/SecurityZoneForm.jsx
index c506ee0f8..97e6d3b62 100644
--- a/security-admin/src/main/webapp/react-webapp/src/views/SecurityZone/SecurityZoneForm.jsx
+++ b/security-admin/src/main/webapp/react-webapp/src/views/SecurityZone/SecurityZoneForm.jsx
@@ -30,9 +30,9 @@ import {
isEmpty,
pickBy,
find,
- has,
maxBy,
- sortBy
+ sortBy,
+ map
} from "lodash";
import { Table } from "react-bootstrap";
import { FieldArray } from "react-final-form-arrays";
@@ -60,7 +60,7 @@ const PromtDialog = (props) => {
return null;
};
-const SecurityZoneForm = (props) => {
+const SecurityZoneForm = () => {
const navigate = useNavigate();
const params = useParams();
const toastId = useRef(null);
@@ -179,7 +179,7 @@ const SecurityZoneForm = (props) => {
let resourceServices = [];
- for (var key of Object.keys(servicesByType)) {
+ for (let key of Object.keys(servicesByType)) {
resourceServices.push({
label: <span className="font-weight-bold text-body h6">{key}</span>,
options: servicesByType[key].map((name) => {
@@ -289,14 +289,14 @@ const SecurityZoneForm = (props) => {
zoneData.description = values.description || "";
zoneData.adminUsers = [];
if (values.adminUsers) {
- for (var key of Object.keys(values.adminUsers)) {
+ for (let key of Object.keys(values.adminUsers)) {
zoneData.adminUsers.push(values.adminUsers[key].value);
}
}
zoneData.adminUserGroups = [];
if (values.adminUserGroups) {
- for (var key of Object.keys(values.adminUserGroups)) {
+ for (let key of Object.keys(values.adminUserGroups)) {
zoneData.adminUserGroups.push(values.adminUserGroups[key].label || "");
}
}
@@ -304,14 +304,14 @@ const SecurityZoneForm = (props) => {
zoneData.auditUsers = [];
if (values.auditUsers) {
- for (var key of Object.keys(values.auditUsers)) {
+ for (let key of Object.keys(values.auditUsers)) {
zoneData.auditUsers.push(values.auditUsers[key].label || "");
}
}
zoneData.auditUserGroups = [];
if (values.auditUserGroups) {
- for (var key of Object.keys(values.auditUserGroups)) {
+ for (let key of Object.keys(values.auditUserGroups)) {
zoneData.auditUserGroups.push(values.auditUserGroups[key].label || "");
}
}
@@ -319,14 +319,14 @@ const SecurityZoneForm = (props) => {
zoneData.tagServices = [];
if (values.tagServices) {
- for (var key of Object.keys(values.tagServices)) {
+ for (let key of Object.keys(values.tagServices)) {
zoneData.tagServices.push(values.tagServices[key].label || "");
}
}
zoneData.services = {};
- for (key of Object.keys(values.tableList)) {
+ for (let key of Object.keys(values.tableList)) {
let serviceName = values.tableList[key].serviceName;
let resourcesName = values.tableList[key].resources;
zoneData.services[serviceName] = {};
@@ -373,7 +373,7 @@ const SecurityZoneForm = (props) => {
setBlockUI(false);
toast.dismiss(toastId.current);
toast.current = toast.success(
- `Success! Service zone ${apiSuccess} successfully`
+ `Success! Security zone ${apiSuccess} successfully`
);
navigate(`/zones/zone/${zoneResp.data.id}`);
} catch (error) {
@@ -484,41 +484,51 @@ const SecurityZoneForm = (props) => {
};
const fetchUsers = async (inputValue) => {
- let params = {},
- op = [];
+ let params = { isVisible: 1 };
+ let usersOp = [];
+
if (inputValue) {
params["name"] = inputValue || "";
}
- const userResp = await fetchApi({
- url: "xusers/users",
- params: params
- });
- if (userResp.data && userResp.data.vXUsers) {
- op = userResp.data.vXUsers.map((obj) => {
- return {
- label: obj.name,
- value: obj.name
- };
+ try {
+ const userResp = await fetchApi({
+ url: "xusers/lookup/users",
+ params: params
});
+ usersOp = userResp.data?.vXStrings;
+ } catch (error) {
+ console.error(`Error occurred while fetching Users ! ${error}`);
+ serverError(error);
}
- return op;
+ return map(usersOp, function (user) {
+ return { value: user.value, label: user.value };
+ });
};
const fetchGroups = async (inputValue) => {
- let params = {};
+ let params = { isVisible: 1 };
+ let groupsOp = [];
+
if (inputValue) {
params["name"] = inputValue || "";
}
- const groupResp = await fetchApi({
- url: "xusers/groups",
- params: params
+
+ try {
+ const groupResp = await fetchApi({
+ url: "xusers/lookup/groups",
+ params: params
+ });
+ groupsOp = groupResp.data?.vXStrings;
+ } catch (error) {
+ console.error(`Error occurred while fetching Groups ! ${error}`);
+ serverError(error);
+ }
+
+ return map(groupsOp, function (group) {
+ return { label: group.value, value: group.value };
});
- return groupResp.data.vXGroups.map(({ name }) => ({
- label: name,
- value: name
- }));
};
const fetchTagServices = async (inputValue) => {
diff --git a/security-admin/src/main/webapp/react-webapp/src/views/ServiceManager/ServiceForm.jsx b/security-admin/src/main/webapp/react-webapp/src/views/ServiceManager/ServiceForm.jsx
index efddf8080..2df0c4d63 100644
--- a/security-admin/src/main/webapp/react-webapp/src/views/ServiceManager/ServiceForm.jsx
+++ b/security-admin/src/main/webapp/react-webapp/src/views/ServiceManager/ServiceForm.jsx
@@ -79,9 +79,6 @@ class ServiceForm extends Component {
service: {},
tagService: [],
editInitialValues: {},
- usersDataRef: null,
- groupsDataRef: null,
- rolesDataRef: null,
showDelete: false,
loader: true,
blockUI: false,
@@ -702,7 +699,7 @@ class ServiceForm extends Component {
</Field>
);
break;
- case "enum":
+ case "enum": {
const paramEnum = serviceDef.enums.find(
(e) => e.name == configParam.subType
);
@@ -760,6 +757,7 @@ class ServiceForm extends Component {
</Field>
);
break;
+ }
case "bool":
formField.push(
<Field
@@ -931,52 +929,58 @@ class ServiceForm extends Component {
fetchUsers = async (inputValue) => {
let params = { name: inputValue || "", isVisible: 1 };
let op = [];
- const userResp = await fetchApi({
- url: "xusers/lookup/users",
- params: params
- });
- op = userResp?.data?.vXStrings;
- return op?.map((obj) => ({
- label: obj.value,
- value: obj.value
- }));
+ try {
+ const userResp = await fetchApi({
+ url: "xusers/lookup/users",
+ params: params
+ });
+ op = userResp.data?.vXStrings;
+ } catch (error) {
+ console.error(`Error occurred while fetching Users ! ${error}`);
+ }
+
+ return map(op, function (obj) {
+ return { value: obj.value, label: obj.value };
+ });
};
fetchGroups = async (inputValue) => {
let params = { name: inputValue || "", isVisible: 1 };
let op = [];
- const userResp = await fetchApi({
- url: "xusers/lookup/groups",
- params: params
- });
- op = userResp?.data?.vXStrings;
- if (!inputValue) {
- this.state.groupsDataRef = op;
+
+ try {
+ const groupResp = await fetchApi({
+ url: "xusers/lookup/groups",
+ params: params
+ });
+ op = groupResp.data?.vXStrings;
+ } catch (error) {
+ console.error(`Error occurred while fetching Groups ! ${error}`);
}
- return op?.map((obj) => ({
- label: obj.value,
- value: obj.value
- }));
+ return map(op, function (obj) {
+ return { label: obj.value, value: obj.value };
+ });
};
fetchRoles = async (inputValue) => {
- let params = { roleNamePartial: inputValue || "", isVisible: 1 };
+ let params = { roleNamePartial: inputValue || "" };
let op = [];
- const roleResp = await fetchApi({
- url: "roles/roles",
- params: params
- });
- op = roleResp.data.roles;
- if (!inputValue) {
- this.state.rolesDataRef = op;
+
+ try {
+ const roleResp = await fetchApi({
+ url: "roles/roles",
+ params: params
+ });
+ op = roleResp.data?.roles;
+ } catch (error) {
+ console.error(`Error occurred while fetching Roles ! ${error}`);
}
- return op.map((obj) => ({
- label: obj.name,
- value: obj.name
- }));
+ return map(op, function (obj) {
+ return { label: obj.name, value: obj.name };
+ });
};
ServiceDefnBreadcrumb = () => {
let serviceDetails = {};
@@ -1034,13 +1038,12 @@ class ServiceForm extends Component {
}
render={({
handleSubmit,
- form,
submitting,
values,
invalid,
errors,
form: {
- mutators: { push: addItem, pop: removeItem }
+ mutators: { push: addItem }
}
}) => (
<form
diff --git a/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/groups_details/GroupListing.jsx b/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/groups_details/GroupListing.jsx
index 2ba0ca068..332a3940d 100644
--- a/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/groups_details/GroupListing.jsx
+++ b/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/groups_details/GroupListing.jsx
@@ -578,8 +578,7 @@ function Groups() {
<DropdownButton
title="Set Visibility"
size="sm"
- style={{ display: "inline-block" }}
- className="ml-2"
+ className="ml-2 d-inline-block manage-visibility"
onSelect={handleSetVisibility}
data-id="hideShowVisibility"
data-cy="hideShowVisibility"
diff --git a/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/users_details/UserListing.jsx b/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/users_details/UserListing.jsx
index 1890168e5..dee4b196d 100644
--- a/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/users_details/UserListing.jsx
+++ b/security-admin/src/main/webapp/react-webapp/src/views/UserGroupRoleListing/users_details/UserListing.jsx
@@ -644,8 +644,7 @@ function Users() {
<DropdownButton
title="Set Visibility"
size="sm"
- style={{ display: "inline-block" }}
- className="ml-1 btn-sm"
+ className="ml-1 d-inline-block manage-visibility"
onSelect={handleSetVisibility}
data-id="hideShowVisibility"
data-cy="hideShowVisibility"
[ranger] 03/04: RANGER-4407 : Add server side validation for service audit filter
Posted by dh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
dhavalshah9131 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ranger.git
commit 0f70a24f45b394043239d1898d7276b67400bfd2
Author: Dineshkumar Yadav <di...@outlook.com>
AuthorDate: Wed Sep 13 21:18:45 2023 +0530
RANGER-4407 : Add server side validation for service audit filter
---
.../java/org/apache/ranger/biz/ServiceDBStore.java | 7 +++++--
.../src/views/ServiceManager/ServiceDefinition.jsx | 21 ++++++++++++++++----
.../views/ServiceManager/ServiceViewDetails.jsx | 23 +++++++++++++++++-----
3 files changed, 40 insertions(+), 11 deletions(-)
diff --git a/security-admin/src/main/java/org/apache/ranger/biz/ServiceDBStore.java b/security-admin/src/main/java/org/apache/ranger/biz/ServiceDBStore.java
index 84b096e9b..cfb7a6f23 100644
--- a/security-admin/src/main/java/org/apache/ranger/biz/ServiceDBStore.java
+++ b/security-admin/src/main/java/org/apache/ranger/biz/ServiceDBStore.java
@@ -3608,10 +3608,13 @@ public class ServiceDBStore extends AbstractServiceStore {
MessageEnums.INVALID_INPUT_DATA);
}
- if (StringUtils.equals(svcConfDef.getName(), RANGER_PLUGIN_AUDIT_FILTERS) && !configs.containsKey(RANGER_PLUGIN_AUDIT_FILTERS)) {
- if (svcConfDef.getDefaultvalue() != null) {
+ if (StringUtils.equals(svcConfDef.getName(), RANGER_PLUGIN_AUDIT_FILTERS)) {
+ if (svcConfDef.getDefaultvalue() != null && !configs.containsKey(RANGER_PLUGIN_AUDIT_FILTERS)) {
configs.put(RANGER_PLUGIN_AUDIT_FILTERS, svcConfDef.getDefaultvalue());
}
+ if (!stringUtil.isEmpty(configs.get(RANGER_PLUGIN_AUDIT_FILTERS)) && JsonUtils.jsonToAuditFilterList(configs.get(RANGER_PLUGIN_AUDIT_FILTERS)) == null) {
+ throw restErrorUtil.createRESTException("Invalid value for " + svcConfDef.getName());
+ }
}
}
Map<String, String> validConfigs = new HashMap<String, String>();
diff --git a/security-admin/src/main/webapp/react-webapp/src/views/ServiceManager/ServiceDefinition.jsx b/security-admin/src/main/webapp/react-webapp/src/views/ServiceManager/ServiceDefinition.jsx
index 696c25c8c..bedce6f4b 100644
--- a/security-admin/src/main/webapp/react-webapp/src/views/ServiceManager/ServiceDefinition.jsx
+++ b/security-admin/src/main/webapp/react-webapp/src/views/ServiceManager/ServiceDefinition.jsx
@@ -19,7 +19,7 @@
import React, { Component } from "react";
import { Link } from "react-router-dom";
-import { Badge, Button, Col, Modal, Row, Table } from "react-bootstrap";
+import { Alert, Badge, Button, Col, Modal, Row, Table } from "react-bootstrap";
import { difference, isEmpty, keys, map, omit, pick } from "lodash";
import { RangerPolicyType } from "Utils/XAEnums";
import ExportPolicy from "./ExportPolicy";
@@ -193,9 +193,22 @@ class ServiceDefinition extends Component {
return tableRow;
}
- auditFilters = JSON.parse(
- auditFilters["ranger.plugin.audit.filters"].replace(/'/g, '"')
- );
+ try {
+ auditFilters = JSON.parse(
+ auditFilters["ranger.plugin.audit.filters"].replace(/'/g, '"')
+ );
+ } catch (error) {
+ tableRow.push(
+ <tr key="error-service-audit-filter">
+ <td className="text-center" colSpan="8">
+ <Alert variant="danger">
+ Error occured while parsing service audit filter!
+ </Alert>
+ </td>
+ </tr>
+ );
+ return tableRow;
+ }
auditFilters.map((a, index) =>
tableRow.push(
diff --git a/security-admin/src/main/webapp/react-webapp/src/views/ServiceManager/ServiceViewDetails.jsx b/security-admin/src/main/webapp/react-webapp/src/views/ServiceManager/ServiceViewDetails.jsx
index 52279345f..8016d4489 100644
--- a/security-admin/src/main/webapp/react-webapp/src/views/ServiceManager/ServiceViewDetails.jsx
+++ b/security-admin/src/main/webapp/react-webapp/src/views/ServiceManager/ServiceViewDetails.jsx
@@ -18,8 +18,8 @@
*/
import React from "react";
-import { Row, Col, Table, Badge } from "react-bootstrap";
-import { difference, isEmpty, keys, map, omit, pick, upperCase } from "lodash";
+import { Alert, Row, Col, Table, Badge } from "react-bootstrap";
+import { difference, isEmpty, keys, map, omit, pick } from "lodash";
export const ServiceViewDetails = (props) => {
let { serviceData, serviceDefData } = props;
@@ -135,9 +135,22 @@ export const ServiceViewDetails = (props) => {
return tableRow;
}
- auditFilters = JSON.parse(
- auditFilters["ranger.plugin.audit.filters"].replace(/'/g, '"')
- );
+ try {
+ auditFilters = JSON.parse(
+ auditFilters["ranger.plugin.audit.filters"].replace(/'/g, '"')
+ );
+ } catch (error) {
+ tableRow.push(
+ <tr key="error-service-audit-filter">
+ <td className="text-center" colSpan="8">
+ <Alert variant="danger">
+ Error occured while parsing service audit filter!
+ </Alert>
+ </td>
+ </tr>
+ );
+ return tableRow;
+ }
auditFilters?.map((a, index) =>
tableRow.push(