diff --git a/oathkeeper/access-rules/kavach-web.json b/oathkeeper/access-rules/kavach-web.json index 67648c3e..a99671ca 100644 --- a/oathkeeper/access-rules/kavach-web.json +++ b/oathkeeper/access-rules/kavach-web.json @@ -32,7 +32,7 @@ "url": "http://kavach-web:3000" }, "match": { - "url": "http://127.0.0.1:4455/.factly/kavach/web<(/(organisation|organisation/edit|organisation(/(\\d+/settings(/(tokens|tokens/create|roles|roles(/(\\d+/users|\\d+/create|\\d+/edit))|policies|users|users/new))))|settings|password|profile|profile/invite|users|users(/new)|applications(/(create|type|\\d+/edit|\\d+/detail|\\d+/settings|\\d+/settings(/(users|tokens|tokens/create|roles|roles/create|policies|policies/create|spaces|spaces(/(create|\\d+/settings|\\d+/settings(/(tokens|roles|policies|users))))))))?))?/?>", + "url": "http://127.0.0.1:4455/.factly/kavach/web<(/(organisation|organisation(/edit|/create)|organisation(/(\\d+/settings(/(tokens|tokens/create|roles|roles/create|roles(/\\d+(/users|/create|/edit))|policies|policies/create|policies(/\\d+(/view|/edit))|users|users/new))))|settings|password|profile|profile/invite|users|users(/new)|applications(/(create|type|\\d+(/edit|/detail)|\\d+/settings|\\d+/settings(/(users|tokens|tokens/create|roles|roles/create|roles(/\\d+(/users|/create|/edit))|policies|policies/create|policies(/\\d+(/view|/edit))|spaces|spaces(/(create|\\d+/edit|\\d+/settings|\\d+/settings(/(tokens|tokens/create|roles|roles/create|roles(/\\d+(/users|/create|/edit))|policies|policies/create|policies(/\\d+(/view|/edit))|users))))))))?))?/?>", "methods": [ "GET" ] @@ -60,4 +60,4 @@ } ] } -] \ No newline at end of file +] diff --git a/web/src/pages/application/settings/policies/components/CreateApplicationPolicy.js b/web/src/pages/application/settings/policies/components/CreateApplicationPolicy.js index 7a9e4744..9fb7e9a1 100644 --- a/web/src/pages/application/settings/policies/components/CreateApplicationPolicy.js +++ b/web/src/pages/application/settings/policies/components/CreateApplicationPolicy.js @@ -33,7 +33,7 @@ export default function CreateApplicationPolicyForm() { const { roles, loadingRoles } = useSelector((state) => { var roleIDs = state.applications.details[appID]?.roleIDs || []; return { - roles: roleIDs.map((id) => state.roles.application[appID][id]), + roles: roleIDs.map((id) => state.roles.application?.[appID]?.[id]), loadingRoles: state.roles.loading, }; }); diff --git a/web/src/pages/application/settings/policies/components/EditApplicationPolicy.js b/web/src/pages/application/settings/policies/components/EditApplicationPolicy.js index baf06e6a..24e4c181 100644 --- a/web/src/pages/application/settings/policies/components/EditApplicationPolicy.js +++ b/web/src/pages/application/settings/policies/components/EditApplicationPolicy.js @@ -27,7 +27,7 @@ export default function EditApplicationPolicy() { policy: { ...state.policy?.application?.[appID]?.[policyID], roles: state.policy.application?.[appID]?.[policyID]?.roles?.map( - (rID) => state.roles.application[appID][rID], + (rID) => state.roles.application?.[appID]?.[rID], ), }, loading: state.policy.loading, @@ -35,7 +35,7 @@ export default function EditApplicationPolicy() { loadingRole: state.profile.loading, application: state.applications.details[appID], loadingApp: state.applications.loading, - roles: roleIDs.map((id) => state.roles.application[appID][id]), + roles: roleIDs.map((id) => state.roles.application?.[appID]?.[id]), loadingRoles: state.roles.loading, }; }, diff --git a/web/src/pages/application/settings/policies/components/ViewApplicationPolicy.js b/web/src/pages/application/settings/policies/components/ViewApplicationPolicy.js index 7c8c2f14..f00f855c 100644 --- a/web/src/pages/application/settings/policies/components/ViewApplicationPolicy.js +++ b/web/src/pages/application/settings/policies/components/ViewApplicationPolicy.js @@ -32,7 +32,7 @@ export default function ViewApplicationPolicy() { const { policy, loading } = useSelector((state) => { return { policy: { - ...state.policy.application[appID][policyID], + ...state.policy?.application?.[appID]?.[policyID], roles: state.policy.application[appID]?.[policyID]?.roles?.map((rId) => ({ ...state.roles.application[appID]?.[rId], diff --git a/web/src/pages/application/settings/roles/components/RoleList.js b/web/src/pages/application/settings/roles/components/RoleList.js index c8d97fdb..0392612c 100644 --- a/web/src/pages/application/settings/roles/components/RoleList.js +++ b/web/src/pages/application/settings/roles/components/RoleList.js @@ -12,7 +12,7 @@ function ApplicationRoleList({ appID, role }) { roleIDs = state.applications.details[appID]?.roleIDs || []; return { roles: roleIDs?.map((id) => ({ - ...state.roles.application[appID][id], + ...state.roles.application?.[appID]?.[id], })), loading: state.roles.loading, }; diff --git a/web/src/pages/application/settings/roles/users/index.js b/web/src/pages/application/settings/roles/users/index.js index edabbb61..462074fc 100644 --- a/web/src/pages/application/settings/roles/users/index.js +++ b/web/src/pages/application/settings/roles/users/index.js @@ -15,8 +15,8 @@ export default function ApplicationRoleUsers() { (state) => { var remUserIDs = []; var roleUserIDs = []; - roleUserIDs = state.roles.application[appID][roleID].users || []; - const appUserIDs = state.applications.details[appID].users || []; + roleUserIDs = state.roles.application?.[appID]?.[roleID].users || []; + const appUserIDs = state.applications.details[appID]?.users || []; remUserIDs = appUserIDs.filter((uID) => roleUserIDs.every((rUID) => !(rUID === uID))); return { roleUsers: roleUserIDs.map((id) => state.users.details[id]), diff --git a/web/src/pages/application/settings/spaces/settings/policies/components/ViewSpacePolicy.js b/web/src/pages/application/settings/spaces/settings/policies/components/ViewSpacePolicy.js index 22e6719f..8c421724 100644 --- a/web/src/pages/application/settings/spaces/settings/policies/components/ViewSpacePolicy.js +++ b/web/src/pages/application/settings/spaces/settings/policies/components/ViewSpacePolicy.js @@ -34,15 +34,15 @@ export default function ViewSpacePolicy() { policy: { ...state.policy.space?.[spaceID]?.[policyID], roles: - state.policy.space[spaceID][policyID]?.roles?.map((rId) => ({ + state.policy.space[spaceID]?.[policyID]?.roles?.map((rId) => ({ ...state.roles.space[spaceID]?.[rId], })) || [], - permissions: state.policy.space[spaceID][policyID]?.permissions || [], + permissions: state.policy.space[spaceID]?.[policyID]?.permissions || [], }, loading: state.policy.loading, }; }); - + const fetchPolicy = () => { getSpacePolicyByID(appID, spaceID, policyID); diff --git a/web/src/pages/application/settings/spaces/settings/roles/components/EditRole.js b/web/src/pages/application/settings/spaces/settings/roles/components/EditRole.js index 04afbf56..dd4494ef 100644 --- a/web/src/pages/application/settings/spaces/settings/roles/components/EditRole.js +++ b/web/src/pages/application/settings/spaces/settings/roles/components/EditRole.js @@ -31,7 +31,7 @@ export default function EditSpaceRole() { const { role, loading, space, loadingSpace, userRole, loadingUserRole } = useSelector((state) => { return { - role: state.roles.space[spaceID][roleID], + role: state.roles.space?.[spaceID]?.[roleID], loading: state.roles.loading, space: state.spaces.details[spaceID], loadingSpace: state.spaces.loading, diff --git a/web/src/pages/application/settings/spaces/settings/roles/users/index.js b/web/src/pages/application/settings/spaces/settings/roles/users/index.js index 8383f571..225908f5 100644 --- a/web/src/pages/application/settings/spaces/settings/roles/users/index.js +++ b/web/src/pages/application/settings/spaces/settings/roles/users/index.js @@ -14,7 +14,7 @@ export default function SpaceRoleUsers() { (state) => { var remUserIDs = []; var roleUserIDs = []; - roleUserIDs = state.roles.space[spaceID][roleID]?.users || []; + roleUserIDs = state?.roles?.space?.[spaceID]?.[roleID]?.users || []; const spaceUserIDs = state.spaces.details[spaceID]?.users || []; if (spaceUserIDs?.length) { remUserIDs = spaceUserIDs.filter((uID) => roleUserIDs.every((rUID) => !(rUID === uID))); diff --git a/web/src/pages/application/settings/spaces/settings/users/index.js b/web/src/pages/application/settings/spaces/settings/users/index.js index 906b97c9..47cd6afc 100644 --- a/web/src/pages/application/settings/spaces/settings/users/index.js +++ b/web/src/pages/application/settings/spaces/settings/users/index.js @@ -13,11 +13,11 @@ export default function SpaceUser() { const { appUsers, loadingApps, spaceUsers, loadingSpace, role } = useSelector((state) => { return { - appUsers: state.applications.details[appID]?.users.map((id) => state.users.details[id]) || [], - loadingApps: state.applications.loading, - spaceUsers: state.spaces.details[spaceID]?.users.map((id) => state.users.details[id]) || [], - loadingSpace: state.spaces.loading, - role: state.profile.roles[state.organisations.selected], + appUsers: state?.applications?.details[appID]?.users.map((id) => state.users.details[id]) || [], + loadingApps: state?.applications?.loading, + spaceUsers: state?.spaces?.details[spaceID]?.users.map((id) => state.users.details[id]) || [], + loadingSpace: state?.spaces?.loading, + role: state?.profile?.roles[state.organisations.selected], }; }); diff --git a/web/src/pages/organisation/settings/policies/components/ViewOrganisationPolicy.js b/web/src/pages/organisation/settings/policies/components/ViewOrganisationPolicy.js index 1134b485..08800ea6 100644 --- a/web/src/pages/organisation/settings/policies/components/ViewOrganisationPolicy.js +++ b/web/src/pages/organisation/settings/policies/components/ViewOrganisationPolicy.js @@ -34,9 +34,9 @@ export default function ViewOrganisationPolicy() { const { policy, loading } = useSelector((state) => { return { policy: { - ...state.policy.organisation[orgID][policyID], + ...state.policy?.organisation?.[orgID]?.[policyID], roles: - state.policy.organisation[orgID][policyID]?.roles.map((rId) => ({ + state.policy?.organisation?.[orgID]?.[policyID]?.roles.map((rId) => ({ ...state.roles.organisation[orgID]?.[rId], })) || [], }, diff --git a/web/src/pages/organisation/settings/roles/users/index.js b/web/src/pages/organisation/settings/roles/users/index.js index 4f9d8c38..be6e321c 100644 --- a/web/src/pages/organisation/settings/roles/users/index.js +++ b/web/src/pages/organisation/settings/roles/users/index.js @@ -18,8 +18,8 @@ export default function OrganisationRoleUsers() { (state) => { var remUserIDs = []; var roleUserIDs = []; - roleUserIDs = state.roles.organisation[orgID][roleID].users || []; - const orgUserIDs = state.organisations.details[orgID].users || []; + roleUserIDs = state.roles.organisation?.[orgID]?.[roleID].users || []; + const orgUserIDs = state.organisations.details?.[orgID]?.users || []; remUserIDs = orgUserIDs.filter((uID) => roleUserIDs.every((rUID) => !(rUID === uID))); return { roleUsers: roleUserIDs.map((id) => state.users.details[id]),