Update MI authz logic

This commit is contained in:
Tuan Dang
2023-11-27 14:19:10 +07:00
parent 99c41bb63b
commit 6579b3c93f
15 changed files with 49 additions and 29 deletions
@@ -31,7 +31,7 @@ export const MachineIdentitySection = withPermission(
machineId
});
createNotification({
text: "Successfully deleted service token v3",
text: "Successfully deleted machine identity",
type: "success"
});
@@ -39,7 +39,7 @@ export const MachineIdentitySection = withPermission(
} catch (err) {
console.error(err);
createNotification({
text: "Failed to delete service token v3",
text: "Failed to delete machine identity",
type: "error"
});
}
@@ -103,13 +103,13 @@ export const MachineIdentityTable = ({
// });
// createNotification({
// text: `Successfully ${isActive ? "enabled" : "disabled"} service token v3`,
// text: `Successfully ${isActive ? "enabled" : "disabled"} machine identity`,
// type: "success"
// });
// } catch (err) {
// console.log(err);
// createNotification({
// text: `Failed to ${isActive ? "enable" : "disable"} service token v3`,
// text: `Failed to ${isActive ? "enable" : "disable"} machine identity`,
// type: "error"
// });
// }
@@ -84,7 +84,7 @@ const SIMPLE_PERMISSION_OPTIONS = [
] as const;
export const OrgRoleModifySection = ({ role, onGoBack }: Props) => {
const isNonEditable = ["owner", "admin", "member"].includes(role?.slug || "");
const isNonEditable = ["owner", "admin", "member", "no-access"].includes(role?.slug || "");
const isNewRole = !role?.slug;
const { createNotification } = useNotificationContext();
@@ -33,7 +33,7 @@ export const LogsTableRow = ({
return (
<Td>
<p>{`${actor.metadata.name}`}</p>
<p>Service token V3</p>
<p>Machine identity</p>
</Td>
);
default:
@@ -27,7 +27,7 @@ import { UsePopUpState } from "@app/hooks/usePopUp";
const schema = yup.object({
machineId: yup.string().required("Machine identity id is required"),
role: yup.string().required("Machine identity role is required")
role: yup.string()
}).required();
export type FormData = yup.InferType<typeof schema>;
@@ -85,10 +85,11 @@ export const AddMachineIdentityModal = ({
role
}: FormData) => {
try {
await addMachineToWorkspaceMutateAsync({
workspaceId,
machineId,
role
role: role || undefined
});
createNotification({
@@ -9,6 +9,7 @@ import {
faLock,
faNetworkWired,
faPuzzlePiece,
faServer,
faShield,
faTags,
faUser,
@@ -59,6 +60,12 @@ const SINGLE_PERMISSION_LIST = [
icon: faUser,
formName: "member"
},
{
title: "Machine identity management",
subtitle: "Add, view, update and remove machine identities from the project",
icon: faServer,
formName: "machine-identity"
},
{
title: "Webhooks",
subtitle: "Webhook management control",
@@ -109,7 +116,7 @@ type Props = {
};
export const ProjectRoleModifySection = ({ role, onGoBack }: Props) => {
const isNonEditable = ["admin", "member", "viewer"].includes(role?.slug || "");
const isNonEditable = ["admin", "member", "viewer", "no-access"].includes(role?.slug || "");
const isNewRole = !role?.slug;
const { createNotification } = useNotificationContext();
@@ -133,7 +140,7 @@ export const ProjectRoleModifySection = ({ role, onGoBack }: Props) => {
const handleRoleUpdate = async (el: TFormSchema) => {
if (!role?._id) return;
try {
await updateRole({
orgId,
@@ -33,6 +33,7 @@ export const formSchema = z.object({
.object({
secrets: z.record(multiEnvPermissionSchema).optional(),
member: generalPermissionSchema,
"machine-identity": generalPermissionSchema,
role: generalPermissionSchema,
integrations: generalPermissionSchema,
webhooks: generalPermissionSchema,