Skip to content

Commit

Permalink
Merge pull request #427 from factly/fix/ory-access-rules
Browse files Browse the repository at this point in the history
adds the fixes for access rules
  • Loading branch information
shreeharsha-factly authored Mar 20, 2024
2 parents 7999d0d + 1142927 commit e0de424
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions oathkeeper/access-rules/kavach-web.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
Expand Down Expand Up @@ -60,4 +60,4 @@
}
]
}
]
]
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ 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,
role: state.profile.roles[state.organisations.selected],
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,
};
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
4 changes: 2 additions & 2 deletions web/src/pages/application/settings/roles/users/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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],
};
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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],
})) || [],
},
Expand Down
4 changes: 2 additions & 2 deletions web/src/pages/organisation/settings/roles/users/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]),
Expand Down

0 comments on commit e0de424

Please sign in to comment.