Skip to content

Commit

Permalink
RANGER-4374: Getting page not found when wrong password is send in 'O…
Browse files Browse the repository at this point in the history
…ld Password'

Signed-off-by: Mehul Parikh <mehul@apache.org>
  • Loading branch information
fimugdha authored and mehulbparikh committed Aug 28, 2023
1 parent 2cc56e1 commit 50a56de
Show file tree
Hide file tree
Showing 18 changed files with 171 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -727,13 +727,6 @@ const Editable = (props) => {
<RadioBtnComp value={value} options={options} valRef={selectValRef} />
) : type === TYPE_INPUT ? (
<InputboxComp value={value} valRef={selectValRef} />
) : type === TYPE_SELECT ? (
<CreatableSelectNew
value={value}
valRef={selectValRef}
conditionDefVal={props.conditionDefVal}
selectProps={props.selectProps}
/>
) : type === TYPE_CUSTOM ? (
<CustomCondition
value={value}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const RegexMessage = {
"Please avoid these characters (&, <, >, ', \", `) for policy name.",
userNameValidationMsg: (
<>
<p className="pd-10" style={{ fontSize: "small" }}>
<p className="pd-10 mb-0" style={{ fontSize: "small" }}>
1. User name should be start with alphabet / numeric / underscore /
non-us characters.
<br />
Expand All @@ -39,7 +39,7 @@ export const RegexMessage = {
"Password should be minimum 8 characters ,atleast one uppercase letter, one lowercase letter and one numeric. For FIPS environment password should be minimum 14 characters with atleast one uppercase letter, one special characters, one lowercase letter and one numeric.",
emailvalidationinfomessage: (
<>
<p className="pd-10" style={{ fontSize: "small" }}>
<p className="pd-10 mb-0" style={{ fontSize: "small" }}>
1. Email address should be start with alphabet / numeric / underscore
/ non-us characters.
<br /> 2. Allowed special character <b>.-@</b> .
Expand All @@ -55,7 +55,7 @@ export const RegexMessage = {
2. Dragging bottom-right corner of javascript condition editor(Textarea) can resizable",
firstNameValidationMsg: (
<>
<p className="pd-10" style={{ fontSize: "small" }}>
<p className="pd-10 mb-0" style={{ fontSize: "small" }}>
1. First name should be start with alphabet / numeric / underscore /
non-us characters.
<br />
Expand All @@ -67,7 +67,7 @@ export const RegexMessage = {
),
lastNameValidationMsg: (
<>
<p className="pd-10" style={{ fontSize: "small" }}>
<p className="pd-10 mb-0" style={{ fontSize: "small" }}>
1. Last name should be start with alphabet / numeric / underscore /
non-us characters.
<br />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import React, { useState } from "react";
import { getUserProfile, setUserProfile } from "Utils/appState";
import { getUserProfile } from "Utils/appState";
import { UserRoles, PathAssociateWithModule, QueryParams } from "Utils/XAEnums";
import {
filter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,19 @@

const appState = {};
const serviceDefData = {};

function getUserProfile() {
return appState.userProfile;
}

function setUserProfile(profile = null) {
appState.userProfile = profile;
}

function getServiceDef() {
return serviceDefData;
}

function setServiceDef(serviceDef, tagServiceDef, allServiceDefs) {
serviceDefData.serviceDefs = serviceDef;
serviceDefData.tagServiceDefs = tagServiceDef;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* under the License.
*/
import axios from "axios";
import ErrorPage from "../views/ErrorPage";
import {
RANGER_REST_CSRF_ENABLED,
RANGER_REST_CSRF_CUSTOM_HEADER,
Expand Down Expand Up @@ -55,6 +54,7 @@ async function fetchApi(axiosConfig = {}, otherConf = {}) {
const config = {
...axiosConfig
};

if (otherConf && otherConf.cancelRequest) {
/*
Below code add "source" attribute in second argument which is use to cancel request.
Expand All @@ -77,6 +77,7 @@ async function fetchApi(axiosConfig = {}, otherConf = {}) {
config.cancelToken = source.token;
otherConf.source = source;
}

try {
const resp = await axios(config);
return resp;
Expand All @@ -88,6 +89,9 @@ async function fetchApi(axiosConfig = {}, otherConf = {}) {
window.location.replace("login.jsp?sessionTimeout=true");
}
}
if (config.skipNavigate !== undefined && config.skipNavigate) {
throw error;
}
if (
error?.response?.status === 400 &&
(error?.response?.data?.messageList?.[0]?.name == "DATA_NOT_FOUND" ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function AccessLogDetail(props) {
fetchServiceDefs();
fetchAcessLogs();
}, []);

const fetchServiceDefs = async () => {
let serviceDefsResp = [];
try {
Expand All @@ -51,9 +52,10 @@ function AccessLogDetail(props) {
setServiceDefs(serviceDefsResp.data.serviceDefs);
setLoader(false);
};

const fetchAcessLogs = async () => {
let accessResp;
let accessData;
let accessResp = {};
let accessData = {};

try {
accessResp = await fetchApi({
Expand All @@ -66,7 +68,7 @@ function AccessLogDetail(props) {
console.error(
`Error occurred while fetching Access or CSRF headers! ${error}`
);
toast.error(error.response.data.msgDesc);
toast.error(error?.response?.data?.msgDesc);
}
if (!isEmpty(accessResp)) {
accessResp.data.vXAccessAudits.map((obj) => {
Expand All @@ -91,7 +93,7 @@ function AccessLogDetail(props) {
<div className="wrap">
<AccessLogsTable data={access}></AccessLogsTable>
</div>
{access.policyId != -1 && (
{access?.policyId !== undefined && access?.policyId > 0 && (
<>
<h5 className="heading-without-wrap">Policy Details</h5>
<div className="wrap">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,13 @@ export const AccessLogsTable = ({ data = {} }) => {
</tr>
<tr>
<td>Result</td>
<td>{accessResult == 1 ? "Allowed" : "Denied"}</td>
<td>
{accessResult !== undefined
? accessResult == 1
? "Allowed"
: "Denied"
: "--"}
</td>
</tr>
<tr>
<td className="text-nowrap">Access Enforcer</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export const PolicyLogs = ({ data, reportdata }) => {
return obj.attributeName == "Policy Resources" && obj.action == "update";
});

/*UPDATESS*/
/* UPDATES */

const policyDetailsUpdate = (details, resources) => {
let tablerow = [];
Expand Down Expand Up @@ -1743,7 +1743,7 @@ export const PolicyLogs = ({ data, reportdata }) => {

let keynew = {};
resources.map((obj) => {
keynew = !isEmpty(ovj.previousValue) && JSON.parse(obj.previousValue);
keynew = !isEmpty(obj.previousValue) && JSON.parse(obj.previousValue);
});

Object.keys(keynew).map((key, index) => {
Expand Down Expand Up @@ -3041,8 +3041,8 @@ export const PolicyLogs = ({ data, reportdata }) => {
<td className="table-warning policyitem-field">
<i>{`Users`}</i>
{`: ${
!isEmpty(policy.suers)
? policy.suers.join(", ")
!isEmpty(policy.users)
? policy.users.join(", ")
: "<empty>"
} `}
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,15 +243,15 @@ export const UserLogs = ({ data, reportdata }) => {
if (val == "ROLE_USER") {
val = UserRoles.ROLE_USER.label;
}
if (val == "ROLE_USER") {
val = UserRoles.ROLE_USER.label;
}
if (val == "ROLE_SYS_ADMIN") {
val = UserRoles.ROLE_SYS_ADMIN.label;
}
if (val == "ROLE_KEY_ADMIN") {
val = UserRoles.ROLE_KEY_ADMIN.label;
}
if (val == "ROLE_ADMIN_AUDITOR") {
val = UserRoles.ROLE_ADMIN_AUDITOR.label;
}
if (val == "ROLE_KEY_ADMIN_AUDITOR") {
val = UserRoles.ROLE_KEY_ADMIN_AUDITOR.label;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import { fetchApi } from "Utils/fetchAPI";
import dateFormat from "dateformat";
import moment from "moment-timezone";
import { find, sortBy, isUndefined, isEmpty } from "lodash";
import { commonBreadcrumb } from "../../utils/XAUtils";
import StructuredFilter from "../../components/structured-filter/react-typeahead/tokenizer";
import AsyncSelect from "react-select/async";
import { isKeyAdmin, parseSearchFilter } from "../../utils/XAUtils";
Expand Down Expand Up @@ -60,7 +59,7 @@ function init(props) {
updatetable: moment.now(),
currentPageIndex: 0,
currentPageSize: 25,
resetPage: { page: null }
resetPage: { page: 0 }
};
}

Expand Down Expand Up @@ -166,7 +165,8 @@ const KeyManager = (props) => {
currentPageIndex,
currentPageSize,
pagecount,
updatetable
updatetable,
resetPage
} = keyState;

useEffect(() => {
Expand Down Expand Up @@ -331,9 +331,8 @@ const KeyManager = (props) => {
setBlockUI(false);
toast.success(`Success! Key deleted successfully`);
if (keydata.length == 1 && currentPageIndex > 1) {
let page = currentPageIndex - currentPageIndex;
if (typeof resetPage?.page === "function") {
resetPage.page(page);
resetPage.page(0);
}
} else {
dispatch({
Expand All @@ -344,7 +343,7 @@ const KeyManager = (props) => {
} catch (error) {
setBlockUI(false);
let errorMsg = "";
if (error.response.data.msgDesc) {
if (error?.response?.data?.msgDesc) {
errorMsg = toast.error("Error! " + error.response.data.msgDesc + "\n");
} else {
errorMsg = `Error occurred during deleting Key` + "\n";
Expand Down Expand Up @@ -410,7 +409,7 @@ const KeyManager = (props) => {
});
dispatch({
type: "SET_RESET_PAGE",
resetPage: gotoPage
resetPage: { page: gotoPage }
});
dispatch({
type: "SET_LOADER",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,9 @@ const SecurityZoneForm = (props) => {
console.error(
`Error occurred while fetching Zone or CSRF headers! ${error}`
);
toast.error(error.response.data.msgDesc);
if (error?.response?.data?.msgDesc) {
toast.error(error.response.data.msgDesc);
}
}
setZone(zoneResp?.data);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,15 +476,17 @@ class ServiceDefinition extends Component {
<p className="form-header">
Config Properties :
</p>
<Table bordered size="sm">
<tbody className="service-config">
{s?.configs &&
this.getServiceConfigs(
this.state.serviceDef,
s.configs
)}
</tbody>
</Table>
<div className="table-responsive">
<Table bordered size="sm">
<tbody className="service-config">
{s?.configs &&
this.getServiceConfigs(
this.state.serviceDef,
s.configs
)}
</tbody>
</Table>
</div>
<p className="form-header">Audit Filter :</p>
<div className="table-responsive">
<Table
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,11 +281,13 @@ export const ServiceViewDetails = (props) => {
</tbody>
</Table>
<p className="form-header">Config Properties :</p>
<Table bordered size="sm">
<tbody className="service-config">
{getServiceConfigs(serviceDefData, serviceData.configs)}
</tbody>
</Table>
<div className="table-responsive">
<Table bordered size="sm">
<tbody className="service-config">
{getServiceConfigs(serviceDefData, serviceData.configs)}
</tbody>
</Table>
</div>
<p className="form-header">Audit Filter :</p>
<div className="table-responsive">
<Table bordered size="sm" className="table-audit-filter-ready-only">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {
import { getServiceDef } from "../../utils/appState";
import ResourceTagContent from "./ResourceTagContent";
import { Button } from "react-bootstrap";
import { toast } from "react-toastify";

function reducer(state, action) {
switch (action.type) {
Expand Down
Loading

0 comments on commit 50a56de

Please sign in to comment.