Skip to content
Snippets Groups Projects

Fix permissions

Merged Polina Arzhevikina requested to merge fix_permissions into decentralized-iam
1 file
+ 56
51
Compare changes
  • Side-by-side
  • Inline
@@ -59,18 +59,18 @@ const CustomAddButton = ({conditionType}) => {
context.append({ type: event.target.getAttribute("value") });
setAnchorEl(null);
};
if (conditionType == 'obligation'){
return(
<>
if (conditionType == 'permission'){
return (
<>
<IconButton color="primary" onClick={handleClick}>
<AddCircleOutlineIcon />
</IconButton>
<Menu anchorEl={anchorEl} open={open} onClose={handleClose}>
<MenuItem value="access" onClick={handleAdd} disableRipple>
<MenuItem value="membership" onClick={handleAdd} disableRipple>
<ListItemIcon>
<KeyIcon />
<CardMembershipIcon />
</ListItemIcon>
Access Based
Membership Based
</MenuItem>
<MenuItem value="identity" onClick={handleAdd} disableRipple>
<ListItemIcon>
@@ -84,30 +84,31 @@ const CustomAddButton = ({conditionType}) => {
</ListItemIcon>
Location Based
</MenuItem>
</Menu>
</>
)
}
else if (conditionType == 'permission'){
return (
<>
<IconButton color="primary" onClick={handleClick}>
<AddCircleOutlineIcon />
</IconButton>
<Menu anchorEl={anchorEl} open={open} onClose={handleClose}>
<MenuItem value="membership" onClick={handleAdd} disableRipple>
<MenuItem value="access" onClick={handleAdd} disableRipple>
<ListItemIcon>
<CardMembershipIcon />
<KeyIcon />
</ListItemIcon>
Membership Based
Access Based
</MenuItem>
</Menu>
</>
)
}
// uncomment when there are obligation policies
// else if (conditionType == 'obligation'){
// return(
// <>
// <IconButton color="primary" onClick={handleClick}>
// <AddCircleOutlineIcon />
// </IconButton>
// <Menu anchorEl={anchorEl} open={open} onClose={handleClose}>
// </Menu>
// </>
// )
// }
};
const IdentityBasedObligation = () => {
const IdentityBasedPermission = () => {
const {
field: { value: operatorValue },
} = useInput({ source: "operator" });
@@ -129,7 +130,7 @@ const IdentityBasedObligation = () => {
return (
<>
<Typography sx={{ mt: 2 }}>Identity Based Obligation</Typography>
<Typography sx={{ mt: 2 }}>Identity Based Permission</Typography>
<TextInput
source="leftOperand"
defaultValue="Membership.membershipId"
@@ -153,10 +154,10 @@ const IdentityBasedObligation = () => {
);
};
const AccessBasedObligation = () => {
const AccessBasedPermission = () => {
return (
<>
<Typography sx={{ mt: 2 }}>Access Based Obligation</Typography>
<Typography sx={{ mt: 2 }}>Access Based Permission</Typography>
<TextInput
source="leftOperand"
defaultValue="DataAccess.level"
@@ -214,7 +215,7 @@ const MembershipBasedPermission = () => {
</>)
};
const LocationBasedObligation = () => {
const LocationBasedPermission = () => {
const {
field: { value: operatorValue },
} = useInput({ source: "operator" });
@@ -242,7 +243,7 @@ const LocationBasedObligation = () => {
return (
<>
<Typography sx={{ mt: 2 }}>Location Based Obligation</Typography>
<Typography sx={{ mt: 2 }}>Location Based Permission</Typography>
<TextInput
source="leftOperand"
defaultValue="Membership.country"
@@ -378,35 +379,38 @@ export const PolicyShow = () => {
);
};
const ObligationCreate = () => {
const renderObligation = ({ type }) => {
if (type === "access") {
return <AccessBasedObligation />;
}
if (type === "identity") {
return <IdentityBasedObligation />;
}
if (type === "location") {
return <LocationBasedObligation />;
}
return null;
};
// uncomment when there are policies for obligations
// const ObligationCreate = () => {
// const renderObligation = ({ type }) => {
// {}
// return null;
// };
return (
<SimpleFormIterator addButton={<CustomAddButton conditionType={"obligation"} />}>
<FormDataConsumer>
{({ scopedFormData }) => {
return renderObligation({ type: scopedFormData.type });
}}
</FormDataConsumer>
</SimpleFormIterator>
);
};
// return (
// <SimpleFormIterator addButton={<CustomAddButton conditionType={"obligation"} />}>
// <FormDataConsumer>
// {({ scopedFormData }) => {
// return renderObligation({ type: scopedFormData.type });
// }}
// </FormDataConsumer>
// </SimpleFormIterator>
// );
// };
const PermissionCreate = () => {
const renderPermission = ({ type }) => {
if (type === "membership") {
return <MembershipBasedPermission />;
}
if (type === "identity") {
return <IdentityBasedPermission />;
}
if (type === "location") {
return <LocationBasedPermission />;
}
if (type === "access") {
return <AccessBasedPermission />;
}
return null;
};
@@ -447,9 +451,10 @@ export const PolicyCreate = (props: any) => (
<ArrayInput source="permissions">
<PermissionCreate />
</ArrayInput>
<ArrayInput source="obligations">
{/* uncomment when there are policies for obligations */}
{/* <ArrayInput source="obligations">
<ObligationCreate />
</ArrayInput>
</ArrayInput> */}
</Grid>
</Grid>
</SimpleForm>