mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-03 23:26:09 +00:00
Merge pull request #4790 from Infisical/fix/remove-duplicate-error-notifications
Fix: remove duplicate error notifications
This commit is contained in:
@@ -35,23 +35,16 @@ export const WishForm = () => {
|
|||||||
const [isOpen, setIsOpen] = useToggle(false);
|
const [isOpen, setIsOpen] = useToggle(false);
|
||||||
|
|
||||||
const createWish = async (data: TFormData) => {
|
const createWish = async (data: TFormData) => {
|
||||||
try {
|
await mutateAsync({
|
||||||
await mutateAsync({
|
text: data.text
|
||||||
text: data.text
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Your wish has been sent to the Infisical team!",
|
text: "Your wish has been sent to the Infisical team!",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
setIsOpen.off();
|
setIsOpen.off();
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
text: "An error occured while sending your wish to the Infisical team.",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -25,27 +25,20 @@ const TotpRegistration = ({ onComplete, shouldCenterQr }: Props) => {
|
|||||||
|
|
||||||
const handleTotpVerify = async (event: React.FormEvent<HTMLFormElement>) => {
|
const handleTotpVerify = async (event: React.FormEvent<HTMLFormElement>) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
try {
|
const result = await verifyUserTotp({
|
||||||
const result = await verifyUserTotp({
|
totp
|
||||||
totp
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully configured mobile authenticator",
|
text: "Successfully configured mobile authenticator",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
if (result.recoveryCodes && result.recoveryCodes.length > 0) {
|
if (result.recoveryCodes && result.recoveryCodes.length > 0) {
|
||||||
setRecoveryCodes(result.recoveryCodes);
|
setRecoveryCodes(result.recoveryCodes);
|
||||||
setShowRecoveryModal(true);
|
setShowRecoveryModal(true);
|
||||||
} else if (onComplete) {
|
} else if (onComplete) {
|
||||||
onComplete();
|
onComplete();
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to verify TOTP code",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -43,35 +43,27 @@ export const CreateOrgModal: FC<CreateOrgModalProps> = ({ isOpen, onClose }) =>
|
|||||||
const { mutateAsync: selectOrg } = useSelectOrganization();
|
const { mutateAsync: selectOrg } = useSelectOrganization();
|
||||||
|
|
||||||
const onFormSubmit = async ({ name }: FormData) => {
|
const onFormSubmit = async ({ name }: FormData) => {
|
||||||
try {
|
const organization = await createOrg({
|
||||||
const organization = await createOrg({
|
name
|
||||||
name
|
});
|
||||||
});
|
|
||||||
|
|
||||||
await selectOrg({
|
await selectOrg({
|
||||||
organizationId: organization.id
|
organizationId: organization.id
|
||||||
});
|
});
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully created organization",
|
text: "Successfully created organization",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
navigate({
|
navigate({
|
||||||
to: "/organization/projects"
|
to: "/organization/projects"
|
||||||
});
|
});
|
||||||
|
|
||||||
localStorage.setItem("orgData.id", organization.id);
|
localStorage.setItem("orgData.id", organization.id);
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
onClose();
|
onClose();
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to created organization",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -20,28 +20,19 @@ export const DeletePkiSyncModal = ({ isOpen, onOpenChange, pkiSync, onComplete }
|
|||||||
const handleDeletePkiSync = async () => {
|
const handleDeletePkiSync = async () => {
|
||||||
const destinationName = PKI_SYNC_MAP[destination].name;
|
const destinationName = PKI_SYNC_MAP[destination].name;
|
||||||
|
|
||||||
try {
|
await deleteSync.mutateAsync({
|
||||||
await deleteSync.mutateAsync({
|
syncId,
|
||||||
syncId,
|
projectId,
|
||||||
projectId,
|
destination
|
||||||
destination
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Successfully deleted ${destinationName} PKI Sync`,
|
text: `Successfully deleted ${destinationName} PKI Sync`,
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
if (onComplete) onComplete();
|
if (onComplete) onComplete();
|
||||||
onOpenChange(false);
|
onOpenChange(false);
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: `Failed to delete ${destinationName} PKI Sync`,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -21,27 +21,18 @@ const Content = ({ pkiSync, onComplete }: ContentProps) => {
|
|||||||
const triggerImportCertificates = useTriggerPkiSyncImportCertificates();
|
const triggerImportCertificates = useTriggerPkiSyncImportCertificates();
|
||||||
|
|
||||||
const handleTriggerImportCertificates = async () => {
|
const handleTriggerImportCertificates = async () => {
|
||||||
try {
|
await triggerImportCertificates.mutateAsync({
|
||||||
await triggerImportCertificates.mutateAsync({
|
syncId,
|
||||||
syncId,
|
destination,
|
||||||
destination,
|
projectId
|
||||||
projectId
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Successfully triggered certificate import for ${destinationName} Sync`,
|
text: `Successfully triggered certificate import for ${destinationName} Sync`,
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
onComplete();
|
onComplete();
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: `Failed to trigger certificate import for ${destinationName} Sync`,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -21,27 +21,18 @@ const Content = ({ pkiSync, onComplete }: ContentProps) => {
|
|||||||
const triggerRemoveCertificates = useTriggerPkiSyncRemoveCertificates();
|
const triggerRemoveCertificates = useTriggerPkiSyncRemoveCertificates();
|
||||||
|
|
||||||
const handleTriggerRemoveCertificates = async () => {
|
const handleTriggerRemoveCertificates = async () => {
|
||||||
try {
|
await triggerRemoveCertificates.mutateAsync({
|
||||||
await triggerRemoveCertificates.mutateAsync({
|
syncId,
|
||||||
syncId,
|
destination,
|
||||||
destination,
|
projectId
|
||||||
projectId
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Successfully triggered certificate removal for ${destinationName} Sync`,
|
text: `Successfully triggered certificate removal for ${destinationName} Sync`,
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
onComplete();
|
onComplete();
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: `Failed to trigger certificate removal for ${destinationName} Sync`,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -86,14 +86,8 @@ export const CreatePkiSyncForm = ({ destination, onComplete, onCancel, initialDa
|
|||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
onComplete(pkiSync);
|
onComplete(pkiSync);
|
||||||
} catch (err: Error | unknown) {
|
} catch {
|
||||||
console.error("PKI sync creation failed:", err);
|
|
||||||
setShowConfirmation(false);
|
setShowConfirmation(false);
|
||||||
createNotification({
|
|
||||||
title: `Failed to create ${destinationName} Certificate Sync`,
|
|
||||||
text: err instanceof Error ? err.message : "An unknown error occurred",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -42,28 +42,19 @@ export const EditPkiSyncForm = ({ pkiSync, fields, onComplete }: Props) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const onSubmit = async ({ connection, ...formData }: TUpdatePkiSyncForm) => {
|
const onSubmit = async ({ connection, ...formData }: TUpdatePkiSyncForm) => {
|
||||||
try {
|
const updatedPkiSync = await updatePkiSync.mutateAsync({
|
||||||
const updatedPkiSync = await updatePkiSync.mutateAsync({
|
syncId: pkiSync.id,
|
||||||
syncId: pkiSync.id,
|
...formData,
|
||||||
...formData,
|
connectionId: connection.id,
|
||||||
connectionId: connection.id,
|
projectId: pkiSync.projectId,
|
||||||
projectId: pkiSync.projectId,
|
destination: pkiSync.destination
|
||||||
destination: pkiSync.destination
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Successfully updated ${destinationName} PKI Sync`,
|
text: `Successfully updated ${destinationName} PKI Sync`,
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
onComplete(updatedPkiSync);
|
onComplete(updatedPkiSync);
|
||||||
} catch (err: any) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
title: `Failed to update ${destinationName} PKI Sync`,
|
|
||||||
text: err.message,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let Component: ReactNode;
|
let Component: ReactNode;
|
||||||
|
|||||||
@@ -56,30 +56,22 @@ export const ProjectOverviewChangeSection = ({ showSlugField = false }: Props) =
|
|||||||
}, [currentProject, showSlugField]);
|
}, [currentProject, showSlugField]);
|
||||||
|
|
||||||
const onFormSubmit = async (data: BaseFormData | FormDataWithSlug) => {
|
const onFormSubmit = async (data: BaseFormData | FormDataWithSlug) => {
|
||||||
try {
|
if (!currentProject?.id) return;
|
||||||
if (!currentProject?.id) return;
|
|
||||||
|
|
||||||
await mutateAsync({
|
await mutateAsync({
|
||||||
projectId: currentProject.id,
|
projectId: currentProject.id,
|
||||||
newProjectName: data.name,
|
newProjectName: data.name,
|
||||||
newProjectDescription: data.description,
|
newProjectDescription: data.description,
|
||||||
...(showSlugField &&
|
...(showSlugField &&
|
||||||
"slug" in data && {
|
"slug" in data && {
|
||||||
newSlug: data.slug !== currentProject.slug ? data.slug : undefined
|
newSlug: data.slug !== currentProject.slug ? data.slug : undefined
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully updated project overview",
|
text: "Successfully updated project overview",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to update project overview",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -141,29 +141,24 @@ const NewProjectForm = ({ onOpenChange }: NewProjectFormProps) => {
|
|||||||
// type check
|
// type check
|
||||||
if (!currentOrg) return;
|
if (!currentOrg) return;
|
||||||
if (!user) return;
|
if (!user) return;
|
||||||
try {
|
const {
|
||||||
const {
|
data: { project }
|
||||||
data: { project }
|
} = await createWs.mutateAsync({
|
||||||
} = await createWs.mutateAsync({
|
projectName: name,
|
||||||
projectName: name,
|
projectDescription: description,
|
||||||
projectDescription: description,
|
kmsKeyId: kmsKeyId !== INTERNAL_KMS_KEY_ID ? kmsKeyId : undefined,
|
||||||
kmsKeyId: kmsKeyId !== INTERNAL_KMS_KEY_ID ? kmsKeyId : undefined,
|
template,
|
||||||
template,
|
type
|
||||||
type
|
});
|
||||||
});
|
await refetchWorkspaces();
|
||||||
await refetchWorkspaces();
|
|
||||||
|
|
||||||
createNotification({ text: "Project created", type: "success" });
|
createNotification({ text: "Project created", type: "success" });
|
||||||
reset();
|
reset();
|
||||||
onOpenChange(false);
|
onOpenChange(false);
|
||||||
navigate({
|
navigate({
|
||||||
to: getProjectHomePage(project.type, project.environments),
|
to: getProjectHomePage(project.type, project.environments),
|
||||||
params: { projectId: project.id }
|
params: { projectId: project.id }
|
||||||
});
|
});
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({ text: "Failed to create project", type: "error" });
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
const onSubmit = handleSubmit((data) => {
|
const onSubmit = handleSubmit((data) => {
|
||||||
return onCreateProject(data);
|
return onCreateProject(data);
|
||||||
|
|||||||
@@ -37,29 +37,22 @@ export const DeleteSecretRotationV2Modal = ({
|
|||||||
const handleDeleteSecretRotation = async () => {
|
const handleDeleteSecretRotation = async () => {
|
||||||
const rotationType = SECRET_ROTATION_MAP[type].name;
|
const rotationType = SECRET_ROTATION_MAP[type].name;
|
||||||
|
|
||||||
try {
|
await deleteSecretRotation.mutateAsync({
|
||||||
await deleteSecretRotation.mutateAsync({
|
rotationId,
|
||||||
rotationId,
|
type,
|
||||||
type,
|
revokeGeneratedCredentials,
|
||||||
revokeGeneratedCredentials,
|
deleteSecrets,
|
||||||
deleteSecrets,
|
projectId,
|
||||||
projectId,
|
secretPath: folder.path
|
||||||
secretPath: folder.path
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Successfully deleted ${rotationType} Rotation`,
|
text: `Successfully deleted ${rotationType} Rotation`,
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
if (onComplete) onComplete();
|
if (onComplete) onComplete();
|
||||||
onOpenChange(false);
|
onOpenChange(false);
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
text: `Failed to delete ${rotationType} Rotation`,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -22,28 +22,19 @@ const Content = ({ secretRotation, onComplete }: ContentProps) => {
|
|||||||
const rotationType = SECRET_ROTATION_MAP[type].name;
|
const rotationType = SECRET_ROTATION_MAP[type].name;
|
||||||
|
|
||||||
const handleRotateSecrets = async () => {
|
const handleRotateSecrets = async () => {
|
||||||
try {
|
await rotateSecrets.mutateAsync({
|
||||||
await rotateSecrets.mutateAsync({
|
rotationId,
|
||||||
rotationId,
|
type,
|
||||||
type,
|
projectId,
|
||||||
projectId,
|
secretPath: folder.path
|
||||||
secretPath: folder.path
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Successfully rotated ${rotationType} secrets`,
|
text: `Successfully rotated ${rotationType} secrets`,
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
onComplete();
|
onComplete();
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: `Failed to rotate ${rotationType} secrets`,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -120,21 +120,13 @@ export const SecretRotationV2Form = ({
|
|||||||
environment: environment.slug,
|
environment: environment.slug,
|
||||||
projectId: currentProject.id
|
projectId: currentProject.id
|
||||||
});
|
});
|
||||||
try {
|
const rotation = await mutation;
|
||||||
const rotation = await mutation;
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Successfully ${secretRotation ? "updated" : "created"} ${rotationType} Rotation`,
|
text: `Successfully ${secretRotation ? "updated" : "created"} ${rotationType} Rotation`,
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
onComplete(rotation);
|
onComplete(rotation);
|
||||||
} catch (err: any) {
|
|
||||||
createNotification({
|
|
||||||
title: `Failed to ${secretRotation ? "update" : "create"} ${rotationType} Rotation`,
|
|
||||||
text: err.message,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handlePrev = () => {
|
const handlePrev = () => {
|
||||||
|
|||||||
@@ -28,26 +28,19 @@ export const DeleteSecretScanningDataSourceModal = ({
|
|||||||
const handleDeleteDataSource = async () => {
|
const handleDeleteDataSource = async () => {
|
||||||
const dataSourceType = SECRET_SCANNING_DATA_SOURCE_MAP[type].name;
|
const dataSourceType = SECRET_SCANNING_DATA_SOURCE_MAP[type].name;
|
||||||
|
|
||||||
try {
|
await deleteDataSource.mutateAsync({
|
||||||
await deleteDataSource.mutateAsync({
|
dataSourceId,
|
||||||
dataSourceId,
|
type,
|
||||||
type,
|
projectId
|
||||||
projectId
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Successfully deleted ${dataSourceType} Data Source`,
|
text: `Successfully deleted ${dataSourceType} Data Source`,
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
if (onComplete) onComplete();
|
if (onComplete) onComplete();
|
||||||
onOpenChange(false);
|
onOpenChange(false);
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
text: `Failed to delete ${dataSourceType} Data Source`,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -73,21 +73,13 @@ export const SecretScanningDataSourceForm = ({
|
|||||||
connectionId: connection?.id,
|
connectionId: connection?.id,
|
||||||
projectId: currentProject.id
|
projectId: currentProject.id
|
||||||
});
|
});
|
||||||
try {
|
const source = await mutation;
|
||||||
const source = await mutation;
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Successfully ${source ? "updated" : "created"} ${sourceType} Data Source`,
|
text: `Successfully ${source ? "updated" : "created"} ${sourceType} Data Source`,
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
onComplete(source);
|
onComplete(source);
|
||||||
} catch (err: any) {
|
|
||||||
createNotification({
|
|
||||||
title: `Failed to ${dataSource ? "update" : "create"} ${sourceType} Data Source`,
|
|
||||||
text: err.message,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handlePrev = () => {
|
const handlePrev = () => {
|
||||||
|
|||||||
@@ -23,29 +23,20 @@ export const DeleteSecretSyncModal = ({ isOpen, onOpenChange, secretSync, onComp
|
|||||||
const handleDeleteSecretSync = async () => {
|
const handleDeleteSecretSync = async () => {
|
||||||
const destinationName = SECRET_SYNC_MAP[destination].name;
|
const destinationName = SECRET_SYNC_MAP[destination].name;
|
||||||
|
|
||||||
try {
|
await deleteSync.mutateAsync({
|
||||||
await deleteSync.mutateAsync({
|
syncId,
|
||||||
syncId,
|
destination,
|
||||||
destination,
|
removeSecrets,
|
||||||
removeSecrets,
|
projectId
|
||||||
projectId
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Successfully removed ${destinationName} Sync`,
|
text: `Successfully removed ${destinationName} Sync`,
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
if (onComplete) onComplete();
|
if (onComplete) onComplete();
|
||||||
onOpenChange(false);
|
onOpenChange(false);
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: `Failed to remove ${destinationName} Sync`,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -51,28 +51,19 @@ const Content = ({ secretSync, onComplete }: ContentProps) => {
|
|||||||
const triggerImportSecrets = useTriggerSecretSyncImportSecrets();
|
const triggerImportSecrets = useTriggerSecretSyncImportSecrets();
|
||||||
|
|
||||||
const handleTriggerImportSecrets = async ({ importBehavior }: TFormData) => {
|
const handleTriggerImportSecrets = async ({ importBehavior }: TFormData) => {
|
||||||
try {
|
await triggerImportSecrets.mutateAsync({
|
||||||
await triggerImportSecrets.mutateAsync({
|
syncId,
|
||||||
syncId,
|
destination,
|
||||||
destination,
|
importBehavior,
|
||||||
importBehavior,
|
projectId
|
||||||
projectId
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Successfully triggered secret import for ${destinationName} Sync`,
|
text: `Successfully triggered secret import for ${destinationName} Sync`,
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
onComplete();
|
onComplete();
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: `Failed to trigger secret import for ${destinationName} Sync`,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -21,27 +21,18 @@ const Content = ({ secretSync, onComplete }: ContentProps) => {
|
|||||||
const triggerSyncImport = useTriggerSecretSyncRemoveSecrets();
|
const triggerSyncImport = useTriggerSecretSyncRemoveSecrets();
|
||||||
|
|
||||||
const handleTriggerRemoveSecrets = async () => {
|
const handleTriggerRemoveSecrets = async () => {
|
||||||
try {
|
await triggerSyncImport.mutateAsync({
|
||||||
await triggerSyncImport.mutateAsync({
|
syncId,
|
||||||
syncId,
|
destination,
|
||||||
destination,
|
projectId
|
||||||
projectId
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Successfully triggered secret removal for ${destinationName} Sync`,
|
text: `Successfully triggered secret removal for ${destinationName} Sync`,
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
onComplete();
|
onComplete();
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: `Failed to trigger secret removal for ${destinationName} Sync`,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -88,14 +88,8 @@ export const CreateSecretSyncForm = ({
|
|||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
onComplete(secretSync);
|
onComplete(secretSync);
|
||||||
} catch (err: any) {
|
} catch {
|
||||||
console.error(err);
|
|
||||||
setShowConfirmation(false);
|
setShowConfirmation(false);
|
||||||
createNotification({
|
|
||||||
title: `Failed to add ${destinationName} Sync`,
|
|
||||||
text: err.message,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -58,29 +58,20 @@ export const EditSecretSyncForm = ({ secretSync, fields, onComplete }: Props) =>
|
|||||||
|
|
||||||
const performUpdate = useCallback(
|
const performUpdate = useCallback(
|
||||||
async (formData: TSecretSyncForm) => {
|
async (formData: TSecretSyncForm) => {
|
||||||
try {
|
const { environment, connection, ...updateData } = formData;
|
||||||
const { environment, connection, ...updateData } = formData;
|
const updatedSecretSync = await updateSecretSync.mutateAsync({
|
||||||
const updatedSecretSync = await updateSecretSync.mutateAsync({
|
syncId: secretSync.id,
|
||||||
syncId: secretSync.id,
|
...updateData,
|
||||||
...updateData,
|
environment: environment?.slug,
|
||||||
environment: environment?.slug,
|
connectionId: connection.id,
|
||||||
connectionId: connection.id,
|
projectId: secretSync.projectId
|
||||||
projectId: secretSync.projectId
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Successfully updated ${destinationName} Sync`,
|
text: `Successfully updated ${destinationName} Sync`,
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
onComplete(updatedSecretSync);
|
onComplete(updatedSecretSync);
|
||||||
} catch (err: any) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
title: `Failed to update ${destinationName} Sync`,
|
|
||||||
text: err.message,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
[updateSecretSync, secretSync.id, secretSync.projectId, destinationName, onComplete]
|
[updateSecretSync, secretSync.id, secretSync.projectId, destinationName, onComplete]
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -130,26 +130,18 @@ export const CreateTagModal = ({ isOpen, onToggle, append, currentSecret }: Prop
|
|||||||
}, [isOpen]);
|
}, [isOpen]);
|
||||||
|
|
||||||
const onFormSubmit = async ({ slug, color }: FormData) => {
|
const onFormSubmit = async ({ slug, color }: FormData) => {
|
||||||
try {
|
const data = await createWsTag({
|
||||||
const data = await createWsTag({
|
projectId,
|
||||||
projectId,
|
tagColor: color,
|
||||||
tagColor: color,
|
tagSlug: slug
|
||||||
tagSlug: slug
|
});
|
||||||
});
|
append(data);
|
||||||
append(data);
|
onToggle(false);
|
||||||
onToggle(false);
|
reset();
|
||||||
reset();
|
createNotification({
|
||||||
createNotification({
|
text: "Successfully created a tag",
|
||||||
text: "Successfully created a tag",
|
type: "success"
|
||||||
type: "success"
|
});
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to create a tag",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+13
-20
@@ -36,28 +36,21 @@ export const NewSubOrganizationForm = ({ onClose }: ContentProps) => {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const onSubmit = async ({ name }: FormData) => {
|
const onSubmit = async ({ name }: FormData) => {
|
||||||
try {
|
const { organization } = await createSubOrg.mutateAsync({
|
||||||
const { organization } = await createSubOrg.mutateAsync({
|
name
|
||||||
name
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
type: "success",
|
type: "success",
|
||||||
text: "Successfully created sub organization"
|
text: "Successfully created sub organization"
|
||||||
});
|
});
|
||||||
onClose();
|
onClose();
|
||||||
|
|
||||||
navigate({
|
navigate({
|
||||||
to: "/organization/projects",
|
to: "/organization/projects",
|
||||||
search: (prev) => ({ ...prev, subOrganization: organization.name })
|
search: (prev) => ({ ...prev, subOrganization: organization.name })
|
||||||
});
|
});
|
||||||
await router.invalidate({ sync: true }).catch(() => null);
|
await router.invalidate({ sync: true }).catch(() => null);
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to create sub organization",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|||||||
import { Link, linkOptions } from "@tanstack/react-router";
|
import { Link, linkOptions } from "@tanstack/react-router";
|
||||||
|
|
||||||
import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal";
|
import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal";
|
||||||
import { createNotification } from "@app/components/notifications";
|
|
||||||
import { OrgPermissionCan } from "@app/components/permissions";
|
import { OrgPermissionCan } from "@app/components/permissions";
|
||||||
import { NewProjectModal } from "@app/components/projects";
|
import { NewProjectModal } from "@app/components/projects";
|
||||||
import {
|
import {
|
||||||
@@ -59,31 +58,17 @@ export const ProjectSelect = () => {
|
|||||||
const { mutateAsync: updateUserProjectFavorites } = useUpdateUserProjectFavorites();
|
const { mutateAsync: updateUserProjectFavorites } = useUpdateUserProjectFavorites();
|
||||||
|
|
||||||
const addProjectToFavorites = async (projectId: string) => {
|
const addProjectToFavorites = async (projectId: string) => {
|
||||||
try {
|
await updateUserProjectFavorites({
|
||||||
await updateUserProjectFavorites({
|
orgId: currentOrg!.id,
|
||||||
orgId: currentOrg!.id,
|
projectFavorites: [...(projectFavorites || []), projectId]
|
||||||
projectFavorites: [...(projectFavorites || []), projectId]
|
});
|
||||||
});
|
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to add project to favorites.",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const removeProjectFromFavorites = async (projectId: string) => {
|
const removeProjectFromFavorites = async (projectId: string) => {
|
||||||
try {
|
await updateUserProjectFavorites({
|
||||||
await updateUserProjectFavorites({
|
orgId: currentOrg!.id,
|
||||||
orgId: currentOrg!.id,
|
projectFavorites: [...(projectFavorites || []).filter((entry) => entry !== projectId)]
|
||||||
projectFavorites: [...(projectFavorites || []).filter((entry) => entry !== projectId)]
|
});
|
||||||
});
|
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to remove project from favorites.",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const isAddingProjectsAllowed = subscription?.workspaceLimit
|
const isAddingProjectsAllowed = subscription?.workspaceLimit
|
||||||
|
|||||||
@@ -65,20 +65,13 @@ const Content = ({ onClose }: ContentProps) => {
|
|||||||
const users = usersData.filter((user) => !user.superAdmin);
|
const users = usersData.filter((user) => !user.superAdmin);
|
||||||
|
|
||||||
const onSubmit = async ({ user }: FormData) => {
|
const onSubmit = async ({ user }: FormData) => {
|
||||||
try {
|
await grantAdmin.mutateAsync(user.id);
|
||||||
await grantAdmin.mutateAsync(user.id);
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
type: "success",
|
type: "success",
|
||||||
text: "Successfully granted server admin status"
|
text: "Successfully granted server admin status"
|
||||||
});
|
});
|
||||||
onClose();
|
onClose();
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to grant server admin status",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -303,18 +303,11 @@ export const ServerAdminsTable = () => {
|
|||||||
const handleRemoveUser = async () => {
|
const handleRemoveUser = async () => {
|
||||||
const { id } = popUp?.removeUser?.data as { id: string; username: string };
|
const { id } = popUp?.removeUser?.data as { id: string; username: string };
|
||||||
|
|
||||||
try {
|
await deleteUser(id);
|
||||||
await deleteUser(id);
|
createNotification({
|
||||||
createNotification({
|
type: "success",
|
||||||
type: "success",
|
text: "Successfully deleted user"
|
||||||
text: "Successfully deleted user"
|
});
|
||||||
});
|
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
type: "error",
|
|
||||||
text: "Error deleting user"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
handlePopUpClose("removeUser");
|
handlePopUpClose("removeUser");
|
||||||
};
|
};
|
||||||
@@ -322,39 +315,25 @@ export const ServerAdminsTable = () => {
|
|||||||
const handleRemoveServerAdminAccess = async () => {
|
const handleRemoveServerAdminAccess = async () => {
|
||||||
const { id } = popUp?.removeServerAdmin?.data as { id: string; username: string };
|
const { id } = popUp?.removeServerAdmin?.data as { id: string; username: string };
|
||||||
|
|
||||||
try {
|
await removeAdminAccess(id);
|
||||||
await removeAdminAccess(id);
|
createNotification({
|
||||||
createNotification({
|
type: "success",
|
||||||
type: "success",
|
text: "Successfully removed server admin access from user"
|
||||||
text: "Successfully removed server admin access from user"
|
});
|
||||||
});
|
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
type: "error",
|
|
||||||
text: "Error removing server admin access from user"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
handlePopUpClose("removeServerAdmin");
|
handlePopUpClose("removeServerAdmin");
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleRemoveUsers = async () => {
|
const handleRemoveUsers = async () => {
|
||||||
try {
|
await deleteUsers(selectedUsers.map((user) => user.id));
|
||||||
await deleteUsers(selectedUsers.map((user) => user.id));
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully removed users",
|
text: "Successfully removed users",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
setSelectedUsers([]);
|
setSelectedUsers([]);
|
||||||
handlePopUpClose("removeUsers");
|
handlePopUpClose("removeUsers");
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to remove users",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -54,59 +54,51 @@ export const AuthenticationPageForm = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const onAuthFormSubmit = async (formData: TAuthForm) => {
|
const onAuthFormSubmit = async (formData: TAuthForm) => {
|
||||||
try {
|
const enabledMethods: LoginMethod[] = [];
|
||||||
const enabledMethods: LoginMethod[] = [];
|
if (formData.isEmailEnabled) {
|
||||||
if (formData.isEmailEnabled) {
|
enabledMethods.push(LoginMethod.EMAIL);
|
||||||
enabledMethods.push(LoginMethod.EMAIL);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (formData.isGoogleEnabled) {
|
if (formData.isGoogleEnabled) {
|
||||||
enabledMethods.push(LoginMethod.GOOGLE);
|
enabledMethods.push(LoginMethod.GOOGLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (formData.isGithubEnabled) {
|
if (formData.isGithubEnabled) {
|
||||||
enabledMethods.push(LoginMethod.GITHUB);
|
enabledMethods.push(LoginMethod.GITHUB);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (formData.isGitlabEnabled) {
|
if (formData.isGitlabEnabled) {
|
||||||
enabledMethods.push(LoginMethod.GITLAB);
|
enabledMethods.push(LoginMethod.GITLAB);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (formData.isSamlEnabled) {
|
if (formData.isSamlEnabled) {
|
||||||
enabledMethods.push(LoginMethod.SAML);
|
enabledMethods.push(LoginMethod.SAML);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (formData.isLdapEnabled) {
|
if (formData.isLdapEnabled) {
|
||||||
enabledMethods.push(LoginMethod.LDAP);
|
enabledMethods.push(LoginMethod.LDAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (formData.isOidcEnabled) {
|
if (formData.isOidcEnabled) {
|
||||||
enabledMethods.push(LoginMethod.OIDC);
|
enabledMethods.push(LoginMethod.OIDC);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!enabledMethods.length) {
|
if (!enabledMethods.length) {
|
||||||
createNotification({
|
|
||||||
type: "error",
|
|
||||||
text: "At least one login method should be enabled."
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await updateServerConfig({
|
|
||||||
enabledLoginMethods: enabledMethods
|
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: "Login methods have been successfully updated.",
|
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
createNotification({
|
createNotification({
|
||||||
type: "error",
|
type: "error",
|
||||||
text: "Failed to update login methods."
|
text: "At least one login method should be enabled."
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await updateServerConfig({
|
||||||
|
enabledLoginMethods: enabledMethods
|
||||||
|
});
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: "Login methods have been successfully updated.",
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -31,15 +31,10 @@ export const CachingPageForm = () => {
|
|||||||
const handleInvalidateCacheSubmit = async () => {
|
const handleInvalidateCacheSubmit = async () => {
|
||||||
if (!type || isInvalidating) return;
|
if (!type || isInvalidating) return;
|
||||||
|
|
||||||
try {
|
await invalidateCache({ type });
|
||||||
await invalidateCache({ type });
|
createNotification({ text: `Began invalidating ${type} cache`, type: "success" });
|
||||||
createNotification({ text: `Began invalidating ${type} cache`, type: "success" });
|
setShouldPoll(true);
|
||||||
setShouldPoll(true);
|
handlePopUpClose("invalidateCache");
|
||||||
handlePopUpClose("invalidateCache");
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({ text: `Failed to invalidate ${type} cache`, type: "error" });
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -60,19 +60,12 @@ export const EncryptionPageForm = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
await updateEncryptionStrategy(formData.encryptionStrategy);
|
||||||
await updateEncryptionStrategy(formData.encryptionStrategy);
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
type: "success",
|
type: "success",
|
||||||
text: "Encryption strategy updated successfully"
|
text: "Encryption strategy updated successfully"
|
||||||
});
|
});
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
type: "error",
|
|
||||||
text: "Failed to update encryption strategy"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -176,31 +176,19 @@ export const EnvironmentPageForm = () => {
|
|||||||
|
|
||||||
const onSubmit = useCallback(
|
const onSubmit = useCallback(
|
||||||
async (formData: TForm) => {
|
async (formData: TForm) => {
|
||||||
try {
|
const filteredFormData = Object.fromEntries(
|
||||||
const filteredFormData = Object.fromEntries(
|
Object.entries(formData).filter(([, value]) => value !== "")
|
||||||
Object.entries(formData).filter(([, value]) => value !== "")
|
);
|
||||||
);
|
await updateServerConfig({
|
||||||
await updateServerConfig({
|
envOverrides: filteredFormData
|
||||||
envOverrides: filteredFormData
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
type: "success",
|
type: "success",
|
||||||
text: "Environment overrides updated successfully. It can take up to 5 minutes to take effect."
|
text: "Environment overrides updated successfully. It can take up to 5 minutes to take effect."
|
||||||
});
|
});
|
||||||
|
|
||||||
reset(formData);
|
reset(formData);
|
||||||
} catch (error) {
|
|
||||||
const errorMessage =
|
|
||||||
(error as any)?.response?.data?.message ||
|
|
||||||
(error as any)?.message ||
|
|
||||||
"An unknown error occurred";
|
|
||||||
createNotification({
|
|
||||||
type: "error",
|
|
||||||
title: "Failed to update environment overrides",
|
|
||||||
text: errorMessage
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
[reset, updateServerConfig]
|
[reset, updateServerConfig]
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -68,37 +68,29 @@ export const GeneralPageForm = () => {
|
|||||||
const organizations = useGetOrganizations();
|
const organizations = useGetOrganizations();
|
||||||
|
|
||||||
const onFormSubmit = async (formData: TDashboardForm) => {
|
const onFormSubmit = async (formData: TDashboardForm) => {
|
||||||
try {
|
const {
|
||||||
const {
|
allowedSignUpDomain,
|
||||||
allowedSignUpDomain,
|
trustSamlEmails,
|
||||||
trustSamlEmails,
|
trustLdapEmails,
|
||||||
trustLdapEmails,
|
trustOidcEmails,
|
||||||
trustOidcEmails,
|
authConsentContent,
|
||||||
authConsentContent,
|
pageFrameContent
|
||||||
pageFrameContent
|
} = formData;
|
||||||
} = formData;
|
|
||||||
|
|
||||||
await updateServerConfig({
|
await updateServerConfig({
|
||||||
defaultAuthOrgId: defaultAuthOrgId || null,
|
defaultAuthOrgId: defaultAuthOrgId || null,
|
||||||
allowSignUp: signUpMode !== SignUpModes.Disabled,
|
allowSignUp: signUpMode !== SignUpModes.Disabled,
|
||||||
allowedSignUpDomain: signUpMode === SignUpModes.Anyone ? allowedSignUpDomain : null,
|
allowedSignUpDomain: signUpMode === SignUpModes.Anyone ? allowedSignUpDomain : null,
|
||||||
trustSamlEmails,
|
trustSamlEmails,
|
||||||
trustLdapEmails,
|
trustLdapEmails,
|
||||||
trustOidcEmails,
|
trustOidcEmails,
|
||||||
authConsentContent,
|
authConsentContent,
|
||||||
pageFrameContent
|
pageFrameContent
|
||||||
});
|
});
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully changed sign up setting.",
|
text: "Successfully changed sign up setting.",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
createNotification({
|
|
||||||
type: "error",
|
|
||||||
text: "Failed to update sign up setting."
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -10,23 +10,15 @@ export const UsageReportSection = () => {
|
|||||||
const generateUsageReport = useGenerateUsageReport();
|
const generateUsageReport = useGenerateUsageReport();
|
||||||
|
|
||||||
const handleGenerateReport = async () => {
|
const handleGenerateReport = async () => {
|
||||||
try {
|
const response = await generateUsageReport.mutateAsync();
|
||||||
const response = await generateUsageReport.mutateAsync();
|
const { csvContent, filename } = response;
|
||||||
const { csvContent, filename } = response;
|
|
||||||
|
|
||||||
downloadFile(csvContent, filename, "text/csv");
|
downloadFile(csvContent, filename, "text/csv");
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Usage report downloaded: "${filename}"`,
|
text: `Usage report downloaded: "${filename}"`,
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
} catch (error) {
|
|
||||||
console.error("Failed to generate usage report:", error);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to generate usage report. Please try again.",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -81,25 +81,18 @@ const Content = ({ onClose }: ContentProps) => {
|
|||||||
const { users = [] } = data ?? {};
|
const { users = [] } = data ?? {};
|
||||||
|
|
||||||
const onSubmit = async ({ name, invitees }: FormData) => {
|
const onSubmit = async ({ name, invitees }: FormData) => {
|
||||||
try {
|
await createOrg.mutateAsync({
|
||||||
await createOrg.mutateAsync({
|
name,
|
||||||
name,
|
inviteAdminEmails: invitees
|
||||||
inviteAdminEmails: invitees
|
.filter((user) => Boolean(user.email))
|
||||||
.filter((user) => Boolean(user.email))
|
.map((user) => user.email) as string[]
|
||||||
.map((user) => user.email) as string[]
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
type: "success",
|
type: "success",
|
||||||
text: "Successfully created organization"
|
text: "Successfully created organization"
|
||||||
});
|
});
|
||||||
onClose();
|
onClose();
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to create organization",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const { append } = useFieldArray<FormData>({ control, name: "invitees" });
|
const { append } = useFieldArray<FormData>({ control, name: "invitees" });
|
||||||
|
|||||||
+5
-12
@@ -185,18 +185,11 @@ export const MachineIdentitiesTable = () => {
|
|||||||
const handleRemoveServerAdmin = async () => {
|
const handleRemoveServerAdmin = async () => {
|
||||||
const { id } = popUp?.removeServerAdmin?.data as { id: string; name: string };
|
const { id } = popUp?.removeServerAdmin?.data as { id: string; name: string };
|
||||||
|
|
||||||
try {
|
await deleteIdentitySuperAdminAccess(id);
|
||||||
await deleteIdentitySuperAdminAccess(id);
|
createNotification({
|
||||||
createNotification({
|
type: "success",
|
||||||
type: "success",
|
text: "Successfully removed server admin permissions"
|
||||||
text: "Successfully removed server admin permissions"
|
});
|
||||||
});
|
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
type: "error",
|
|
||||||
text: "Error removing server admin permissions"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
handlePopUpClose("removeServerAdmin");
|
handlePopUpClose("removeServerAdmin");
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -179,12 +179,6 @@ const ViewMembersModalContent = ({
|
|||||||
text: "Successfully resent org invitation",
|
text: "Successfully resent org invitation",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to resend org invitation",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
} finally {
|
} finally {
|
||||||
setResendInviteId(null);
|
setResendInviteId(null);
|
||||||
}
|
}
|
||||||
@@ -479,26 +473,19 @@ const OrganizationsPanelTable = ({
|
|||||||
const { mutateAsync: accessOrganization } = useServerAdminAccessOrg();
|
const { mutateAsync: accessOrganization } = useServerAdminAccessOrg();
|
||||||
|
|
||||||
const handleAccessOrg = async (orgId: string) => {
|
const handleAccessOrg = async (orgId: string) => {
|
||||||
try {
|
await accessOrganization(orgId);
|
||||||
await accessOrganization(orgId);
|
|
||||||
|
|
||||||
navigate({
|
navigate({
|
||||||
to: "/login/select-organization",
|
to: "/login/select-organization",
|
||||||
search: {
|
search: {
|
||||||
org_id: orgId
|
org_id: orgId
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully joined organization",
|
text: "Successfully joined organization",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to join organization",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -364,18 +364,11 @@ export const UserIdentitiesTable = () => {
|
|||||||
const handleRemoveUser = async () => {
|
const handleRemoveUser = async () => {
|
||||||
const { id } = popUp?.removeUser?.data as { id: string; username: string };
|
const { id } = popUp?.removeUser?.data as { id: string; username: string };
|
||||||
|
|
||||||
try {
|
await deleteUser(id);
|
||||||
await deleteUser(id);
|
createNotification({
|
||||||
createNotification({
|
type: "success",
|
||||||
type: "success",
|
text: "Successfully deleted user"
|
||||||
text: "Successfully deleted user"
|
});
|
||||||
});
|
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
type: "error",
|
|
||||||
text: "Error deleting user"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
handlePopUpClose("removeUser");
|
handlePopUpClose("removeUser");
|
||||||
};
|
};
|
||||||
@@ -383,18 +376,11 @@ export const UserIdentitiesTable = () => {
|
|||||||
const handleGrantServerAdminAccess = async () => {
|
const handleGrantServerAdminAccess = async () => {
|
||||||
const { id } = popUp?.upgradeToServerAdmin?.data as { id: string; username: string };
|
const { id } = popUp?.upgradeToServerAdmin?.data as { id: string; username: string };
|
||||||
|
|
||||||
try {
|
await grantAdminAccess(id);
|
||||||
await grantAdminAccess(id);
|
createNotification({
|
||||||
createNotification({
|
type: "success",
|
||||||
type: "success",
|
text: "Successfully granted server admin access to user"
|
||||||
text: "Successfully granted server admin access to user"
|
});
|
||||||
});
|
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
type: "error",
|
|
||||||
text: "Error granting server admin access to user"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
handlePopUpClose("upgradeToServerAdmin");
|
handlePopUpClose("upgradeToServerAdmin");
|
||||||
};
|
};
|
||||||
@@ -402,39 +388,25 @@ export const UserIdentitiesTable = () => {
|
|||||||
const handleRemoveServerAdminAccess = async () => {
|
const handleRemoveServerAdminAccess = async () => {
|
||||||
const { id } = popUp?.removeServerAdmin?.data as { id: string; username: string };
|
const { id } = popUp?.removeServerAdmin?.data as { id: string; username: string };
|
||||||
|
|
||||||
try {
|
await removeAdminAccess(id);
|
||||||
await removeAdminAccess(id);
|
createNotification({
|
||||||
createNotification({
|
type: "success",
|
||||||
type: "success",
|
text: "Successfully removed server admin access from user"
|
||||||
text: "Successfully removed server admin access from user"
|
});
|
||||||
});
|
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
type: "error",
|
|
||||||
text: "Error removing server admin access from user"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
handlePopUpClose("removeServerAdmin");
|
handlePopUpClose("removeServerAdmin");
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleRemoveUsers = async () => {
|
const handleRemoveUsers = async () => {
|
||||||
try {
|
await deleteUsers(selectedUsers.map((user) => user.id));
|
||||||
await deleteUsers(selectedUsers.map((user) => user.id));
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully removed users",
|
text: "Successfully removed users",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
setSelectedUsers([]);
|
setSelectedUsers([]);
|
||||||
handlePopUpClose("removeUsers");
|
handlePopUpClose("removeUsers");
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to remove users",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import { useNavigate } from "@tanstack/react-router";
|
|||||||
import { AnimatePresence, motion } from "framer-motion";
|
import { AnimatePresence, motion } from "framer-motion";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
import { createNotification } from "@app/components/notifications";
|
|
||||||
// TODO(akhilmhdh): rewrite this into module functions in lib
|
// TODO(akhilmhdh): rewrite this into module functions in lib
|
||||||
import SecurityClient from "@app/components/utilities/SecurityClient";
|
import SecurityClient from "@app/components/utilities/SecurityClient";
|
||||||
import { Button, ContentLoader, FormControl, Input } from "@app/components/v2";
|
import { Button, ContentLoader, FormControl, Input } from "@app/components/v2";
|
||||||
@@ -46,29 +45,21 @@ export const SignUpPage = () => {
|
|||||||
const handleFormSubmit = async ({ email, password, firstName, lastName }: TFormSchema) => {
|
const handleFormSubmit = async ({ email, password, firstName, lastName }: TFormSchema) => {
|
||||||
// avoid multi submission
|
// avoid multi submission
|
||||||
if (isSubmitting) return;
|
if (isSubmitting) return;
|
||||||
try {
|
const res = await createAdminUser({
|
||||||
const res = await createAdminUser({
|
email,
|
||||||
email,
|
password,
|
||||||
password,
|
firstName,
|
||||||
firstName,
|
lastName
|
||||||
lastName
|
});
|
||||||
});
|
|
||||||
|
|
||||||
SecurityClient.setToken(res.token);
|
SecurityClient.setToken(res.token);
|
||||||
await selectOrganization({ organizationId: res.organization.id });
|
await selectOrganization({ organizationId: res.organization.id });
|
||||||
|
|
||||||
// TODO(akhilmhdh): This is such a confusing pattern and too unreliable
|
// TODO(akhilmhdh): This is such a confusing pattern and too unreliable
|
||||||
// Will be refactored in next iteration to make it url based rather than local storage ones
|
// Will be refactored in next iteration to make it url based rather than local storage ones
|
||||||
// Part of migration to nextjs 14
|
// Part of migration to nextjs 14
|
||||||
localStorage.setItem("orgData.id", res.organization.id);
|
localStorage.setItem("orgData.id", res.organization.id);
|
||||||
navigate({ to: "/admin" });
|
navigate({ to: "/admin" });
|
||||||
} catch (err) {
|
|
||||||
console.log(err);
|
|
||||||
createNotification({
|
|
||||||
type: "error",
|
|
||||||
text: "Failed to create admin"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (config?.initialized) return <ContentLoader text="Redirecting to admin page..." />;
|
if (config?.initialized) return <ContentLoader text="Redirecting to admin page..." />;
|
||||||
|
|||||||
@@ -75,11 +75,7 @@ export const PasswordSetupPage = () => {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
window.location.href = "/login";
|
window.location.href = "/login";
|
||||||
}, 3000);
|
}, 3000);
|
||||||
} catch (error) {
|
} catch {
|
||||||
createNotification({
|
|
||||||
type: "error",
|
|
||||||
text: (error as Error).message ?? "Error setting password"
|
|
||||||
});
|
|
||||||
navigate({ to: "/personal-settings" });
|
navigate({ to: "/personal-settings" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+34
-48
@@ -73,67 +73,53 @@ export const EmailConfirmationStep = ({
|
|||||||
const { mutateAsync: verifyEmailVerificationCode } = useVerifyEmailVerificationCode();
|
const { mutateAsync: verifyEmailVerificationCode } = useVerifyEmailVerificationCode();
|
||||||
|
|
||||||
const checkCode = async () => {
|
const checkCode = async () => {
|
||||||
try {
|
await verifyEmailVerificationCode({ username, code });
|
||||||
await verifyEmailVerificationCode({ username, code });
|
setCodeError(false);
|
||||||
setCodeError(false);
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully verified code",
|
text: "Successfully verified code",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
switch (authType) {
|
switch (authType) {
|
||||||
case UserAliasType.SAML: {
|
case UserAliasType.SAML: {
|
||||||
window.open(`/api/v1/sso/redirect/saml2/organizations/${organizationSlug}`);
|
window.open(`/api/v1/sso/redirect/saml2/organizations/${organizationSlug}`);
|
||||||
window.close();
|
window.close();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case UserAliasType.LDAP: {
|
case UserAliasType.LDAP: {
|
||||||
navigate({ to: "/login/ldap", search: { organizationSlug } });
|
navigate({ to: "/login/ldap", search: { organizationSlug } });
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case UserAliasType.OIDC: {
|
case UserAliasType.OIDC: {
|
||||||
window.open(`/api/v1/sso/oidc/login?orgSlug=${organizationSlug}`);
|
window.open(`/api/v1/sso/oidc/login?orgSlug=${organizationSlug}`);
|
||||||
window.close();
|
window.close();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
setStep(1);
|
setStep(1);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to verify code",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setCode("");
|
setCode("");
|
||||||
};
|
};
|
||||||
|
|
||||||
const resendCode = async () => {
|
const resendCode = async () => {
|
||||||
try {
|
const queryParams = new URLSearchParams(window.location.search);
|
||||||
const queryParams = new URLSearchParams(window.location.search);
|
const token = queryParams.get("token");
|
||||||
const token = queryParams.get("token");
|
if (!token) {
|
||||||
if (!token) {
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to resend code, no token found",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await sendEmailVerificationCode(token);
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully resent code",
|
text: "Failed to resend code, no token found",
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to resend code",
|
|
||||||
type: "error"
|
type: "error"
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
await sendEmailVerificationCode(token);
|
||||||
|
createNotification({
|
||||||
|
text: "Successfully resent code",
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -113,52 +113,44 @@ export const PkiAlertModal = ({ popUp, handlePopUpToggle }: Props) => {
|
|||||||
alertUnit,
|
alertUnit,
|
||||||
emails
|
emails
|
||||||
}: FormData) => {
|
}: FormData) => {
|
||||||
try {
|
if (!projectId) return;
|
||||||
if (!projectId) return;
|
|
||||||
|
|
||||||
const emailArray = emails
|
const emailArray = emails
|
||||||
.split(",")
|
.split(",")
|
||||||
.map((email) => email.trim())
|
.map((email) => email.trim())
|
||||||
.filter((email) => email.length > 0);
|
.filter((email) => email.length > 0);
|
||||||
|
|
||||||
const alertBeforeDays = convertToDays(alertUnit, Number(alertBefore));
|
const alertBeforeDays = convertToDays(alertUnit, Number(alertBefore));
|
||||||
|
|
||||||
if (alert) {
|
if (alert) {
|
||||||
// update
|
// update
|
||||||
await updatePkiAlert({
|
await updatePkiAlert({
|
||||||
alertId: alert.id,
|
alertId: alert.id,
|
||||||
pkiCollectionId,
|
pkiCollectionId,
|
||||||
name,
|
name,
|
||||||
projectId,
|
projectId,
|
||||||
alertBeforeDays,
|
alertBeforeDays,
|
||||||
emails: emailArray
|
emails: emailArray
|
||||||
});
|
|
||||||
} else {
|
|
||||||
// create
|
|
||||||
await createPkiAlert({
|
|
||||||
name,
|
|
||||||
projectId,
|
|
||||||
pkiCollectionId,
|
|
||||||
alertBeforeDays,
|
|
||||||
emails: emailArray
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
handlePopUpToggle("pkiAlert", false);
|
|
||||||
|
|
||||||
reset();
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: `Successfully ${alert ? "updated" : "created"} alert`,
|
|
||||||
type: "success"
|
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} else {
|
||||||
console.error(err);
|
// create
|
||||||
createNotification({
|
await createPkiAlert({
|
||||||
text: `Failed to ${alert ? "updated" : "created"} alert`,
|
name,
|
||||||
type: "error"
|
projectId,
|
||||||
|
pkiCollectionId,
|
||||||
|
alertBeforeDays,
|
||||||
|
emails: emailArray
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handlePopUpToggle("pkiAlert", false);
|
||||||
|
|
||||||
|
reset();
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: `Successfully ${alert ? "updated" : "created"} alert`,
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -22,27 +22,19 @@ export const PkiAlertsSection = () => {
|
|||||||
] as const);
|
] as const);
|
||||||
|
|
||||||
const onRemoveAlertSubmit = async (alertId: string) => {
|
const onRemoveAlertSubmit = async (alertId: string) => {
|
||||||
try {
|
if (!projectId) return;
|
||||||
if (!projectId) return;
|
|
||||||
|
|
||||||
await deletePkiAlert({
|
await deletePkiAlert({
|
||||||
alertId,
|
alertId,
|
||||||
projectId
|
projectId
|
||||||
});
|
});
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully deleted alert",
|
text: "Successfully deleted alert",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
handlePopUpClose("deletePkiAlert");
|
handlePopUpClose("deletePkiAlert");
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to delete alert",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -62,49 +62,41 @@ export const PkiCollectionModal = ({ popUp, handlePopUpToggle }: Props) => {
|
|||||||
}, [pkiCollection]);
|
}, [pkiCollection]);
|
||||||
|
|
||||||
const onFormSubmit = async ({ name, description }: FormData) => {
|
const onFormSubmit = async ({ name, description }: FormData) => {
|
||||||
try {
|
if (!projectId) return;
|
||||||
if (!projectId) return;
|
|
||||||
|
|
||||||
if (pkiCollection) {
|
if (pkiCollection) {
|
||||||
// update
|
// update
|
||||||
await updatePkiCollection({
|
await updatePkiCollection({
|
||||||
collectionId: pkiCollection.id,
|
collectionId: pkiCollection.id,
|
||||||
name,
|
name,
|
||||||
description,
|
description,
|
||||||
projectId
|
projectId
|
||||||
});
|
|
||||||
} else {
|
|
||||||
// create
|
|
||||||
const { id: collectionId } = await createPkiCollection({
|
|
||||||
name,
|
|
||||||
description,
|
|
||||||
projectId
|
|
||||||
});
|
|
||||||
|
|
||||||
navigate({
|
|
||||||
to: "/projects/cert-management/$projectId/pki-collections/$collectionId",
|
|
||||||
params: {
|
|
||||||
projectId,
|
|
||||||
collectionId
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
handlePopUpToggle("pkiCollection", false);
|
|
||||||
|
|
||||||
reset();
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: `Successfully ${pkiCollection ? "updated" : "created"} PKI collection`,
|
|
||||||
type: "success"
|
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} else {
|
||||||
console.error(err);
|
// create
|
||||||
createNotification({
|
const { id: collectionId } = await createPkiCollection({
|
||||||
text: `Failed to ${pkiCollection ? "updated" : "created"} PKI collection`,
|
name,
|
||||||
type: "error"
|
description,
|
||||||
|
projectId
|
||||||
|
});
|
||||||
|
|
||||||
|
navigate({
|
||||||
|
to: "/projects/cert-management/$projectId/pki-collections/$collectionId",
|
||||||
|
params: {
|
||||||
|
projectId,
|
||||||
|
collectionId
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handlePopUpToggle("pkiCollection", false);
|
||||||
|
|
||||||
|
reset();
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: `Successfully ${pkiCollection ? "updated" : "created"} PKI collection`,
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -22,27 +22,19 @@ export const PkiCollectionSection = () => {
|
|||||||
] as const);
|
] as const);
|
||||||
|
|
||||||
const onRemovePkiCollectionSubmit = async (collectionId: string) => {
|
const onRemovePkiCollectionSubmit = async (collectionId: string) => {
|
||||||
try {
|
if (!projectId) return;
|
||||||
if (!projectId) return;
|
|
||||||
|
|
||||||
await deletePkiCollection({
|
await deletePkiCollection({
|
||||||
collectionId,
|
collectionId,
|
||||||
projectId
|
projectId
|
||||||
});
|
});
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully deleted PKI collection",
|
text: "Successfully deleted PKI collection",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
handlePopUpClose("deletePkiCollection");
|
handlePopUpClose("deletePkiCollection");
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to delete PKI collection",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+17
-24
@@ -57,33 +57,26 @@ const Page = () => {
|
|||||||
] as const);
|
] as const);
|
||||||
|
|
||||||
const onRemoveCaSubmit = async () => {
|
const onRemoveCaSubmit = async () => {
|
||||||
try {
|
if (!currentProject?.slug) return;
|
||||||
if (!currentProject?.slug) return;
|
|
||||||
|
|
||||||
await deleteCa({
|
await deleteCa({
|
||||||
caName,
|
caName,
|
||||||
projectId: currentProject.id,
|
projectId: currentProject.id,
|
||||||
type: CaType.INTERNAL
|
type: CaType.INTERNAL
|
||||||
});
|
});
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully deleted CA",
|
text: "Successfully deleted CA",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
handlePopUpClose("deleteCa");
|
handlePopUpClose("deleteCa");
|
||||||
navigate({
|
navigate({
|
||||||
to: "/projects/cert-management/$projectId/certificate-authorities",
|
to: "/projects/cert-management/$projectId/certificate-authorities",
|
||||||
params: {
|
params: {
|
||||||
projectId
|
projectId
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to delete CA",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+13
-17
@@ -84,27 +84,23 @@ export const CaRenewalModal = ({ popUp, handlePopUpToggle }: Props) => {
|
|||||||
// }, [ca, parentCa]);
|
// }, [ca, parentCa]);
|
||||||
|
|
||||||
const onFormSubmit = async ({ type, notAfter }: FormData) => {
|
const onFormSubmit = async ({ type, notAfter }: FormData) => {
|
||||||
try {
|
if (!projectSlug || !popUpData.caId) return;
|
||||||
if (!projectSlug || !popUpData.caId) return;
|
|
||||||
|
|
||||||
await renewCa({
|
await renewCa({
|
||||||
projectSlug,
|
projectSlug,
|
||||||
caId: popUpData.caId,
|
caId: popUpData.caId,
|
||||||
notAfter,
|
notAfter,
|
||||||
type
|
type
|
||||||
});
|
});
|
||||||
|
|
||||||
handlePopUpToggle("renewCa", false);
|
handlePopUpToggle("renewCa", false);
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully renewed CA",
|
text: "Successfully renewed CA",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+13
-20
@@ -48,29 +48,22 @@ export const ExternalCaInstallForm = ({ caId, handlePopUpToggle }: Props) => {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const onFormSubmit = async ({ certificate, certificateChain }: FormData) => {
|
const onFormSubmit = async ({ certificate, certificateChain }: FormData) => {
|
||||||
try {
|
if (!csr || !caId || !currentProject?.slug) return;
|
||||||
if (!csr || !caId || !currentProject?.slug) return;
|
|
||||||
|
|
||||||
await importCaCertificate({
|
await importCaCertificate({
|
||||||
caId,
|
caId,
|
||||||
projectSlug: currentProject?.slug,
|
projectSlug: currentProject?.slug,
|
||||||
certificate,
|
certificate,
|
||||||
certificateChain
|
certificateChain
|
||||||
});
|
});
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully installed certificate for CA",
|
text: "Successfully installed certificate for CA",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
handlePopUpToggle("installCaCert", false);
|
handlePopUpToggle("installCaCert", false);
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to install certificate for CA",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const downloadTxtFile = (filename: string, content: string) => {
|
const downloadTxtFile = (filename: string, content: string) => {
|
||||||
|
|||||||
+20
-27
@@ -101,37 +101,30 @@ export const InternalCaInstallForm = ({ caId, handlePopUpToggle }: Props) => {
|
|||||||
}, [parentCa]);
|
}, [parentCa]);
|
||||||
|
|
||||||
const onFormSubmit = async ({ notAfter, maxPathLength }: FormData) => {
|
const onFormSubmit = async ({ notAfter, maxPathLength }: FormData) => {
|
||||||
try {
|
if (!csr || !caId || !currentProject?.slug) return;
|
||||||
if (!csr || !caId || !currentProject?.slug) return;
|
|
||||||
|
|
||||||
const { certificate, certificateChain } = await signIntermediate({
|
const { certificate, certificateChain } = await signIntermediate({
|
||||||
caId: parentCaId,
|
caId: parentCaId,
|
||||||
csr,
|
csr,
|
||||||
maxPathLength: Number(maxPathLength),
|
maxPathLength: Number(maxPathLength),
|
||||||
notAfter,
|
notAfter,
|
||||||
notBefore: new Date().toISOString()
|
notBefore: new Date().toISOString()
|
||||||
});
|
});
|
||||||
|
|
||||||
await importCaCertificate({
|
await importCaCertificate({
|
||||||
caId,
|
caId,
|
||||||
projectSlug: currentProject?.slug,
|
projectSlug: currentProject?.slug,
|
||||||
certificate,
|
certificate,
|
||||||
certificateChain
|
certificateChain
|
||||||
});
|
});
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully installed certificate for CA",
|
text: "Successfully installed certificate for CA",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
handlePopUpToggle("installCaCert", false);
|
handlePopUpToggle("installCaCert", false);
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to install certificate for CA",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function generatePathLengthOpts(parentCaMaxPathLength: number): number[] {
|
function generatePathLengthOpts(parentCaMaxPathLength: number): number[] {
|
||||||
|
|||||||
@@ -175,48 +175,40 @@ export const CaModal = ({ popUp, handlePopUpToggle }: Props) => {
|
|||||||
status,
|
status,
|
||||||
configuration
|
configuration
|
||||||
}: FormData) => {
|
}: FormData) => {
|
||||||
try {
|
if (!currentProject?.slug) return;
|
||||||
if (!currentProject?.slug) return;
|
|
||||||
|
|
||||||
if (ca) {
|
if (ca) {
|
||||||
// update
|
// update
|
||||||
await updateMutateAsync({
|
await updateMutateAsync({
|
||||||
caName: ca.name,
|
caName: ca.name,
|
||||||
projectId: currentProject.id,
|
projectId: currentProject.id,
|
||||||
name,
|
name,
|
||||||
type: CaType.INTERNAL,
|
type: CaType.INTERNAL,
|
||||||
status,
|
status,
|
||||||
enableDirectIssuance
|
enableDirectIssuance
|
||||||
});
|
|
||||||
} else {
|
|
||||||
// create
|
|
||||||
await createMutateAsync({
|
|
||||||
projectId: currentProject.id,
|
|
||||||
name,
|
|
||||||
type,
|
|
||||||
status,
|
|
||||||
enableDirectIssuance,
|
|
||||||
configuration: {
|
|
||||||
...configuration,
|
|
||||||
maxPathLength: Number(configuration.maxPathLength)
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
reset();
|
|
||||||
handlePopUpToggle("ca", false);
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: `Successfully ${ca ? "updated" : "created"} CA`,
|
|
||||||
type: "success"
|
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} else {
|
||||||
console.error(err);
|
// create
|
||||||
createNotification({
|
await createMutateAsync({
|
||||||
text: "Failed to create CA",
|
projectId: currentProject.id,
|
||||||
type: "error"
|
name,
|
||||||
|
type,
|
||||||
|
status,
|
||||||
|
enableDirectIssuance,
|
||||||
|
configuration: {
|
||||||
|
...configuration,
|
||||||
|
maxPathLength: Number(configuration.maxPathLength)
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reset();
|
||||||
|
handlePopUpToggle("ca", false);
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: `Successfully ${ca ? "updated" : "created"} CA`,
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+14
-29
@@ -27,44 +27,29 @@ export const CaSection = () => {
|
|||||||
] as const);
|
] as const);
|
||||||
|
|
||||||
const onRemoveCaSubmit = async (caName: string) => {
|
const onRemoveCaSubmit = async (caName: string) => {
|
||||||
try {
|
if (!currentProject?.slug) return;
|
||||||
if (!currentProject?.slug) return;
|
|
||||||
|
|
||||||
await deleteCa({ caName, projectId: currentProject.id, type: CaType.INTERNAL });
|
await deleteCa({ caName, projectId: currentProject.id, type: CaType.INTERNAL });
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully deleted CA",
|
text: "Successfully deleted CA",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
handlePopUpClose("deleteCa");
|
handlePopUpClose("deleteCa");
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to delete CA",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const onUpdateCaStatus = async ({ caName, status }: { caName: string; status: CaStatus }) => {
|
const onUpdateCaStatus = async ({ caName, status }: { caName: string; status: CaStatus }) => {
|
||||||
try {
|
if (!currentProject?.slug) return;
|
||||||
if (!currentProject?.slug) return;
|
|
||||||
|
|
||||||
await updateCa({ caName, projectId: currentProject.id, type: CaType.INTERNAL, status });
|
await updateCa({ caName, projectId: currentProject.id, type: CaType.INTERNAL, status });
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Successfully ${status === CaStatus.ACTIVE ? "enabled" : "disabled"} CA`,
|
text: `Successfully ${status === CaStatus.ACTIVE ? "enabled" : "disabled"} CA`,
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
handlePopUpClose("caStatus");
|
handlePopUpClose("caStatus");
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: `Failed to ${status === CaStatus.ACTIVE ? "enabled" : "disabled"} CA`,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+43
-51
@@ -297,63 +297,55 @@ export const ExternalCaModal = ({ popUp, handlePopUpToggle }: Props) => {
|
|||||||
status,
|
status,
|
||||||
configuration: formConfiguration
|
configuration: formConfiguration
|
||||||
}: FormData) => {
|
}: FormData) => {
|
||||||
try {
|
if (!currentProject?.slug) return;
|
||||||
if (!currentProject?.slug) return;
|
|
||||||
|
|
||||||
let configPayload: any;
|
let configPayload: any;
|
||||||
|
|
||||||
if (type === CaType.ACME && "dnsAppConnection" in formConfiguration) {
|
if (type === CaType.ACME && "dnsAppConnection" in formConfiguration) {
|
||||||
configPayload = {
|
configPayload = {
|
||||||
dnsProviderConfig: formConfiguration.dnsProviderConfig,
|
dnsProviderConfig: formConfiguration.dnsProviderConfig,
|
||||||
directoryUrl: formConfiguration.directoryUrl,
|
directoryUrl: formConfiguration.directoryUrl,
|
||||||
accountEmail: formConfiguration.accountEmail,
|
accountEmail: formConfiguration.accountEmail,
|
||||||
dnsAppConnectionId: formConfiguration.dnsAppConnection.id,
|
dnsAppConnectionId: formConfiguration.dnsAppConnection.id,
|
||||||
eabKid: formConfiguration.eabKid,
|
eabKid: formConfiguration.eabKid,
|
||||||
eabHmacKey: formConfiguration.eabHmacKey
|
eabHmacKey: formConfiguration.eabHmacKey
|
||||||
};
|
};
|
||||||
} else if (type === CaType.AZURE_AD_CS && "azureAdcsConnection" in formConfiguration) {
|
} else if (type === CaType.AZURE_AD_CS && "azureAdcsConnection" in formConfiguration) {
|
||||||
configPayload = {
|
configPayload = {
|
||||||
azureAdcsConnectionId: formConfiguration.azureAdcsConnection.id
|
azureAdcsConnectionId: formConfiguration.azureAdcsConnection.id
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
throw new Error("Invalid certificate authority configuration");
|
throw new Error("Invalid certificate authority configuration");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ca) {
|
if (ca) {
|
||||||
await updateMutateAsync({
|
await updateMutateAsync({
|
||||||
caName: ca.name,
|
caName: ca.name,
|
||||||
projectId: currentProject.id,
|
projectId: currentProject.id,
|
||||||
name,
|
name,
|
||||||
type,
|
type,
|
||||||
status,
|
status,
|
||||||
enableDirectIssuance: type === CaType.AZURE_AD_CS ? false : enableDirectIssuance,
|
enableDirectIssuance: type === CaType.AZURE_AD_CS ? false : enableDirectIssuance,
|
||||||
configuration: configPayload
|
configuration: configPayload
|
||||||
});
|
|
||||||
} else {
|
|
||||||
await createMutateAsync({
|
|
||||||
projectId: currentProject.id,
|
|
||||||
name,
|
|
||||||
type,
|
|
||||||
status,
|
|
||||||
enableDirectIssuance: type === CaType.AZURE_AD_CS ? false : enableDirectIssuance,
|
|
||||||
configuration: configPayload
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
reset();
|
|
||||||
handlePopUpToggle("ca", false);
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: `Successfully ${ca ? "updated" : "created"} CA`,
|
|
||||||
type: "success"
|
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} else {
|
||||||
console.error(err);
|
await createMutateAsync({
|
||||||
createNotification({
|
projectId: currentProject.id,
|
||||||
text: "Failed to create CA",
|
name,
|
||||||
type: "error"
|
type,
|
||||||
|
status,
|
||||||
|
enableDirectIssuance: type === CaType.AZURE_AD_CS ? false : enableDirectIssuance,
|
||||||
|
configuration: configPayload
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reset();
|
||||||
|
handlePopUpToggle("ca", false);
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: `Successfully ${ca ? "updated" : "created"} CA`,
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+14
-29
@@ -23,23 +23,16 @@ export const ExternalCaSection = () => {
|
|||||||
] as const);
|
] as const);
|
||||||
|
|
||||||
const onRemoveCaSubmit = async (caName: string, type: CaType) => {
|
const onRemoveCaSubmit = async (caName: string, type: CaType) => {
|
||||||
try {
|
if (!currentProject?.id) return;
|
||||||
if (!currentProject?.id) return;
|
|
||||||
|
|
||||||
await deleteCa({ caName, type, projectId: currentProject.id });
|
await deleteCa({ caName, type, projectId: currentProject.id });
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully deleted CA",
|
text: "Successfully deleted CA",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
handlePopUpClose("deleteCa");
|
handlePopUpClose("deleteCa");
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to delete CA",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const onUpdateCaStatus = async ({
|
const onUpdateCaStatus = async ({
|
||||||
@@ -51,24 +44,16 @@ export const ExternalCaSection = () => {
|
|||||||
type: CaType;
|
type: CaType;
|
||||||
status: CaStatus;
|
status: CaStatus;
|
||||||
}) => {
|
}) => {
|
||||||
try {
|
if (!currentProject?.slug) return;
|
||||||
if (!currentProject?.slug) return;
|
|
||||||
|
|
||||||
await updateCa({ caName: name, type, status, projectId: currentProject.id });
|
await updateCa({ caName: name, type, status, projectId: currentProject.id });
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Successfully ${status === CaStatus.ACTIVE ? "enabled" : "disabled"} CA`,
|
text: `Successfully ${status === CaStatus.ACTIVE ? "enabled" : "disabled"} CA`,
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
handlePopUpClose("caStatus");
|
handlePopUpClose("caStatus");
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: `Failed to ${status === CaStatus.ACTIVE ? "enable" : "disable"} CA`,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+19
-27
@@ -71,38 +71,30 @@ export const CertificateImportModal = ({ popUp, handlePopUpToggle }: Props) => {
|
|||||||
chainPem,
|
chainPem,
|
||||||
collectionId
|
collectionId
|
||||||
}: FormData) => {
|
}: FormData) => {
|
||||||
try {
|
if (!currentProject?.slug) return;
|
||||||
if (!currentProject?.slug) return;
|
|
||||||
|
|
||||||
const { serialNumber, certificate, certificateChain, privateKey } = await importCertificate({
|
const { serialNumber, certificate, certificateChain, privateKey } = await importCertificate({
|
||||||
projectSlug: currentProject.slug,
|
projectSlug: currentProject.slug,
|
||||||
|
|
||||||
certificatePem,
|
certificatePem,
|
||||||
privateKeyPem,
|
privateKeyPem,
|
||||||
chainPem,
|
chainPem,
|
||||||
pkiCollectionId: collectionId
|
pkiCollectionId: collectionId
|
||||||
});
|
});
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
setCertificateDetails({
|
setCertificateDetails({
|
||||||
serialNumber,
|
serialNumber,
|
||||||
certificate,
|
certificate,
|
||||||
certificateChain,
|
certificateChain,
|
||||||
privateKey
|
privateKey
|
||||||
});
|
});
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully imported certificate",
|
text: "Successfully imported certificate",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to import certificate",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+62
-74
@@ -243,84 +243,72 @@ export const CertificateIssuanceModal = ({ popUp, handlePopUpToggle, profileId }
|
|||||||
keyUsages,
|
keyUsages,
|
||||||
extendedKeyUsages
|
extendedKeyUsages
|
||||||
}: FormData) => {
|
}: FormData) => {
|
||||||
try {
|
if (!currentProject?.slug) {
|
||||||
if (!currentProject?.slug) {
|
|
||||||
createNotification({
|
|
||||||
text: "Project not found. Please refresh and try again.",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!formProfileId) {
|
|
||||||
createNotification({
|
|
||||||
text: "Please select a certificate profile.",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let commonName = "";
|
|
||||||
if (
|
|
||||||
constraints.shouldShowSubjectSection &&
|
|
||||||
subjectAttributes &&
|
|
||||||
subjectAttributes.length > 0
|
|
||||||
) {
|
|
||||||
commonName = getAttributeValue(subjectAttributes, "common_name");
|
|
||||||
if (!commonName.trim()) {
|
|
||||||
createNotification({
|
|
||||||
text: "Common name is required.",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const certificateRequest: any = {
|
|
||||||
profileId: formProfileId,
|
|
||||||
projectSlug: currentProject.slug,
|
|
||||||
ttl,
|
|
||||||
signatureAlgorithm,
|
|
||||||
keyAlgorithm,
|
|
||||||
keyUsages: filterUsages(keyUsages) as CertKeyUsage[],
|
|
||||||
extendedKeyUsages: filterUsages(extendedKeyUsages) as CertExtendedKeyUsage[]
|
|
||||||
};
|
|
||||||
|
|
||||||
if (constraints.shouldShowSubjectSection && commonName) {
|
|
||||||
certificateRequest.commonName = commonName;
|
|
||||||
}
|
|
||||||
if (constraints.shouldShowSanSection && subjectAltNames && subjectAltNames.length > 0) {
|
|
||||||
const formattedSans = formatSubjectAltNames(subjectAltNames);
|
|
||||||
if (formattedSans && formattedSans.length > 0) {
|
|
||||||
certificateRequest.altNames = formattedSans;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const { serialNumber, certificate, certificateChain, privateKey } =
|
|
||||||
await createCertificate(certificateRequest);
|
|
||||||
|
|
||||||
setCertificateDetails({
|
|
||||||
serialNumber,
|
|
||||||
certificate,
|
|
||||||
certificateChain,
|
|
||||||
privateKey
|
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully created certificate",
|
text: "Project not found. Please refresh and try again.",
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
console.error("Certificate creation failed:", err);
|
|
||||||
const errorMessage =
|
|
||||||
err instanceof Error
|
|
||||||
? err.message
|
|
||||||
: "An unexpected error occurred while creating the certificate";
|
|
||||||
createNotification({
|
|
||||||
text: `Failed to create certificate: ${errorMessage}`,
|
|
||||||
type: "error"
|
type: "error"
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!formProfileId) {
|
||||||
|
createNotification({
|
||||||
|
text: "Please select a certificate profile.",
|
||||||
|
type: "error"
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let commonName = "";
|
||||||
|
if (
|
||||||
|
constraints.shouldShowSubjectSection &&
|
||||||
|
subjectAttributes &&
|
||||||
|
subjectAttributes.length > 0
|
||||||
|
) {
|
||||||
|
commonName = getAttributeValue(subjectAttributes, "common_name");
|
||||||
|
if (!commonName.trim()) {
|
||||||
|
createNotification({
|
||||||
|
text: "Common name is required.",
|
||||||
|
type: "error"
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const certificateRequest: any = {
|
||||||
|
profileId: formProfileId,
|
||||||
|
projectSlug: currentProject.slug,
|
||||||
|
ttl,
|
||||||
|
signatureAlgorithm,
|
||||||
|
keyAlgorithm,
|
||||||
|
keyUsages: filterUsages(keyUsages) as CertKeyUsage[],
|
||||||
|
extendedKeyUsages: filterUsages(extendedKeyUsages) as CertExtendedKeyUsage[]
|
||||||
|
};
|
||||||
|
|
||||||
|
if (constraints.shouldShowSubjectSection && commonName) {
|
||||||
|
certificateRequest.commonName = commonName;
|
||||||
|
}
|
||||||
|
if (constraints.shouldShowSanSection && subjectAltNames && subjectAltNames.length > 0) {
|
||||||
|
const formattedSans = formatSubjectAltNames(subjectAltNames);
|
||||||
|
if (formattedSans && formattedSans.length > 0) {
|
||||||
|
certificateRequest.altNames = formattedSans;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const { serialNumber, certificate, certificateChain, privateKey } =
|
||||||
|
await createCertificate(certificateRequest);
|
||||||
|
|
||||||
|
setCertificateDetails({
|
||||||
|
serialNumber,
|
||||||
|
certificate,
|
||||||
|
certificateChain,
|
||||||
|
privateKey
|
||||||
|
});
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: "Successfully created certificate",
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
currentProject?.slug,
|
currentProject?.slug,
|
||||||
|
|||||||
+18
-28
@@ -163,38 +163,28 @@ export const CertificateManageRenewalModal = ({ popUp, handlePopUpToggle }: Prop
|
|||||||
}, [popUp.manageRenewal.isOpen, defaultRenewalDays, reset]);
|
}, [popUp.manageRenewal.isOpen, defaultRenewalDays, reset]);
|
||||||
|
|
||||||
const onUpdateRenewal = async (data: FormData) => {
|
const onUpdateRenewal = async (data: FormData) => {
|
||||||
try {
|
if (!currentProject?.slug) {
|
||||||
if (!currentProject?.slug) {
|
|
||||||
createNotification({
|
|
||||||
text: "Unable to update auto-renewal: Project not found. Please refresh the page and try again.",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await updateRenewalConfig({
|
|
||||||
certificateId: certificateData.certificateId,
|
|
||||||
renewBeforeDays: data.renewBeforeDays,
|
|
||||||
projectSlug: currentProject.slug
|
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: isAutoRenewalEnabled
|
text: "Unable to update auto-renewal: Project not found. Please refresh the page and try again.",
|
||||||
? "Auto-renewal configuration updated successfully"
|
|
||||||
: "Auto-renewal enabled successfully",
|
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
|
|
||||||
handlePopUpToggle("manageRenewal", false);
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: isAutoRenewalEnabled
|
|
||||||
? "Failed to update auto-renewal configuration. Please check your inputs and try again."
|
|
||||||
: "Failed to enable auto-renewal. Please check your inputs and try again.",
|
|
||||||
type: "error"
|
type: "error"
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await updateRenewalConfig({
|
||||||
|
certificateId: certificateData.certificateId,
|
||||||
|
renewBeforeDays: data.renewBeforeDays,
|
||||||
|
projectSlug: currentProject.slug
|
||||||
|
});
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: isAutoRenewalEnabled
|
||||||
|
? "Auto-renewal configuration updated successfully"
|
||||||
|
: "Auto-renewal enabled successfully",
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
|
|
||||||
|
handlePopUpToggle("manageRenewal", false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getModalTitle = () => {
|
const getModalTitle = () => {
|
||||||
|
|||||||
@@ -186,45 +186,37 @@ export const CertificateModal = ({ popUp, handlePopUpToggle }: Props) => {
|
|||||||
keyUsages,
|
keyUsages,
|
||||||
extendedKeyUsages
|
extendedKeyUsages
|
||||||
}: FormData) => {
|
}: FormData) => {
|
||||||
try {
|
if (!currentProject?.slug) return;
|
||||||
if (!currentProject?.slug) return;
|
|
||||||
|
|
||||||
const { serialNumber, certificate, certificateChain, privateKey } = await createCertificate({
|
const { serialNumber, certificate, certificateChain, privateKey } = await createCertificate({
|
||||||
caId: !selectedCertTemplate ? caId : undefined,
|
caId: !selectedCertTemplate ? caId : undefined,
|
||||||
certificateTemplateId: selectedCertTemplate ? selectedCertTemplateId : undefined,
|
certificateTemplateId: selectedCertTemplate ? selectedCertTemplateId : undefined,
|
||||||
projectSlug: currentProject.slug,
|
projectSlug: currentProject.slug,
|
||||||
pkiCollectionId: collectionId,
|
pkiCollectionId: collectionId,
|
||||||
commonName,
|
commonName,
|
||||||
subjectAltNames,
|
subjectAltNames,
|
||||||
ttl,
|
ttl,
|
||||||
keyUsages: Object.entries(keyUsages)
|
keyUsages: Object.entries(keyUsages)
|
||||||
.filter(([, value]) => value)
|
.filter(([, value]) => value)
|
||||||
.map(([key]) => key as CertKeyUsage),
|
.map(([key]) => key as CertKeyUsage),
|
||||||
extendedKeyUsages: Object.entries(extendedKeyUsages)
|
extendedKeyUsages: Object.entries(extendedKeyUsages)
|
||||||
.filter(([, value]) => value)
|
.filter(([, value]) => value)
|
||||||
.map(([key]) => key as CertExtendedKeyUsage)
|
.map(([key]) => key as CertExtendedKeyUsage)
|
||||||
});
|
});
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
setCertificateDetails({
|
setCertificateDetails({
|
||||||
serialNumber,
|
serialNumber,
|
||||||
certificate,
|
certificate,
|
||||||
certificateChain,
|
certificateChain,
|
||||||
privateKey
|
privateKey
|
||||||
});
|
});
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully created certificate",
|
text: "Successfully created certificate",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to create certificate",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
+16
-24
@@ -61,34 +61,26 @@ export const CertificateRenewalConfigModal = ({ popUp, handlePopUpToggle }: Prop
|
|||||||
const renewBeforeDays = watch("renewBeforeDays");
|
const renewBeforeDays = watch("renewBeforeDays");
|
||||||
|
|
||||||
const onSubmit = async (data: FormData) => {
|
const onSubmit = async (data: FormData) => {
|
||||||
try {
|
if (!currentProject?.slug) {
|
||||||
if (!currentProject?.slug) {
|
|
||||||
createNotification({
|
|
||||||
text: "Project not found",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await updateRenewalConfig({
|
|
||||||
certificateId: certificateData.certificateId,
|
|
||||||
renewBeforeDays: data.renewBeforeDays,
|
|
||||||
projectSlug: currentProject.slug
|
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully updated auto-renewal configuration",
|
text: "Project not found",
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
|
|
||||||
handlePopUpToggle("configureRenewal", false);
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to update auto-renewal configuration",
|
|
||||||
type: "error"
|
type: "error"
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await updateRenewalConfig({
|
||||||
|
certificateId: certificateData.certificateId,
|
||||||
|
renewBeforeDays: data.renewBeforeDays,
|
||||||
|
projectSlug: currentProject.slug
|
||||||
|
});
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: "Successfully updated auto-renewal configuration",
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
|
|
||||||
|
handlePopUpToggle("configureRenewal", false);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+16
-24
@@ -19,34 +19,26 @@ export const CertificateRenewalDisableModal = ({ popUp, handlePopUpToggle }: Pro
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onDisableConfirm = async () => {
|
const onDisableConfirm = async () => {
|
||||||
try {
|
if (!currentProject?.slug) {
|
||||||
if (!currentProject?.slug) {
|
|
||||||
createNotification({
|
|
||||||
text: "Project not found",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await updateRenewalConfig({
|
|
||||||
certificateId: certificateData.certificateId,
|
|
||||||
projectSlug: currentProject.slug,
|
|
||||||
enableAutoRenewal: false
|
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully disabled auto-renewal",
|
text: "Project not found",
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
|
|
||||||
handlePopUpToggle("disableRenewal", false);
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to disable auto-renewal",
|
|
||||||
type: "error"
|
type: "error"
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await updateRenewalConfig({
|
||||||
|
certificateId: certificateData.certificateId,
|
||||||
|
projectSlug: currentProject.slug,
|
||||||
|
enableAutoRenewal: false
|
||||||
|
});
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: "Successfully disabled auto-renewal",
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
|
|
||||||
|
handlePopUpToggle("disableRenewal", false);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+9
-13
@@ -18,22 +18,18 @@ export const CertificateRenewalModal = ({ popUp, handlePopUpToggle }: Props) =>
|
|||||||
const { mutateAsync: renewCertificate, isPending: isRenewing } = useRenewCertificate();
|
const { mutateAsync: renewCertificate, isPending: isRenewing } = useRenewCertificate();
|
||||||
|
|
||||||
const onRenewConfirm = async () => {
|
const onRenewConfirm = async () => {
|
||||||
try {
|
const { certificateId } = popUp.renewCertificate.data as { certificateId: string };
|
||||||
const { certificateId } = popUp.renewCertificate.data as { certificateId: string };
|
|
||||||
|
|
||||||
await renewCertificate({
|
await renewCertificate({
|
||||||
certificateId
|
certificateId
|
||||||
});
|
});
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Certificate renewed successfully",
|
text: "Certificate renewed successfully",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
handlePopUpToggle("renewCertificate", false);
|
handlePopUpToggle("renewCertificate", false);
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const certificateData = popUp.renewCertificate.data as {
|
const certificateData = popUp.renewCertificate.data as {
|
||||||
|
|||||||
+13
-21
@@ -48,31 +48,23 @@ export const CertificateRevocationModal = ({ popUp, handlePopUpToggle }: Props)
|
|||||||
});
|
});
|
||||||
|
|
||||||
const onFormSubmit = async ({ revocationReason }: FormData) => {
|
const onFormSubmit = async ({ revocationReason }: FormData) => {
|
||||||
try {
|
if (!currentProject?.slug) return;
|
||||||
if (!currentProject?.slug) return;
|
|
||||||
|
|
||||||
const { serialNumber } = popUp.revokeCertificate.data as { serialNumber: string };
|
const { serialNumber } = popUp.revokeCertificate.data as { serialNumber: string };
|
||||||
|
|
||||||
await revokeCertificate({
|
await revokeCertificate({
|
||||||
projectSlug: currentProject.slug,
|
projectSlug: currentProject.slug,
|
||||||
serialNumber,
|
serialNumber,
|
||||||
revocationReason
|
revocationReason
|
||||||
});
|
});
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
handlePopUpToggle("revokeCertificate", false);
|
handlePopUpToggle("revokeCertificate", false);
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully revoked certificate",
|
text: "Successfully revoked certificate",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to revoke certificate",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+51
-59
@@ -159,69 +159,61 @@ export const CertificateTemplateModal = ({ popUp, handlePopUpToggle, caId }: Pro
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
if (certTemplate) {
|
||||||
if (certTemplate) {
|
await updateCertTemplate({
|
||||||
await updateCertTemplate({
|
id: certTemplate.id,
|
||||||
id: certTemplate.id,
|
projectId: currentProject.id,
|
||||||
projectId: currentProject.id,
|
pkiCollectionId: collectionId,
|
||||||
pkiCollectionId: collectionId,
|
caId,
|
||||||
caId,
|
name,
|
||||||
name,
|
commonName,
|
||||||
commonName,
|
subjectAlternativeName,
|
||||||
subjectAlternativeName,
|
ttl,
|
||||||
ttl,
|
keyUsages: Object.entries(keyUsages)
|
||||||
keyUsages: Object.entries(keyUsages)
|
.filter(([, value]) => value)
|
||||||
.filter(([, value]) => value)
|
.map(([key]) =>
|
||||||
.map(([key]) =>
|
key === CertKeyUsage.CRL_SIGN
|
||||||
key === CertKeyUsage.CRL_SIGN
|
? "cRLSign"
|
||||||
? "cRLSign"
|
: key.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase())
|
||||||
: key.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase())
|
),
|
||||||
),
|
extendedKeyUsages: Object.entries(extendedKeyUsages)
|
||||||
extendedKeyUsages: Object.entries(extendedKeyUsages)
|
.filter(([, value]) => value)
|
||||||
.filter(([, value]) => value)
|
.map(([key]) => key.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase()))
|
||||||
.map(([key]) => key.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase()))
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: "Successfully updated certificate template",
|
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
await createCertTemplate({
|
|
||||||
projectId: currentProject.id,
|
|
||||||
pkiCollectionId: collectionId,
|
|
||||||
caId,
|
|
||||||
name,
|
|
||||||
commonName,
|
|
||||||
subjectAlternativeName,
|
|
||||||
ttl,
|
|
||||||
keyUsages: Object.entries(keyUsages)
|
|
||||||
.filter(([, value]) => value)
|
|
||||||
.map(([key]) =>
|
|
||||||
key === CertKeyUsage.CRL_SIGN
|
|
||||||
? "cRLSign"
|
|
||||||
: key.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase())
|
|
||||||
),
|
|
||||||
extendedKeyUsages: Object.entries(extendedKeyUsages)
|
|
||||||
.filter(([, value]) => value)
|
|
||||||
.map(([key]) => key.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase()))
|
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: "Successfully created certificate template",
|
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
reset();
|
|
||||||
handlePopUpToggle("certificateTemplate", false);
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Failed to save changes",
|
text: "Successfully updated certificate template",
|
||||||
type: "error"
|
type: "success"
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
await createCertTemplate({
|
||||||
|
projectId: currentProject.id,
|
||||||
|
pkiCollectionId: collectionId,
|
||||||
|
caId,
|
||||||
|
name,
|
||||||
|
commonName,
|
||||||
|
subjectAlternativeName,
|
||||||
|
ttl,
|
||||||
|
keyUsages: Object.entries(keyUsages)
|
||||||
|
.filter(([, value]) => value)
|
||||||
|
.map(([key]) =>
|
||||||
|
key === CertKeyUsage.CRL_SIGN
|
||||||
|
? "cRLSign"
|
||||||
|
: key.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase())
|
||||||
|
),
|
||||||
|
extendedKeyUsages: Object.entries(extendedKeyUsages)
|
||||||
|
.filter(([, value]) => value)
|
||||||
|
.map(([key]) => key.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase()))
|
||||||
|
});
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: "Successfully created certificate template",
|
||||||
|
type: "success"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reset();
|
||||||
|
handlePopUpToggle("certificateTemplate", false);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+9
-17
@@ -41,25 +41,17 @@ export const CertificateTemplatesSection = ({ caId }: Props) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
await deleteCertTemplate({
|
||||||
await deleteCertTemplate({
|
id,
|
||||||
id,
|
projectId: currentProject.id
|
||||||
projectId: currentProject.id
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully deleted certificate template",
|
text: "Successfully deleted certificate template",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
handlePopUpClose("deleteCertificateTemplate");
|
handlePopUpClose("deleteCertificateTemplate");
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to delete certificate template",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+7
-15
@@ -42,24 +42,16 @@ export const CertificatesSection = () => {
|
|||||||
] as const);
|
] as const);
|
||||||
|
|
||||||
const onRemoveCertificateSubmit = async (serialNumber: string) => {
|
const onRemoveCertificateSubmit = async (serialNumber: string) => {
|
||||||
try {
|
if (!currentProject?.slug) return;
|
||||||
if (!currentProject?.slug) return;
|
|
||||||
|
|
||||||
await deleteCert({ serialNumber, projectSlug: currentProject.slug });
|
await deleteCert({ serialNumber, projectSlug: currentProject.slug });
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully deleted certificate",
|
text: "Successfully deleted certificate",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
handlePopUpClose("deleteCertificate");
|
handlePopUpClose("deleteCertificate");
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to delete certificate",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -118,32 +118,24 @@ export const CertificatesTable = ({ handlePopUpOpen }: Props) => {
|
|||||||
}, [caData]);
|
}, [caData]);
|
||||||
|
|
||||||
const handleDisableAutoRenewal = async (certificateId: string, commonName: string) => {
|
const handleDisableAutoRenewal = async (certificateId: string, commonName: string) => {
|
||||||
try {
|
if (!currentProject?.slug) {
|
||||||
if (!currentProject?.slug) {
|
|
||||||
createNotification({
|
|
||||||
text: "Unable to disable auto-renewal: Project not found. Please refresh the page and try again.",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await updateRenewalConfig({
|
|
||||||
certificateId,
|
|
||||||
projectSlug: currentProject.slug,
|
|
||||||
enableAutoRenewal: false
|
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Auto-renewal disabled for ${commonName}`,
|
text: "Unable to disable auto-renewal: Project not found. Please refresh the page and try again.",
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to disable auto-renewal. Please try again or contact support if the issue persists.",
|
|
||||||
type: "error"
|
type: "error"
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await updateRenewalConfig({
|
||||||
|
certificateId,
|
||||||
|
projectSlug: currentProject.slug,
|
||||||
|
enableAutoRenewal: false
|
||||||
|
});
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: `Auto-renewal disabled for ${commonName}`,
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+19
-33
@@ -217,46 +217,32 @@ export const PkiSyncsTable = ({ pkiSyncs }: Props) => {
|
|||||||
|
|
||||||
const isAutoSyncEnabled = !pkiSync.isAutoSyncEnabled;
|
const isAutoSyncEnabled = !pkiSync.isAutoSyncEnabled;
|
||||||
|
|
||||||
try {
|
await updateSync.mutateAsync({
|
||||||
await updateSync.mutateAsync({
|
syncId: pkiSync.id,
|
||||||
syncId: pkiSync.id,
|
projectId: pkiSync.projectId,
|
||||||
projectId: pkiSync.projectId,
|
destination: pkiSync.destination,
|
||||||
destination: pkiSync.destination,
|
isAutoSyncEnabled
|
||||||
isAutoSyncEnabled
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Successfully ${isAutoSyncEnabled ? "enabled" : "disabled"} auto-sync for ${destinationName} Sync`,
|
text: `Successfully ${isAutoSyncEnabled ? "enabled" : "disabled"} auto-sync for ${destinationName} Sync`,
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
text: `Failed to ${isAutoSyncEnabled ? "enable" : "disable"} auto-sync for ${destinationName} Sync`,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleTriggerSync = async (pkiSync: TPkiSync) => {
|
const handleTriggerSync = async (pkiSync: TPkiSync) => {
|
||||||
const destinationName = PKI_SYNC_MAP[pkiSync.destination].name;
|
const destinationName = PKI_SYNC_MAP[pkiSync.destination].name;
|
||||||
|
|
||||||
try {
|
await triggerSync.mutateAsync({
|
||||||
await triggerSync.mutateAsync({
|
syncId: pkiSync.id,
|
||||||
syncId: pkiSync.id,
|
destination: pkiSync.destination,
|
||||||
destination: pkiSync.destination,
|
projectId: pkiSync.projectId
|
||||||
projectId: pkiSync.projectId
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Successfully triggered ${destinationName} Sync`,
|
text: `Successfully triggered ${destinationName} Sync`,
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
text: `Failed to trigger ${destinationName} Sync`,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+16
-23
@@ -45,31 +45,24 @@ export const PkiCollectionPage = () => {
|
|||||||
] as const);
|
] as const);
|
||||||
|
|
||||||
const onDeletePkiCollectionSubmit = async (collectionIdToDelete: string) => {
|
const onDeletePkiCollectionSubmit = async (collectionIdToDelete: string) => {
|
||||||
try {
|
if (!projectId) return;
|
||||||
if (!projectId) return;
|
|
||||||
|
|
||||||
await deletePkiCollection({
|
await deletePkiCollection({
|
||||||
projectId,
|
projectId,
|
||||||
collectionId: collectionIdToDelete
|
collectionId: collectionIdToDelete
|
||||||
});
|
});
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully deleted PKI collection",
|
text: "Successfully deleted PKI collection",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
handlePopUpClose("deletePkiCollection");
|
handlePopUpClose("deletePkiCollection");
|
||||||
navigate({
|
navigate({
|
||||||
to: "/projects/cert-management/$projectId/policies",
|
to: "/projects/cert-management/$projectId/policies",
|
||||||
params: {
|
params: {
|
||||||
projectId: params.projectId
|
projectId: params.projectId
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to delete PKI collection",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+13
-21
@@ -51,30 +51,22 @@ const Page = () => {
|
|||||||
] as const);
|
] as const);
|
||||||
|
|
||||||
const onRemoveSubscriberSubmit = async (subscriberNameToDelete: string) => {
|
const onRemoveSubscriberSubmit = async (subscriberNameToDelete: string) => {
|
||||||
try {
|
if (!projectId) return;
|
||||||
if (!projectId) return;
|
|
||||||
|
|
||||||
await deletePkiSubscriber({ subscriberName: subscriberNameToDelete, projectId });
|
await deletePkiSubscriber({ subscriberName: subscriberNameToDelete, projectId });
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully deleted subscriber",
|
text: "Successfully deleted subscriber",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
handlePopUpClose("deletePkiSubscriber");
|
handlePopUpClose("deletePkiSubscriber");
|
||||||
navigate({
|
navigate({
|
||||||
to: "/projects/cert-management/$projectId/subscribers",
|
to: "/projects/cert-management/$projectId/subscribers",
|
||||||
params: {
|
params: {
|
||||||
projectId
|
projectId
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to delete subscriber",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+18
-26
@@ -70,36 +70,28 @@ export const PkiSubscriberDetailsSection = ({ subscriberName, handlePopUpOpen }:
|
|||||||
useOrderPkiSubscriberCert();
|
useOrderPkiSubscriberCert();
|
||||||
|
|
||||||
const onIssuePkiSubscriberCert = async () => {
|
const onIssuePkiSubscriberCert = async () => {
|
||||||
try {
|
if (pkiSubscriber?.supportsImmediateCertIssuance) {
|
||||||
if (pkiSubscriber?.supportsImmediateCertIssuance) {
|
const response = await issuePkiSubscriberCert({ subscriberName, projectId });
|
||||||
const response = await issuePkiSubscriberCert({ subscriberName, projectId });
|
|
||||||
|
|
||||||
setCertificateDetails({
|
setCertificateDetails({
|
||||||
serialNumber: response.serialNumber,
|
serialNumber: response.serialNumber,
|
||||||
certificate: response.certificate,
|
certificate: response.certificate,
|
||||||
certificateChain: response.certificateChain,
|
certificateChain: response.certificateChain,
|
||||||
privateKey: response.privateKey
|
privateKey: response.privateKey
|
||||||
});
|
});
|
||||||
|
|
||||||
setIsModalOpen(true);
|
setIsModalOpen(true);
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: "Successfully issued certificate",
|
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
await orderPkiSubscriberCert({ subscriberName, projectId });
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: "Successfully ordered certificate. It will be issued after CA processing which could take a few minutes.",
|
|
||||||
type: "info"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Failed to issue certificate",
|
text: "Successfully issued certificate",
|
||||||
type: "error"
|
type: "success"
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
await orderPkiSubscriberCert({ subscriberName, projectId });
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: "Successfully ordered certificate. It will be issued after CA processing which could take a few minutes.",
|
||||||
|
type: "info"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
+110
-118
@@ -276,129 +276,121 @@ export const PkiSubscriberModal = ({ popUp, handlePopUpToggle }: Props) => {
|
|||||||
locality,
|
locality,
|
||||||
emailAddress
|
emailAddress
|
||||||
}: FormData) => {
|
}: FormData) => {
|
||||||
try {
|
if (!projectId) return;
|
||||||
if (!projectId) return;
|
|
||||||
|
|
||||||
if (!caId) {
|
|
||||||
createNotification({
|
|
||||||
text: "Please select an Issuing CA",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if there is already a different subscriber with the same name
|
|
||||||
const existingNames =
|
|
||||||
subscribers?.filter((s) => s.id !== pkiSubscriber?.id).map((s) => s.name) || [];
|
|
||||||
|
|
||||||
if (existingNames.includes(name.trim())) {
|
|
||||||
createNotification({
|
|
||||||
text: "A subscriber with this name already exists.",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate Azure template for Azure ADCS CA
|
|
||||||
if (selectedCa?.type === CaType.AZURE_AD_CS && !azureTemplateType) {
|
|
||||||
createNotification({
|
|
||||||
text: "Please select an Azure certificate template",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const keyUsagesList =
|
|
||||||
selectedCa?.type === CaType.AZURE_AD_CS
|
|
||||||
? []
|
|
||||||
: Object.entries(keyUsages)
|
|
||||||
.filter(([, value]) => value)
|
|
||||||
.map(([key]) => key as CertKeyUsage);
|
|
||||||
|
|
||||||
const extendedKeyUsagesList =
|
|
||||||
selectedCa?.type === CaType.AZURE_AD_CS
|
|
||||||
? []
|
|
||||||
: Object.entries(extendedKeyUsages)
|
|
||||||
.filter(([, value]) => value)
|
|
||||||
.map(([key]) => key as CertExtendedKeyUsage);
|
|
||||||
|
|
||||||
const subjectAlternativeNamesList = subjectAlternativeNames
|
|
||||||
.split(",")
|
|
||||||
.map((san) => san.trim())
|
|
||||||
.filter(Boolean);
|
|
||||||
|
|
||||||
const autoRenewalPeriodInDays = enableAutoRenewal
|
|
||||||
? convertTimeUnitValueToDays(renewalUnit, renewalBefore)
|
|
||||||
: undefined;
|
|
||||||
|
|
||||||
// Build properties object
|
|
||||||
const properties = {
|
|
||||||
...(selectedCa?.type === CaType.AZURE_AD_CS && azureTemplateType && { azureTemplateType }),
|
|
||||||
...(organization && { organization }),
|
|
||||||
...(organizationalUnit && { organizationalUnit }),
|
|
||||||
...(country && { country }),
|
|
||||||
...(state && { state }),
|
|
||||||
...(locality && { locality }),
|
|
||||||
...(emailAddress && { emailAddress })
|
|
||||||
};
|
|
||||||
|
|
||||||
if (pkiSubscriber) {
|
|
||||||
await updateMutateAsync({
|
|
||||||
subscriberName: pkiSubscriber.name,
|
|
||||||
projectId,
|
|
||||||
name,
|
|
||||||
caId,
|
|
||||||
commonName,
|
|
||||||
subjectAlternativeNames: subjectAlternativeNamesList,
|
|
||||||
ttl,
|
|
||||||
keyUsages: keyUsagesList.map((key) =>
|
|
||||||
key === CertKeyUsage.CRL_SIGN
|
|
||||||
? "cRLSign"
|
|
||||||
: key.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase())
|
|
||||||
),
|
|
||||||
extendedKeyUsages: extendedKeyUsagesList.map((key) =>
|
|
||||||
key.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase())
|
|
||||||
),
|
|
||||||
enableAutoRenewal,
|
|
||||||
autoRenewalPeriodInDays,
|
|
||||||
properties: Object.keys(properties).length > 0 ? properties : undefined
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
await createMutateAsync({
|
|
||||||
projectId,
|
|
||||||
name,
|
|
||||||
caId,
|
|
||||||
commonName,
|
|
||||||
subjectAlternativeNames: subjectAlternativeNamesList,
|
|
||||||
ttl,
|
|
||||||
keyUsages: keyUsagesList.map((key) =>
|
|
||||||
key === CertKeyUsage.CRL_SIGN
|
|
||||||
? "cRLSign"
|
|
||||||
: key.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase())
|
|
||||||
),
|
|
||||||
extendedKeyUsages: extendedKeyUsagesList.map((key) =>
|
|
||||||
key.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase())
|
|
||||||
),
|
|
||||||
enableAutoRenewal,
|
|
||||||
autoRenewalPeriodInDays,
|
|
||||||
properties: Object.keys(properties).length > 0 ? properties : undefined
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
reset();
|
|
||||||
handlePopUpToggle("pkiSubscriber", false);
|
|
||||||
|
|
||||||
|
if (!caId) {
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Successfully ${pkiSubscriber ? "updated" : "added"} PKI subscriber`,
|
text: "Please select an Issuing CA",
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: `Failed to ${pkiSubscriber ? "update" : "add"} PKI subscriber`,
|
|
||||||
type: "error"
|
type: "error"
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if there is already a different subscriber with the same name
|
||||||
|
const existingNames =
|
||||||
|
subscribers?.filter((s) => s.id !== pkiSubscriber?.id).map((s) => s.name) || [];
|
||||||
|
|
||||||
|
if (existingNames.includes(name.trim())) {
|
||||||
|
createNotification({
|
||||||
|
text: "A subscriber with this name already exists.",
|
||||||
|
type: "error"
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate Azure template for Azure ADCS CA
|
||||||
|
if (selectedCa?.type === CaType.AZURE_AD_CS && !azureTemplateType) {
|
||||||
|
createNotification({
|
||||||
|
text: "Please select an Azure certificate template",
|
||||||
|
type: "error"
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const keyUsagesList =
|
||||||
|
selectedCa?.type === CaType.AZURE_AD_CS
|
||||||
|
? []
|
||||||
|
: Object.entries(keyUsages)
|
||||||
|
.filter(([, value]) => value)
|
||||||
|
.map(([key]) => key as CertKeyUsage);
|
||||||
|
|
||||||
|
const extendedKeyUsagesList =
|
||||||
|
selectedCa?.type === CaType.AZURE_AD_CS
|
||||||
|
? []
|
||||||
|
: Object.entries(extendedKeyUsages)
|
||||||
|
.filter(([, value]) => value)
|
||||||
|
.map(([key]) => key as CertExtendedKeyUsage);
|
||||||
|
|
||||||
|
const subjectAlternativeNamesList = subjectAlternativeNames
|
||||||
|
.split(",")
|
||||||
|
.map((san) => san.trim())
|
||||||
|
.filter(Boolean);
|
||||||
|
|
||||||
|
const autoRenewalPeriodInDays = enableAutoRenewal
|
||||||
|
? convertTimeUnitValueToDays(renewalUnit, renewalBefore)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
// Build properties object
|
||||||
|
const properties = {
|
||||||
|
...(selectedCa?.type === CaType.AZURE_AD_CS && azureTemplateType && { azureTemplateType }),
|
||||||
|
...(organization && { organization }),
|
||||||
|
...(organizationalUnit && { organizationalUnit }),
|
||||||
|
...(country && { country }),
|
||||||
|
...(state && { state }),
|
||||||
|
...(locality && { locality }),
|
||||||
|
...(emailAddress && { emailAddress })
|
||||||
|
};
|
||||||
|
|
||||||
|
if (pkiSubscriber) {
|
||||||
|
await updateMutateAsync({
|
||||||
|
subscriberName: pkiSubscriber.name,
|
||||||
|
projectId,
|
||||||
|
name,
|
||||||
|
caId,
|
||||||
|
commonName,
|
||||||
|
subjectAlternativeNames: subjectAlternativeNamesList,
|
||||||
|
ttl,
|
||||||
|
keyUsages: keyUsagesList.map((key) =>
|
||||||
|
key === CertKeyUsage.CRL_SIGN
|
||||||
|
? "cRLSign"
|
||||||
|
: key.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase())
|
||||||
|
),
|
||||||
|
extendedKeyUsages: extendedKeyUsagesList.map((key) =>
|
||||||
|
key.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase())
|
||||||
|
),
|
||||||
|
enableAutoRenewal,
|
||||||
|
autoRenewalPeriodInDays,
|
||||||
|
properties: Object.keys(properties).length > 0 ? properties : undefined
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
await createMutateAsync({
|
||||||
|
projectId,
|
||||||
|
name,
|
||||||
|
caId,
|
||||||
|
commonName,
|
||||||
|
subjectAlternativeNames: subjectAlternativeNamesList,
|
||||||
|
ttl,
|
||||||
|
keyUsages: keyUsagesList.map((key) =>
|
||||||
|
key === CertKeyUsage.CRL_SIGN
|
||||||
|
? "cRLSign"
|
||||||
|
: key.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase())
|
||||||
|
),
|
||||||
|
extendedKeyUsages: extendedKeyUsagesList.map((key) =>
|
||||||
|
key.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase())
|
||||||
|
),
|
||||||
|
enableAutoRenewal,
|
||||||
|
autoRenewalPeriodInDays,
|
||||||
|
properties: Object.keys(properties).length > 0 ? properties : undefined
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
reset();
|
||||||
|
handlePopUpToggle("pkiSubscriber", false);
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: `Successfully ${pkiSubscriber ? "updated" : "added"} PKI subscriber`,
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+13
-29
@@ -32,22 +32,14 @@ export const PkiSubscriberSection = () => {
|
|||||||
] as const);
|
] as const);
|
||||||
|
|
||||||
const onRemovePkiSubscriberSubmit = async (subscriberName: string) => {
|
const onRemovePkiSubscriberSubmit = async (subscriberName: string) => {
|
||||||
try {
|
const subscriber = await deletePkiSubscriber({ subscriberName, projectId });
|
||||||
const subscriber = await deletePkiSubscriber({ subscriberName, projectId });
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Successfully deleted PKI subscriber: ${subscriber.name}`,
|
text: `Successfully deleted PKI subscriber: ${subscriber.name}`,
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
handlePopUpClose("deletePkiSubscriber");
|
handlePopUpClose("deletePkiSubscriber");
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to delete PKI subscriber",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const onUpdatePkiSubscriberStatus = async ({
|
const onUpdatePkiSubscriberStatus = async ({
|
||||||
@@ -57,24 +49,16 @@ export const PkiSubscriberSection = () => {
|
|||||||
subscriberName: string;
|
subscriberName: string;
|
||||||
status: PkiSubscriberStatus;
|
status: PkiSubscriberStatus;
|
||||||
}) => {
|
}) => {
|
||||||
try {
|
if (!currentProject?.slug) return;
|
||||||
if (!currentProject?.slug) return;
|
|
||||||
|
|
||||||
await updatePkiSubscriber({ subscriberName, projectId, status });
|
await updatePkiSubscriber({ subscriberName, projectId, status });
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Successfully ${status === PkiSubscriberStatus.ACTIVE ? "enabled" : "disabled"} subscriber`,
|
text: `Successfully ${status === PkiSubscriberStatus.ACTIVE ? "enabled" : "disabled"} subscriber`,
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
handlePopUpClose("pkiSubscriberStatus");
|
handlePopUpClose("pkiSubscriberStatus");
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: `Failed to ${status === PkiSubscriberStatus.ACTIVE ? "enable" : "disable"} subscriber`,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const subscriberStatusData = popUp?.pkiSubscriberStatus?.data as {
|
const subscriberStatusData = popUp?.pkiSubscriberStatus?.data as {
|
||||||
|
|||||||
+19
-35
@@ -86,44 +86,28 @@ export const PkiSyncActionTriggers = ({ pkiSync }: Props) => {
|
|||||||
}, [pkiSync.id, setIsIdCopied]);
|
}, [pkiSync.id, setIsIdCopied]);
|
||||||
|
|
||||||
const handleTriggerSync = useCallback(async () => {
|
const handleTriggerSync = useCallback(async () => {
|
||||||
try {
|
await triggerSyncMutation.mutateAsync({
|
||||||
await triggerSyncMutation.mutateAsync({
|
syncId: id,
|
||||||
syncId: id,
|
destination,
|
||||||
destination,
|
projectId
|
||||||
projectId
|
});
|
||||||
});
|
createNotification({
|
||||||
createNotification({
|
text: "PKI sync job queued successfully",
|
||||||
text: "PKI sync job queued successfully",
|
type: "success"
|
||||||
type: "success"
|
});
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Failed to trigger sync:", error);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to trigger PKI sync",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, [triggerSyncMutation, id, destination, projectId]);
|
}, [triggerSyncMutation, id, destination, projectId]);
|
||||||
|
|
||||||
const handleToggleAutoSync = useCallback(async () => {
|
const handleToggleAutoSync = useCallback(async () => {
|
||||||
try {
|
await updatePkiSyncMutation.mutateAsync({
|
||||||
await updatePkiSyncMutation.mutateAsync({
|
syncId: id,
|
||||||
syncId: id,
|
projectId,
|
||||||
projectId,
|
destination,
|
||||||
destination,
|
isAutoSyncEnabled: !pkiSync.isAutoSyncEnabled
|
||||||
isAutoSyncEnabled: !pkiSync.isAutoSyncEnabled
|
});
|
||||||
});
|
createNotification({
|
||||||
createNotification({
|
text: `Auto-sync ${pkiSync.isAutoSyncEnabled ? "disabled" : "enabled"} successfully`,
|
||||||
text: `Auto-sync ${pkiSync.isAutoSyncEnabled ? "disabled" : "enabled"} successfully`,
|
type: "success"
|
||||||
type: "success"
|
});
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Failed to toggle auto-sync:", error);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to toggle auto-sync",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, [updatePkiSyncMutation, id, projectId, pkiSync.isAutoSyncEnabled]);
|
}, [updatePkiSyncMutation, id, projectId, pkiSync.isAutoSyncEnabled]);
|
||||||
|
|
||||||
const permissionSubject = subject(ProjectPermissionSub.PkiSyncs, {
|
const permissionSubject = subject(ProjectPermissionSub.PkiSyncs, {
|
||||||
|
|||||||
@@ -78,25 +78,17 @@ export const PkiTemplateListPage = () => {
|
|||||||
const deleteCertTemplate = useDeleteCertTemplateV2();
|
const deleteCertTemplate = useDeleteCertTemplateV2();
|
||||||
|
|
||||||
const onRemovePkiSubscriberSubmit = async () => {
|
const onRemovePkiSubscriberSubmit = async () => {
|
||||||
try {
|
const pkiTemplate = await deleteCertTemplate.mutateAsync({
|
||||||
const pkiTemplate = await deleteCertTemplate.mutateAsync({
|
projectId: currentProject.id,
|
||||||
projectId: currentProject.id,
|
templateName: popUp?.deleteTemplate?.data?.name
|
||||||
templateName: popUp?.deleteTemplate?.data?.name
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Successfully deleted PKI template: ${pkiTemplate.name}`,
|
text: `Successfully deleted PKI template: ${pkiTemplate.name}`,
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
handlePopUpClose("deleteTemplate");
|
handlePopUpClose("deleteTemplate");
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to delete PKI subscriber",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+49
-57
@@ -128,67 +128,59 @@ export const PkiTemplateForm = ({ certTemplate, handlePopUpToggle }: Props) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
if (certTemplate) {
|
||||||
if (certTemplate) {
|
await updateCertTemplate({
|
||||||
await updateCertTemplate({
|
templateName: certTemplate.name,
|
||||||
templateName: certTemplate.name,
|
projectId: currentProject.id,
|
||||||
projectId: currentProject.id,
|
caName: ca.name,
|
||||||
caName: ca.name,
|
name,
|
||||||
name,
|
commonName,
|
||||||
commonName,
|
subjectAlternativeName,
|
||||||
subjectAlternativeName,
|
ttl,
|
||||||
ttl,
|
keyUsages: Object.entries(keyUsages)
|
||||||
keyUsages: Object.entries(keyUsages)
|
.filter(([, value]) => value)
|
||||||
.filter(([, value]) => value)
|
.map(([key]) =>
|
||||||
.map(([key]) =>
|
key === CertKeyUsage.CRL_SIGN
|
||||||
key === CertKeyUsage.CRL_SIGN
|
? "cRLSign"
|
||||||
? "cRLSign"
|
: key.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase())
|
||||||
: key.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase())
|
),
|
||||||
),
|
extendedKeyUsages: Object.entries(extendedKeyUsages)
|
||||||
extendedKeyUsages: Object.entries(extendedKeyUsages)
|
.filter(([, value]) => value)
|
||||||
.filter(([, value]) => value)
|
.map(([key]) => key.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase()))
|
||||||
.map(([key]) => key.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase()))
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: "Successfully updated certificate template",
|
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
await createCertTemplate({
|
|
||||||
projectId: currentProject.id,
|
|
||||||
caName: ca.name,
|
|
||||||
name,
|
|
||||||
commonName,
|
|
||||||
subjectAlternativeName,
|
|
||||||
ttl,
|
|
||||||
keyUsages: Object.entries(keyUsages)
|
|
||||||
.filter(([, value]) => value)
|
|
||||||
.map(([key]) =>
|
|
||||||
key === CertKeyUsage.CRL_SIGN
|
|
||||||
? "cRLSign"
|
|
||||||
: key.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase())
|
|
||||||
),
|
|
||||||
extendedKeyUsages: Object.entries(extendedKeyUsages)
|
|
||||||
.filter(([, value]) => value)
|
|
||||||
.map(([key]) => key.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase()))
|
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: "Successfully created certificate template",
|
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
reset();
|
|
||||||
handlePopUpToggle(false);
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Failed to save changes",
|
text: "Successfully updated certificate template",
|
||||||
type: "error"
|
type: "success"
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
await createCertTemplate({
|
||||||
|
projectId: currentProject.id,
|
||||||
|
caName: ca.name,
|
||||||
|
name,
|
||||||
|
commonName,
|
||||||
|
subjectAlternativeName,
|
||||||
|
ttl,
|
||||||
|
keyUsages: Object.entries(keyUsages)
|
||||||
|
.filter(([, value]) => value)
|
||||||
|
.map(([key]) =>
|
||||||
|
key === CertKeyUsage.CRL_SIGN
|
||||||
|
? "cRLSign"
|
||||||
|
: key.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase())
|
||||||
|
),
|
||||||
|
extendedKeyUsages: Object.entries(extendedKeyUsages)
|
||||||
|
.filter(([, value]) => value)
|
||||||
|
.map(([key]) => key.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase()))
|
||||||
|
});
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: "Successfully created certificate template",
|
||||||
|
type: "success"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reset();
|
||||||
|
handlePopUpToggle(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+9
-16
@@ -51,22 +51,15 @@ export const CertificateProfilesTab = () => {
|
|||||||
const handleDeleteConfirm = async () => {
|
const handleDeleteConfirm = async () => {
|
||||||
if (!selectedProfile) return;
|
if (!selectedProfile) return;
|
||||||
|
|
||||||
try {
|
await deleteProfile.mutateAsync({
|
||||||
await deleteProfile.mutateAsync({
|
profileId: selectedProfile.id
|
||||||
profileId: selectedProfile.id
|
});
|
||||||
});
|
setIsDeleteModalOpen(false);
|
||||||
setIsDeleteModalOpen(false);
|
setSelectedProfile(null);
|
||||||
setSelectedProfile(null);
|
createNotification({
|
||||||
createNotification({
|
text: `Certificate profile "${selectedProfile.slug}" deleted successfully`,
|
||||||
text: `Certificate profile "${selectedProfile.slug}" deleted successfully`,
|
type: "success"
|
||||||
type: "success"
|
});
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.error(
|
|
||||||
`Failed to delete profile "${selectedProfile.slug}" (ID: ${selectedProfile.id}):`,
|
|
||||||
error
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+44
-52
@@ -236,64 +236,56 @@ export const CreateProfileModal = ({ isOpen, onClose, profile, mode = "create" }
|
|||||||
}, [isEdit, profile, reset]);
|
}, [isEdit, profile, reset]);
|
||||||
|
|
||||||
const onFormSubmit = async (data: FormData) => {
|
const onFormSubmit = async (data: FormData) => {
|
||||||
try {
|
if (!currentProject?.id && !isEdit) return;
|
||||||
if (!currentProject?.id && !isEdit) return;
|
|
||||||
|
|
||||||
if (isEdit) {
|
if (isEdit) {
|
||||||
const updateData: TUpdateCertificateProfileDTO = {
|
const updateData: TUpdateCertificateProfileDTO = {
|
||||||
profileId: profile.id,
|
profileId: profile.id,
|
||||||
slug: data.slug,
|
slug: data.slug,
|
||||||
description: data.description
|
description: data.description
|
||||||
};
|
};
|
||||||
|
|
||||||
if (data.enrollmentType === "est" && data.estConfig) {
|
if (data.enrollmentType === "est" && data.estConfig) {
|
||||||
updateData.estConfig = data.estConfig;
|
updateData.estConfig = data.estConfig;
|
||||||
} else if (data.enrollmentType === "api" && data.apiConfig) {
|
} else if (data.enrollmentType === "api" && data.apiConfig) {
|
||||||
updateData.apiConfig = data.apiConfig;
|
updateData.apiConfig = data.apiConfig;
|
||||||
}
|
|
||||||
|
|
||||||
await updateProfile.mutateAsync(updateData);
|
|
||||||
} else {
|
|
||||||
if (!currentProject?.id) {
|
|
||||||
throw new Error("Project ID is required for creating a profile");
|
|
||||||
}
|
|
||||||
|
|
||||||
const createData: TCreateCertificateProfileDTO = {
|
|
||||||
projectId: currentProject.id,
|
|
||||||
slug: data.slug,
|
|
||||||
description: data.description,
|
|
||||||
enrollmentType: data.enrollmentType,
|
|
||||||
caId: data.certificateAuthorityId,
|
|
||||||
certificateTemplateId: data.certificateTemplateId
|
|
||||||
};
|
|
||||||
|
|
||||||
if (data.enrollmentType === "est" && data.estConfig) {
|
|
||||||
createData.estConfig = {
|
|
||||||
passphrase: data.estConfig.passphrase,
|
|
||||||
caChain: data.estConfig.caChain || undefined,
|
|
||||||
disableBootstrapCaValidation: data.estConfig.disableBootstrapCaValidation
|
|
||||||
};
|
|
||||||
} else if (data.enrollmentType === "api" && data.apiConfig) {
|
|
||||||
createData.apiConfig = data.apiConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
await createProfile.mutateAsync(createData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
createNotification({
|
await updateProfile.mutateAsync(updateData);
|
||||||
text: `Certificate profile ${isEdit ? "updated" : "created"} successfully`,
|
} else {
|
||||||
type: "success"
|
if (!currentProject?.id) {
|
||||||
});
|
throw new Error("Project ID is required for creating a profile");
|
||||||
|
}
|
||||||
|
|
||||||
reset();
|
const createData: TCreateCertificateProfileDTO = {
|
||||||
onClose();
|
projectId: currentProject.id,
|
||||||
} catch (error) {
|
slug: data.slug,
|
||||||
console.error(`Error ${isEdit ? "updating" : "creating"} profile:`, error);
|
description: data.description,
|
||||||
createNotification({
|
enrollmentType: data.enrollmentType,
|
||||||
text: `Failed to ${isEdit ? "update" : "create"} certificate profile`,
|
caId: data.certificateAuthorityId,
|
||||||
type: "error"
|
certificateTemplateId: data.certificateTemplateId
|
||||||
});
|
};
|
||||||
|
|
||||||
|
if (data.enrollmentType === "est" && data.estConfig) {
|
||||||
|
createData.estConfig = {
|
||||||
|
passphrase: data.estConfig.passphrase,
|
||||||
|
caChain: data.estConfig.caChain || undefined,
|
||||||
|
disableBootstrapCaValidation: data.estConfig.disableBootstrapCaValidation
|
||||||
|
};
|
||||||
|
} else if (data.enrollmentType === "api" && data.apiConfig) {
|
||||||
|
createData.apiConfig = data.apiConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
await createProfile.mutateAsync(createData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: `Certificate profile ${isEdit ? "updated" : "created"} successfully`,
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
|
|
||||||
|
reset();
|
||||||
|
onClose();
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+9
-17
@@ -48,23 +48,15 @@ export const CertificateTemplatesV2Tab = () => {
|
|||||||
const handleDeleteConfirm = async () => {
|
const handleDeleteConfirm = async () => {
|
||||||
if (!selectedTemplate) return;
|
if (!selectedTemplate) return;
|
||||||
|
|
||||||
try {
|
await deleteTemplateV2.mutateAsync({
|
||||||
await deleteTemplateV2.mutateAsync({
|
templateId: selectedTemplate.id
|
||||||
templateId: selectedTemplate.id
|
});
|
||||||
});
|
setIsDeleteModalOpen(false);
|
||||||
setIsDeleteModalOpen(false);
|
setSelectedTemplate(null);
|
||||||
setSelectedTemplate(null);
|
createNotification({
|
||||||
createNotification({
|
text: `Certificate template "${selectedTemplate.name}" deleted successfully`,
|
||||||
text: `Certificate template "${selectedTemplate.name}" deleted successfully`,
|
type: "success"
|
||||||
type: "success"
|
});
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Failed to delete template:", error);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to delete certificate template",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+38
-46
@@ -407,59 +407,51 @@ export const CreateTemplateModal = ({ isOpen, onClose, template, mode = "create"
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onFormSubmit = async (data: FormData) => {
|
const onFormSubmit = async (data: FormData) => {
|
||||||
try {
|
if (!currentProject?.id && !isEdit) return;
|
||||||
if (!currentProject?.id && !isEdit) return;
|
|
||||||
|
|
||||||
const hasEmptyAttributeValues = data.attributes?.some(
|
const hasEmptyAttributeValues = data.attributes?.some(
|
||||||
(attr) => !attr.value || attr.value.length === 0 || attr.value.some((v) => !v.trim())
|
(attr) => !attr.value || attr.value.length === 0 || attr.value.some((v) => !v.trim())
|
||||||
);
|
);
|
||||||
|
|
||||||
const hasEmptySanValues = data.subjectAlternativeNames?.some(
|
const hasEmptySanValues = data.subjectAlternativeNames?.some(
|
||||||
(san) => !san.value || san.value.length === 0 || san.value.some((v) => !v.trim())
|
(san) => !san.value || san.value.length === 0 || san.value.some((v) => !v.trim())
|
||||||
);
|
);
|
||||||
|
|
||||||
if (hasEmptyAttributeValues || hasEmptySanValues) {
|
|
||||||
createNotification({
|
|
||||||
text: "All values must be non-empty. Use wildcards (*) if needed.",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const transformedData = transformToApiFormat(data);
|
|
||||||
|
|
||||||
if (isEdit) {
|
|
||||||
const updateData = {
|
|
||||||
templateId: template.id,
|
|
||||||
...transformedData
|
|
||||||
};
|
|
||||||
await updateTemplate.mutateAsync(updateData);
|
|
||||||
} else {
|
|
||||||
if (!currentProject?.id) {
|
|
||||||
throw new Error("Project ID is required for creating a template");
|
|
||||||
}
|
|
||||||
|
|
||||||
const createData = {
|
|
||||||
projectId: currentProject.id,
|
|
||||||
...transformedData
|
|
||||||
};
|
|
||||||
await createTemplate.mutateAsync(createData);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (hasEmptyAttributeValues || hasEmptySanValues) {
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Certificate template ${isEdit ? "updated" : "created"} successfully`,
|
text: "All values must be non-empty. Use wildcards (*) if needed.",
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
|
|
||||||
reset();
|
|
||||||
onClose();
|
|
||||||
} catch (error) {
|
|
||||||
console.error(`Error ${isEdit ? "updating" : "creating"} template:`, error);
|
|
||||||
createNotification({
|
|
||||||
text: `Failed to ${isEdit ? "update" : "create"} certificate template`,
|
|
||||||
type: "error"
|
type: "error"
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const transformedData = transformToApiFormat(data);
|
||||||
|
|
||||||
|
if (isEdit) {
|
||||||
|
const updateData = {
|
||||||
|
templateId: template.id,
|
||||||
|
...transformedData
|
||||||
|
};
|
||||||
|
await updateTemplate.mutateAsync(updateData);
|
||||||
|
} else {
|
||||||
|
if (!currentProject?.id) {
|
||||||
|
throw new Error("Project ID is required for creating a template");
|
||||||
|
}
|
||||||
|
|
||||||
|
const createData = {
|
||||||
|
projectId: currentProject.id,
|
||||||
|
...transformedData
|
||||||
|
};
|
||||||
|
await createTemplate.mutateAsync(createData);
|
||||||
|
}
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: `Certificate template ${isEdit ? "updated" : "created"} successfully`,
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
|
|
||||||
|
reset();
|
||||||
|
onClose();
|
||||||
};
|
};
|
||||||
|
|
||||||
const addAttribute = () => {
|
const addAttribute = () => {
|
||||||
|
|||||||
@@ -17,28 +17,17 @@ export const DeleteKmipClientModal = ({ isOpen, onOpenChange, kmipClient }: Prop
|
|||||||
const { id, projectId, name } = kmipClient;
|
const { id, projectId, name } = kmipClient;
|
||||||
|
|
||||||
const handleDeleteKmipClient = async () => {
|
const handleDeleteKmipClient = async () => {
|
||||||
try {
|
await deleteKmipClients.mutateAsync({
|
||||||
await deleteKmipClients.mutateAsync({
|
id,
|
||||||
id,
|
projectId
|
||||||
projectId
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "KMIP client successfully deleted",
|
text: "KMIP client successfully deleted",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
onOpenChange(false);
|
onOpenChange(false);
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
const error = err as any;
|
|
||||||
const text = error?.response?.data?.message ?? "Failed to delete KMIP client";
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -98,20 +98,12 @@ const KmipClientForm = ({ onComplete, kmipClient }: FormProps) => {
|
|||||||
.map(([key]) => key as KmipPermission)
|
.map(([key]) => key as KmipPermission)
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
await mutation;
|
||||||
await mutation;
|
createNotification({
|
||||||
createNotification({
|
text: `Successfully ${isUpdate ? "updated" : "added"} KMIP client`,
|
||||||
text: `Successfully ${isUpdate ? "updated" : "added"} KMIP client`,
|
type: "success"
|
||||||
type: "success"
|
});
|
||||||
});
|
onComplete();
|
||||||
onComplete();
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: `Failed to ${isUpdate ? "update" : "add"} KMIP client`,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -52,23 +52,15 @@ const DecryptForm = ({ cmek }: FormProps) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const handleDecryptData = async (formData: FormData) => {
|
const handleDecryptData = async (formData: FormData) => {
|
||||||
try {
|
const data = await cmekDecrypt.mutateAsync({ ...formData, keyId: cmek.id });
|
||||||
const data = await cmekDecrypt.mutateAsync({ ...formData, keyId: cmek.id });
|
createNotification({
|
||||||
createNotification({
|
text: "Successfully decrypted data",
|
||||||
text: "Successfully decrypted data",
|
type: "success"
|
||||||
type: "success"
|
});
|
||||||
});
|
|
||||||
|
|
||||||
setPlaintext(
|
setPlaintext(
|
||||||
shouldDecode ? Buffer.from(decodeBase64(data.plaintext)).toString("utf8") : data.plaintext
|
shouldDecode ? Buffer.from(decodeBase64(data.plaintext)).toString("utf8") : data.plaintext
|
||||||
);
|
);
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to decrypt data",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -53,19 +53,11 @@ const EncryptForm = ({ cmek }: FormProps) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const handleEncryptData = async (formData: FormData) => {
|
const handleEncryptData = async (formData: FormData) => {
|
||||||
try {
|
await cmekEncrypt.mutateAsync({ ...formData, keyId: cmek.id });
|
||||||
await cmekEncrypt.mutateAsync({ ...formData, keyId: cmek.id });
|
createNotification({
|
||||||
createNotification({
|
text: "Successfully encrypted data",
|
||||||
text: "Successfully encrypted data",
|
type: "success"
|
||||||
type: "success"
|
});
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to encrypt data",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const ciphertext = cmekEncrypt.data?.ciphertext;
|
const ciphertext = cmekEncrypt.data?.ciphertext;
|
||||||
|
|||||||
@@ -86,20 +86,12 @@ const CmekForm = ({ onComplete, cmek }: FormProps) => {
|
|||||||
encryptionAlgorithm: encryptionAlgorithm as AsymmetricKeyAlgorithm | SymmetricKeyAlgorithm
|
encryptionAlgorithm: encryptionAlgorithm as AsymmetricKeyAlgorithm | SymmetricKeyAlgorithm
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
await mutation;
|
||||||
await mutation;
|
createNotification({
|
||||||
createNotification({
|
text: `Successfully ${isUpdate ? "updated" : "added"} key`,
|
||||||
text: `Successfully ${isUpdate ? "updated" : "added"} key`,
|
type: "success"
|
||||||
type: "success"
|
});
|
||||||
});
|
onComplete();
|
||||||
onComplete();
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: `Failed to ${isUpdate ? "update" : "add"} key`,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const selectedKeyUsage = watch("keyUsage");
|
const selectedKeyUsage = watch("keyUsage");
|
||||||
|
|||||||
@@ -59,19 +59,11 @@ const SignForm = ({ cmek }: FormProps) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const handleSignData = async (formData: FormData) => {
|
const handleSignData = async (formData: FormData) => {
|
||||||
try {
|
await cmekSign.mutateAsync({ ...formData, keyId: cmek.id });
|
||||||
await cmekSign.mutateAsync({ ...formData, keyId: cmek.id });
|
createNotification({
|
||||||
createNotification({
|
text: "Successfully signed data",
|
||||||
text: "Successfully signed data",
|
type: "success"
|
||||||
type: "success"
|
});
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to sign data",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const signature = cmekSign.data?.signature;
|
const signature = cmekSign.data?.signature;
|
||||||
|
|||||||
@@ -152,28 +152,16 @@ export const CmekTable = () => {
|
|||||||
const updateCmek = useUpdateCmek();
|
const updateCmek = useUpdateCmek();
|
||||||
|
|
||||||
const handleDisableCmek = async ({ id: keyId, isDisabled }: TCmek) => {
|
const handleDisableCmek = async ({ id: keyId, isDisabled }: TCmek) => {
|
||||||
try {
|
await updateCmek.mutateAsync({
|
||||||
await updateCmek.mutateAsync({
|
keyId,
|
||||||
keyId,
|
projectId,
|
||||||
projectId,
|
isDisabled: !isDisabled
|
||||||
isDisabled: !isDisabled
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Key successfully ${isDisabled ? "enabled" : "disabled"}`,
|
text: `Key successfully ${isDisabled ? "enabled" : "disabled"}`,
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
const error = err as any;
|
|
||||||
const text =
|
|
||||||
error?.response?.data?.message ?? `Failed to ${isDisabled ? "enable" : "disable"} key`;
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const cannotEditKey = permission.cannot(
|
const cannotEditKey = permission.cannot(
|
||||||
|
|||||||
@@ -69,25 +69,17 @@ const VerifyForm = ({ cmek }: FormProps) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const handleVerifyData = async (formData: FormData) => {
|
const handleVerifyData = async (formData: FormData) => {
|
||||||
try {
|
const result = await cmekVerify.mutateAsync({ ...formData, keyId: cmek.id });
|
||||||
const result = await cmekVerify.mutateAsync({ ...formData, keyId: cmek.id });
|
|
||||||
|
|
||||||
if (result.signatureValid) {
|
if (result.signatureValid) {
|
||||||
createNotification({
|
|
||||||
text: "Successfully verified signature",
|
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
createNotification({
|
|
||||||
title: "Signature Verification Failed",
|
|
||||||
text: "The signature is invalid. The signature was not created using the same signing algorithm and key as the one used to sign the data. The data and signature may have been tampered with.",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Failed to sign data",
|
text: "Successfully verified signature",
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
createNotification({
|
||||||
|
title: "Signature Verification Failed",
|
||||||
|
text: "The signature is invalid. The signature was not created using the same signing algorithm and key as the one used to sign the data. The data and signature may have been tampered with.",
|
||||||
type: "error"
|
type: "error"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,28 +16,17 @@ export const DeleteCmekModal = ({ isOpen, onOpenChange, cmek }: Props) => {
|
|||||||
const { id: keyId, projectId, name } = cmek;
|
const { id: keyId, projectId, name } = cmek;
|
||||||
|
|
||||||
const handleDeleteCmek = async () => {
|
const handleDeleteCmek = async () => {
|
||||||
try {
|
await deleteCmek.mutateAsync({
|
||||||
await deleteCmek.mutateAsync({
|
keyId,
|
||||||
keyId,
|
projectId
|
||||||
projectId
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Key successfully deleted",
|
text: "Key successfully deleted",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
onOpenChange(false);
|
onOpenChange(false);
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
const error = err as any;
|
|
||||||
const text = error?.response?.data?.message ?? "Failed to delete key";
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+25
-32
@@ -74,43 +74,36 @@ export const OrgGroupModal = ({ popUp, handlePopUpClose, handlePopUpToggle }: Pr
|
|||||||
}, [popUp?.group?.data, roles]);
|
}, [popUp?.group?.data, roles]);
|
||||||
|
|
||||||
const onGroupModalSubmit = async ({ name, slug, role }: TGroupFormData) => {
|
const onGroupModalSubmit = async ({ name, slug, role }: TGroupFormData) => {
|
||||||
try {
|
if (!currentOrg?.id) return;
|
||||||
if (!currentOrg?.id) return;
|
|
||||||
|
|
||||||
const group = popUp?.group?.data as {
|
const group = popUp?.group?.data as {
|
||||||
groupId: string;
|
groupId: string;
|
||||||
name: string;
|
name: string;
|
||||||
slug: string;
|
slug: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (group) {
|
if (group) {
|
||||||
await updateMutateAsync({
|
await updateMutateAsync({
|
||||||
id: group.groupId,
|
id: group.groupId,
|
||||||
name,
|
name,
|
||||||
slug,
|
slug,
|
||||||
role: role.slug || undefined
|
role: role.slug || undefined
|
||||||
});
|
|
||||||
} else {
|
|
||||||
await createMutateAsync({
|
|
||||||
name,
|
|
||||||
slug,
|
|
||||||
organizationId: currentOrg.id,
|
|
||||||
role: role.slug || undefined
|
|
||||||
});
|
|
||||||
}
|
|
||||||
handlePopUpToggle("group", false);
|
|
||||||
reset();
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: `Successfully ${popUp?.group?.data ? "updated" : "created"} group`,
|
|
||||||
type: "success"
|
|
||||||
});
|
});
|
||||||
} catch {
|
} else {
|
||||||
createNotification({
|
await createMutateAsync({
|
||||||
text: `Failed to ${popUp?.group?.data ? "updated" : "created"} group`,
|
name,
|
||||||
type: "error"
|
slug,
|
||||||
|
organizationId: currentOrg.id,
|
||||||
|
role: role.slug || undefined
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
handlePopUpToggle("group", false);
|
||||||
|
reset();
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: `Successfully ${popUp?.group?.data ? "updated" : "created"} group`,
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+7
-15
@@ -36,21 +36,13 @@ export const OrgGroupsSection = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onDeleteGroupSubmit = async ({ name, groupId }: { name: string; groupId: string }) => {
|
const onDeleteGroupSubmit = async ({ name, groupId }: { name: string; groupId: string }) => {
|
||||||
try {
|
await deleteMutateAsync({
|
||||||
await deleteMutateAsync({
|
id: groupId
|
||||||
id: groupId
|
});
|
||||||
});
|
createNotification({
|
||||||
createNotification({
|
text: `Successfully deleted the group named ${name}`,
|
||||||
text: `Successfully deleted the group named ${name}`,
|
type: "success"
|
||||||
type: "success"
|
});
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: `Failed to delete the group named ${name}`,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
handlePopUpClose("deleteGroup");
|
handlePopUpClose("deleteGroup");
|
||||||
};
|
};
|
||||||
|
|||||||
+8
-16
@@ -79,23 +79,15 @@ export const OrgGroupsTable = ({ handlePopUpOpen }: Props) => {
|
|||||||
const { data: roles } = useGetOrgRoles(orgId);
|
const { data: roles } = useGetOrgRoles(orgId);
|
||||||
|
|
||||||
const handleChangeRole = async ({ id, role }: { id: string; role: string }) => {
|
const handleChangeRole = async ({ id, role }: { id: string; role: string }) => {
|
||||||
try {
|
await updateMutateAsync({
|
||||||
await updateMutateAsync({
|
id,
|
||||||
id,
|
role
|
||||||
role
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully updated group role",
|
text: "Successfully updated group role",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
createNotification({
|
|
||||||
text: "Failed to update group role",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
|||||||
+28
-35
@@ -140,45 +140,38 @@ export const IdentityAliCloudAuthForm = ({
|
|||||||
accessTokenNumUsesLimit,
|
accessTokenNumUsesLimit,
|
||||||
accessTokenTrustedIps
|
accessTokenTrustedIps
|
||||||
}: FormData) => {
|
}: FormData) => {
|
||||||
try {
|
if (!identityId) return;
|
||||||
if (!identityId) return;
|
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
await updateMutateAsync({
|
await updateMutateAsync({
|
||||||
organizationId: orgId,
|
organizationId: orgId,
|
||||||
allowedArns,
|
allowedArns,
|
||||||
identityId,
|
identityId,
|
||||||
accessTokenTTL: Number(accessTokenTTL),
|
accessTokenTTL: Number(accessTokenTTL),
|
||||||
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
||||||
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
||||||
accessTokenTrustedIps
|
accessTokenTrustedIps
|
||||||
});
|
|
||||||
} else {
|
|
||||||
await addMutateAsync({
|
|
||||||
organizationId: orgId,
|
|
||||||
identityId,
|
|
||||||
allowedArns,
|
|
||||||
accessTokenTTL: Number(accessTokenTTL),
|
|
||||||
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
|
||||||
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
|
||||||
accessTokenTrustedIps
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
handlePopUpToggle("identityAuthMethod", false);
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
|
|
||||||
type: "success"
|
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
reset();
|
await addMutateAsync({
|
||||||
} catch {
|
organizationId: orgId,
|
||||||
createNotification({
|
identityId,
|
||||||
text: `Failed to ${isUpdate ? "update" : "configure"} identity`,
|
allowedArns,
|
||||||
type: "error"
|
accessTokenTTL: Number(accessTokenTTL),
|
||||||
|
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
||||||
|
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
||||||
|
accessTokenTrustedIps
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handlePopUpToggle("identityAuthMethod", false);
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
|
|
||||||
|
reset();
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+35
-47
@@ -103,56 +103,44 @@ export const IdentityAuthTemplateModal = ({ popUp, handlePopUpToggle }: Props) =
|
|||||||
const selectedMethod = watch("method");
|
const selectedMethod = watch("method");
|
||||||
|
|
||||||
const onFormSubmit = async (data: FormData) => {
|
const onFormSubmit = async (data: FormData) => {
|
||||||
try {
|
if (isEdit && template) {
|
||||||
if (isEdit && template) {
|
await updateTemplate({
|
||||||
await updateTemplate({
|
templateId: template.id,
|
||||||
templateId: template.id,
|
organizationId: orgId,
|
||||||
organizationId: orgId,
|
name: data.name,
|
||||||
name: data.name,
|
templateFields: {
|
||||||
templateFields: {
|
url: data.url,
|
||||||
url: data.url,
|
bindDN: data.bindDN,
|
||||||
bindDN: data.bindDN,
|
bindPass: data.bindPass,
|
||||||
bindPass: data.bindPass,
|
searchBase: data.searchBase,
|
||||||
searchBase: data.searchBase,
|
ldapCaCertificate: data.ldapCaCertificate
|
||||||
ldapCaCertificate: data.ldapCaCertificate
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
createNotification({
|
|
||||||
text: "Successfully updated auth template",
|
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
await createTemplate({
|
|
||||||
organizationId: orgId,
|
|
||||||
name: data.name,
|
|
||||||
authMethod: data.method,
|
|
||||||
templateFields: {
|
|
||||||
url: data.url,
|
|
||||||
bindDN: data.bindDN,
|
|
||||||
bindPass: data.bindPass,
|
|
||||||
searchBase: data.searchBase,
|
|
||||||
ldapCaCertificate: data.ldapCaCertificate
|
|
||||||
}
|
|
||||||
});
|
|
||||||
createNotification({
|
|
||||||
text: "Successfully created auth template",
|
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
handlePopUpToggle(isEdit ? "editTemplate" : "createTemplate", false);
|
|
||||||
reset();
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
const error = err as any;
|
|
||||||
const text =
|
|
||||||
error?.response?.data?.message ?? `Failed to ${isEdit ? "update" : "create"} auth template`;
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text,
|
text: "Successfully updated auth template",
|
||||||
type: "error"
|
type: "success"
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
await createTemplate({
|
||||||
|
organizationId: orgId,
|
||||||
|
name: data.name,
|
||||||
|
authMethod: data.method,
|
||||||
|
templateFields: {
|
||||||
|
url: data.url,
|
||||||
|
bindDN: data.bindDN,
|
||||||
|
bindPass: data.bindPass,
|
||||||
|
searchBase: data.searchBase,
|
||||||
|
ldapCaCertificate: data.ldapCaCertificate
|
||||||
|
}
|
||||||
|
});
|
||||||
|
createNotification({
|
||||||
|
text: "Successfully created auth template",
|
||||||
|
type: "success"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handlePopUpToggle(isEdit ? "editTemplate" : "createTemplate", false);
|
||||||
|
reset();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
|
|||||||
+32
-39
@@ -150,49 +150,42 @@ export const IdentityAwsAuthForm = ({
|
|||||||
accessTokenNumUsesLimit,
|
accessTokenNumUsesLimit,
|
||||||
accessTokenTrustedIps
|
accessTokenTrustedIps
|
||||||
}: FormData) => {
|
}: FormData) => {
|
||||||
try {
|
if (!identityId) return;
|
||||||
if (!identityId) return;
|
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
await updateMutateAsync({
|
await updateMutateAsync({
|
||||||
organizationId: orgId,
|
organizationId: orgId,
|
||||||
stsEndpoint,
|
stsEndpoint,
|
||||||
allowedPrincipalArns,
|
allowedPrincipalArns,
|
||||||
allowedAccountIds,
|
allowedAccountIds,
|
||||||
identityId,
|
identityId,
|
||||||
accessTokenTTL: Number(accessTokenTTL),
|
accessTokenTTL: Number(accessTokenTTL),
|
||||||
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
||||||
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
||||||
accessTokenTrustedIps
|
accessTokenTrustedIps
|
||||||
});
|
|
||||||
} else {
|
|
||||||
await addMutateAsync({
|
|
||||||
organizationId: orgId,
|
|
||||||
identityId,
|
|
||||||
stsEndpoint: stsEndpoint || "",
|
|
||||||
allowedPrincipalArns: allowedPrincipalArns || "",
|
|
||||||
allowedAccountIds: allowedAccountIds || "",
|
|
||||||
accessTokenTTL: Number(accessTokenTTL),
|
|
||||||
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
|
||||||
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
|
||||||
accessTokenTrustedIps
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
handlePopUpToggle("identityAuthMethod", false);
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
|
|
||||||
type: "success"
|
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
reset();
|
await addMutateAsync({
|
||||||
} catch {
|
organizationId: orgId,
|
||||||
createNotification({
|
identityId,
|
||||||
text: `Failed to ${isUpdate ? "update" : "configure"} identity`,
|
stsEndpoint: stsEndpoint || "",
|
||||||
type: "error"
|
allowedPrincipalArns: allowedPrincipalArns || "",
|
||||||
|
allowedAccountIds: allowedAccountIds || "",
|
||||||
|
accessTokenTTL: Number(accessTokenTTL),
|
||||||
|
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
||||||
|
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
||||||
|
accessTokenTrustedIps
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handlePopUpToggle("identityAuthMethod", false);
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
|
|
||||||
|
reset();
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+32
-39
@@ -146,49 +146,42 @@ export const IdentityAzureAuthForm = ({
|
|||||||
accessTokenNumUsesLimit,
|
accessTokenNumUsesLimit,
|
||||||
accessTokenTrustedIps
|
accessTokenTrustedIps
|
||||||
}: FormData) => {
|
}: FormData) => {
|
||||||
try {
|
if (!identityId) return;
|
||||||
if (!identityId) return;
|
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
await updateMutateAsync({
|
await updateMutateAsync({
|
||||||
organizationId: orgId,
|
organizationId: orgId,
|
||||||
identityId,
|
identityId,
|
||||||
tenantId,
|
tenantId,
|
||||||
resource,
|
resource,
|
||||||
allowedServicePrincipalIds,
|
allowedServicePrincipalIds,
|
||||||
accessTokenTTL: Number(accessTokenTTL),
|
accessTokenTTL: Number(accessTokenTTL),
|
||||||
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
||||||
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
||||||
accessTokenTrustedIps
|
accessTokenTrustedIps
|
||||||
});
|
|
||||||
} else {
|
|
||||||
await addMutateAsync({
|
|
||||||
organizationId: orgId,
|
|
||||||
identityId,
|
|
||||||
tenantId: tenantId || "",
|
|
||||||
resource: resource || "",
|
|
||||||
allowedServicePrincipalIds: allowedServicePrincipalIds || "",
|
|
||||||
accessTokenTTL: Number(accessTokenTTL),
|
|
||||||
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
|
||||||
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
|
||||||
accessTokenTrustedIps
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
handlePopUpToggle("identityAuthMethod", false);
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
|
|
||||||
type: "success"
|
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
reset();
|
await addMutateAsync({
|
||||||
} catch {
|
organizationId: orgId,
|
||||||
createNotification({
|
identityId,
|
||||||
text: `Failed to ${isUpdate ? "update" : "configure"} identity`,
|
tenantId: tenantId || "",
|
||||||
type: "error"
|
resource: resource || "",
|
||||||
|
allowedServicePrincipalIds: allowedServicePrincipalIds || "",
|
||||||
|
accessTokenTTL: Number(accessTokenTTL),
|
||||||
|
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
||||||
|
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
||||||
|
accessTokenTrustedIps
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handlePopUpToggle("identityAuthMethod", false);
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
|
|
||||||
|
reset();
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+34
-41
@@ -155,51 +155,44 @@ export const IdentityGcpAuthForm = ({
|
|||||||
accessTokenNumUsesLimit,
|
accessTokenNumUsesLimit,
|
||||||
accessTokenTrustedIps
|
accessTokenTrustedIps
|
||||||
}: FormData) => {
|
}: FormData) => {
|
||||||
try {
|
if (!identityId) return;
|
||||||
if (!identityId) return;
|
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
await updateMutateAsync({
|
await updateMutateAsync({
|
||||||
identityId,
|
identityId,
|
||||||
organizationId: orgId,
|
organizationId: orgId,
|
||||||
type,
|
type,
|
||||||
allowedServiceAccounts,
|
allowedServiceAccounts,
|
||||||
allowedProjects,
|
allowedProjects,
|
||||||
allowedZones,
|
allowedZones,
|
||||||
accessTokenTTL: Number(accessTokenTTL),
|
accessTokenTTL: Number(accessTokenTTL),
|
||||||
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
||||||
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
||||||
accessTokenTrustedIps
|
accessTokenTrustedIps
|
||||||
});
|
|
||||||
} else {
|
|
||||||
await addMutateAsync({
|
|
||||||
identityId,
|
|
||||||
organizationId: orgId,
|
|
||||||
type,
|
|
||||||
allowedServiceAccounts: allowedServiceAccounts || "",
|
|
||||||
allowedProjects: allowedProjects || "",
|
|
||||||
allowedZones: allowedZones || "",
|
|
||||||
accessTokenTTL: Number(accessTokenTTL),
|
|
||||||
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
|
||||||
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
|
||||||
accessTokenTrustedIps
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
handlePopUpToggle("identityAuthMethod", false);
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
|
|
||||||
type: "success"
|
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
reset();
|
await addMutateAsync({
|
||||||
} catch {
|
identityId,
|
||||||
createNotification({
|
organizationId: orgId,
|
||||||
text: `Failed to ${isUpdate ? "update" : "configure"} identity`,
|
type,
|
||||||
type: "error"
|
allowedServiceAccounts: allowedServiceAccounts || "",
|
||||||
|
allowedProjects: allowedProjects || "",
|
||||||
|
allowedZones: allowedZones || "",
|
||||||
|
accessTokenTTL: Number(accessTokenTTL),
|
||||||
|
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
||||||
|
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
||||||
|
accessTokenTrustedIps
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handlePopUpToggle("identityAuthMethod", false);
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
|
|
||||||
|
reset();
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+44
-51
@@ -220,61 +220,54 @@ export const IdentityJwtAuthForm = ({
|
|||||||
boundClaims,
|
boundClaims,
|
||||||
boundSubject
|
boundSubject
|
||||||
}: FormData) => {
|
}: FormData) => {
|
||||||
try {
|
if (!identityId) {
|
||||||
if (!identityId) {
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
await updateMutateAsync({
|
await updateMutateAsync({
|
||||||
identityId,
|
identityId,
|
||||||
organizationId: orgId,
|
organizationId: orgId,
|
||||||
configurationType,
|
configurationType,
|
||||||
jwksUrl,
|
jwksUrl,
|
||||||
jwksCaCert,
|
jwksCaCert,
|
||||||
publicKeys: publicKeys?.map((field) => field.value).filter(Boolean),
|
publicKeys: publicKeys?.map((field) => field.value).filter(Boolean),
|
||||||
boundIssuer,
|
boundIssuer,
|
||||||
boundAudiences,
|
boundAudiences,
|
||||||
boundClaims: Object.fromEntries(boundClaims.map((entry) => [entry.key, entry.value])),
|
boundClaims: Object.fromEntries(boundClaims.map((entry) => [entry.key, entry.value])),
|
||||||
boundSubject,
|
boundSubject,
|
||||||
accessTokenTTL: Number(accessTokenTTL),
|
accessTokenTTL: Number(accessTokenTTL),
|
||||||
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
||||||
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
||||||
accessTokenTrustedIps
|
accessTokenTrustedIps
|
||||||
});
|
|
||||||
} else {
|
|
||||||
await addMutateAsync({
|
|
||||||
identityId,
|
|
||||||
configurationType,
|
|
||||||
jwksUrl,
|
|
||||||
jwksCaCert,
|
|
||||||
publicKeys: publicKeys?.map((field) => field.value).filter(Boolean),
|
|
||||||
boundIssuer,
|
|
||||||
boundAudiences,
|
|
||||||
boundClaims: Object.fromEntries(boundClaims.map((entry) => [entry.key, entry.value])),
|
|
||||||
boundSubject,
|
|
||||||
organizationId: orgId,
|
|
||||||
accessTokenTTL: Number(accessTokenTTL),
|
|
||||||
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
|
||||||
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
|
||||||
accessTokenTrustedIps
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
handlePopUpToggle("identityAuthMethod", false);
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
|
|
||||||
type: "success"
|
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
reset();
|
await addMutateAsync({
|
||||||
} catch {
|
identityId,
|
||||||
createNotification({
|
configurationType,
|
||||||
text: `Failed to ${isUpdate ? "update" : "configure"} identity`,
|
jwksUrl,
|
||||||
type: "error"
|
jwksCaCert,
|
||||||
|
publicKeys: publicKeys?.map((field) => field.value).filter(Boolean),
|
||||||
|
boundIssuer,
|
||||||
|
boundAudiences,
|
||||||
|
boundClaims: Object.fromEntries(boundClaims.map((entry) => [entry.key, entry.value])),
|
||||||
|
boundSubject,
|
||||||
|
organizationId: orgId,
|
||||||
|
accessTokenTTL: Number(accessTokenTTL),
|
||||||
|
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
||||||
|
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
||||||
|
accessTokenTrustedIps
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handlePopUpToggle("identityAuthMethod", false);
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
|
|
||||||
|
reset();
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+54
-61
@@ -314,71 +314,64 @@ export const IdentityKubernetesAuthForm = ({
|
|||||||
tokenReviewMode,
|
tokenReviewMode,
|
||||||
accessTokenTrustedIps
|
accessTokenTrustedIps
|
||||||
}: FormData) => {
|
}: FormData) => {
|
||||||
try {
|
if (!identityId) return;
|
||||||
if (!identityId) return;
|
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
await updateMutateAsync({
|
await updateMutateAsync({
|
||||||
organizationId: orgId,
|
organizationId: orgId,
|
||||||
...(tokenReviewMode === IdentityKubernetesAuthTokenReviewMode.Api
|
...(tokenReviewMode === IdentityKubernetesAuthTokenReviewMode.Api
|
||||||
? {
|
? {
|
||||||
kubernetesHost: kubernetesHost || ""
|
kubernetesHost: kubernetesHost || ""
|
||||||
}
|
}
|
||||||
: {
|
: {
|
||||||
kubernetesHost: null
|
kubernetesHost: null
|
||||||
}),
|
}),
|
||||||
tokenReviewerJwt: tokenReviewerJwt || null,
|
tokenReviewerJwt: tokenReviewerJwt || null,
|
||||||
allowedNames,
|
allowedNames,
|
||||||
allowedNamespaces,
|
allowedNamespaces,
|
||||||
allowedAudience,
|
allowedAudience,
|
||||||
caCert,
|
caCert,
|
||||||
identityId,
|
identityId,
|
||||||
gatewayId: gatewayId || null,
|
gatewayId: gatewayId || null,
|
||||||
tokenReviewMode,
|
tokenReviewMode,
|
||||||
accessTokenTTL: Number(accessTokenTTL),
|
accessTokenTTL: Number(accessTokenTTL),
|
||||||
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
||||||
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
||||||
accessTokenTrustedIps
|
accessTokenTrustedIps
|
||||||
});
|
|
||||||
} else {
|
|
||||||
await addMutateAsync({
|
|
||||||
organizationId: orgId,
|
|
||||||
identityId,
|
|
||||||
...(tokenReviewMode === IdentityKubernetesAuthTokenReviewMode.Api
|
|
||||||
? {
|
|
||||||
kubernetesHost: kubernetesHost || ""
|
|
||||||
}
|
|
||||||
: {
|
|
||||||
kubernetesHost: null
|
|
||||||
}),
|
|
||||||
tokenReviewerJwt: tokenReviewerJwt || undefined,
|
|
||||||
allowedNames: allowedNames || "",
|
|
||||||
allowedNamespaces: allowedNamespaces || "",
|
|
||||||
allowedAudience: allowedAudience || "",
|
|
||||||
gatewayId: gatewayId || null,
|
|
||||||
caCert: caCert || "",
|
|
||||||
tokenReviewMode,
|
|
||||||
accessTokenTTL: Number(accessTokenTTL),
|
|
||||||
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
|
||||||
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
|
||||||
accessTokenTrustedIps
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
handlePopUpToggle("identityAuthMethod", false);
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
|
|
||||||
type: "success"
|
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
reset();
|
await addMutateAsync({
|
||||||
} catch {
|
organizationId: orgId,
|
||||||
createNotification({
|
identityId,
|
||||||
text: `Failed to ${isUpdate ? "update" : "configure"} identity`,
|
...(tokenReviewMode === IdentityKubernetesAuthTokenReviewMode.Api
|
||||||
type: "error"
|
? {
|
||||||
|
kubernetesHost: kubernetesHost || ""
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
kubernetesHost: null
|
||||||
|
}),
|
||||||
|
tokenReviewerJwt: tokenReviewerJwt || undefined,
|
||||||
|
allowedNames: allowedNames || "",
|
||||||
|
allowedNamespaces: allowedNamespaces || "",
|
||||||
|
allowedAudience: allowedAudience || "",
|
||||||
|
gatewayId: gatewayId || null,
|
||||||
|
caCert: caCert || "",
|
||||||
|
tokenReviewMode,
|
||||||
|
accessTokenTTL: Number(accessTokenTTL),
|
||||||
|
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
||||||
|
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
||||||
|
accessTokenTrustedIps
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handlePopUpToggle("identityAuthMethod", false);
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
|
|
||||||
|
reset();
|
||||||
};
|
};
|
||||||
|
|
||||||
const tokenReviewMode = watch("tokenReviewMode");
|
const tokenReviewMode = watch("tokenReviewMode");
|
||||||
|
|||||||
+64
-71
@@ -316,83 +316,76 @@ export const IdentityLdapAuthForm = ({
|
|||||||
}, [subscription, handlePopUpOpen, handlePopUpToggle]);
|
}, [subscription, handlePopUpOpen, handlePopUpToggle]);
|
||||||
|
|
||||||
const onFormSubmit = async (formData: FormData) => {
|
const onFormSubmit = async (formData: FormData) => {
|
||||||
try {
|
if (!identityId) return;
|
||||||
if (!identityId) return;
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
scope: submissionScope,
|
scope: submissionScope,
|
||||||
templateId: submissionTemplateId,
|
templateId: submissionTemplateId,
|
||||||
url: submissionUrl,
|
url: submissionUrl,
|
||||||
bindDN: submissionBindDN,
|
bindDN: submissionBindDN,
|
||||||
bindPass: submissionBindPass,
|
bindPass: submissionBindPass,
|
||||||
searchBase: submissionSearchBase,
|
searchBase: submissionSearchBase,
|
||||||
searchFilter,
|
searchFilter,
|
||||||
ldapCaCertificate,
|
ldapCaCertificate,
|
||||||
allowedFields,
|
allowedFields,
|
||||||
accessTokenTTL,
|
accessTokenTTL,
|
||||||
accessTokenMaxTTL,
|
accessTokenMaxTTL,
|
||||||
accessTokenNumUsesLimit,
|
accessTokenNumUsesLimit,
|
||||||
accessTokenTrustedIps,
|
accessTokenTrustedIps,
|
||||||
lockoutEnabled,
|
lockoutEnabled,
|
||||||
lockoutThreshold,
|
lockoutThreshold,
|
||||||
lockoutDurationValue,
|
lockoutDurationValue,
|
||||||
lockoutDurationUnit,
|
lockoutDurationUnit,
|
||||||
lockoutCounterResetValue,
|
lockoutCounterResetValue,
|
||||||
lockoutCounterResetUnit
|
lockoutCounterResetUnit
|
||||||
} = formData;
|
} = formData;
|
||||||
|
|
||||||
const lockoutDurationSeconds = ms(`${lockoutDurationValue}${lockoutDurationUnit}`) / 1000;
|
const lockoutDurationSeconds = ms(`${lockoutDurationValue}${lockoutDurationUnit}`) / 1000;
|
||||||
const lockoutCounterResetSeconds =
|
const lockoutCounterResetSeconds =
|
||||||
ms(`${lockoutCounterResetValue}${lockoutCounterResetUnit}`) / 1000;
|
ms(`${lockoutCounterResetValue}${lockoutCounterResetUnit}`) / 1000;
|
||||||
|
|
||||||
const basePayload = {
|
const basePayload = {
|
||||||
organizationId: orgId,
|
organizationId: orgId,
|
||||||
identityId,
|
identityId,
|
||||||
searchFilter,
|
searchFilter,
|
||||||
ldapCaCertificate,
|
ldapCaCertificate,
|
||||||
allowedFields,
|
allowedFields,
|
||||||
accessTokenTTL: Number(accessTokenTTL),
|
accessTokenTTL: Number(accessTokenTTL),
|
||||||
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
||||||
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
||||||
accessTokenTrustedIps,
|
accessTokenTrustedIps,
|
||||||
lockoutEnabled,
|
lockoutEnabled,
|
||||||
lockoutThreshold: Number(lockoutThreshold),
|
lockoutThreshold: Number(lockoutThreshold),
|
||||||
lockoutDurationSeconds,
|
lockoutDurationSeconds,
|
||||||
lockoutCounterResetSeconds
|
lockoutCounterResetSeconds
|
||||||
};
|
};
|
||||||
|
|
||||||
// Add scope-specific fields
|
// Add scope-specific fields
|
||||||
const payload =
|
const payload =
|
||||||
submissionScope === "template"
|
submissionScope === "template"
|
||||||
? { ...basePayload, templateId: submissionTemplateId }
|
? { ...basePayload, templateId: submissionTemplateId }
|
||||||
: {
|
: {
|
||||||
...basePayload,
|
...basePayload,
|
||||||
url: submissionUrl,
|
url: submissionUrl,
|
||||||
bindDN: submissionBindDN,
|
bindDN: submissionBindDN,
|
||||||
bindPass: submissionBindPass,
|
bindPass: submissionBindPass,
|
||||||
searchBase: submissionSearchBase
|
searchBase: submissionSearchBase
|
||||||
};
|
};
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
await updateMutateAsync(payload);
|
await updateMutateAsync(payload);
|
||||||
} else {
|
} else {
|
||||||
await addMutateAsync(payload);
|
await addMutateAsync(payload);
|
||||||
}
|
|
||||||
|
|
||||||
handlePopUpToggle("identityAuthMethod", false);
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
|
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
|
|
||||||
reset();
|
|
||||||
} catch {
|
|
||||||
createNotification({
|
|
||||||
text: `Failed to ${isUpdate ? "update" : "configure"} identity`,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handlePopUpToggle("identityAuthMethod", false);
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
|
|
||||||
|
reset();
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+14
-25
@@ -42,31 +42,20 @@ export const IdentityLinkForm = ({ onClose }: Props) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const onFormSubmit = async ({ identity, role }: FormData) => {
|
const onFormSubmit = async ({ identity, role }: FormData) => {
|
||||||
try {
|
await createMutateAsync({
|
||||||
await createMutateAsync({
|
identityId: identity.id,
|
||||||
identityId: identity.id,
|
roles: [{ role: role.slug, isTemporary: false }]
|
||||||
roles: [{ role: role.slug, isTemporary: false }]
|
});
|
||||||
});
|
createNotification({
|
||||||
createNotification({
|
text: "Successfully linked identity",
|
||||||
text: "Successfully linked identity",
|
type: "success"
|
||||||
type: "success"
|
});
|
||||||
});
|
navigate({
|
||||||
navigate({
|
to: "/organization/identities/$identityId",
|
||||||
to: "/organization/identities/$identityId",
|
params: {
|
||||||
params: {
|
identityId: identity.id
|
||||||
identityId: identity.id
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
const error = err as any;
|
|
||||||
const text = error?.response?.data?.message ?? "Failed to link identity";
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+55
-68
@@ -108,81 +108,68 @@ export const IdentityModal = ({ popUp, handlePopUpToggle }: Props) => {
|
|||||||
}, [popUp?.identity?.data, roles]);
|
}, [popUp?.identity?.data, roles]);
|
||||||
|
|
||||||
const onFormSubmit = async ({ name, role, metadata, hasDeleteProtection }: FormData) => {
|
const onFormSubmit = async ({ name, role, metadata, hasDeleteProtection }: FormData) => {
|
||||||
try {
|
const identity = popUp?.identity?.data as {
|
||||||
const identity = popUp?.identity?.data as {
|
identityId: string;
|
||||||
identityId: string;
|
name: string;
|
||||||
name: string;
|
role: string;
|
||||||
role: string;
|
hasDeleteProtection: boolean;
|
||||||
hasDeleteProtection: boolean;
|
orgId: string;
|
||||||
orgId: string;
|
};
|
||||||
};
|
|
||||||
|
|
||||||
if (identity) {
|
if (identity) {
|
||||||
// update
|
// update
|
||||||
|
|
||||||
await updateMutateAsync({
|
await updateMutateAsync({
|
||||||
identityId: identity.identityId,
|
identityId: identity.identityId,
|
||||||
name,
|
name,
|
||||||
role: role.slug || undefined,
|
role: role.slug || undefined,
|
||||||
hasDeleteProtection,
|
hasDeleteProtection,
|
||||||
organizationId: orgId,
|
organizationId: orgId,
|
||||||
metadata
|
metadata
|
||||||
});
|
|
||||||
|
|
||||||
handlePopUpToggle("identity", false);
|
|
||||||
} else {
|
|
||||||
// create
|
|
||||||
|
|
||||||
const { id: createdId } = await createMutateAsync({
|
|
||||||
name,
|
|
||||||
role: role.slug || undefined,
|
|
||||||
hasDeleteProtection,
|
|
||||||
organizationId: orgId,
|
|
||||||
metadata
|
|
||||||
});
|
|
||||||
|
|
||||||
await addMutateAsync({
|
|
||||||
organizationId: orgId,
|
|
||||||
identityId: createdId,
|
|
||||||
clientSecretTrustedIps: [{ ipAddress: "0.0.0.0/0" }, { ipAddress: "::/0" }],
|
|
||||||
accessTokenTrustedIps: [{ ipAddress: "0.0.0.0/0" }, { ipAddress: "::/0" }],
|
|
||||||
accessTokenTTL: 2592000,
|
|
||||||
accessTokenMaxTTL: 2592000,
|
|
||||||
accessTokenNumUsesLimit: 0,
|
|
||||||
accessTokenPeriod: 0,
|
|
||||||
lockoutEnabled: true,
|
|
||||||
lockoutThreshold: 3,
|
|
||||||
lockoutDurationSeconds: 300,
|
|
||||||
lockoutCounterResetSeconds: 30
|
|
||||||
});
|
|
||||||
|
|
||||||
handlePopUpToggle("identity", false);
|
|
||||||
navigate({
|
|
||||||
to: "/organization/identities/$identityId",
|
|
||||||
params: {
|
|
||||||
identityId: createdId
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: `Successfully ${popUp?.identity?.data ? "updated" : "created"} identity`,
|
|
||||||
type: "success"
|
|
||||||
});
|
});
|
||||||
|
|
||||||
reset();
|
handlePopUpToggle("identity", false);
|
||||||
} catch (err) {
|
} else {
|
||||||
console.error(err);
|
// create
|
||||||
const error = err as any;
|
|
||||||
const text =
|
|
||||||
error?.response?.data?.message ??
|
|
||||||
`Failed to ${popUp?.identity?.data ? "update" : "create"} identity`;
|
|
||||||
|
|
||||||
createNotification({
|
const { id: createdId } = await createMutateAsync({
|
||||||
text,
|
name,
|
||||||
type: "error"
|
role: role.slug || undefined,
|
||||||
|
hasDeleteProtection,
|
||||||
|
organizationId: orgId,
|
||||||
|
metadata
|
||||||
|
});
|
||||||
|
|
||||||
|
await addMutateAsync({
|
||||||
|
organizationId: orgId,
|
||||||
|
identityId: createdId,
|
||||||
|
clientSecretTrustedIps: [{ ipAddress: "0.0.0.0/0" }, { ipAddress: "::/0" }],
|
||||||
|
accessTokenTrustedIps: [{ ipAddress: "0.0.0.0/0" }, { ipAddress: "::/0" }],
|
||||||
|
accessTokenTTL: 2592000,
|
||||||
|
accessTokenMaxTTL: 2592000,
|
||||||
|
accessTokenNumUsesLimit: 0,
|
||||||
|
accessTokenPeriod: 0,
|
||||||
|
lockoutEnabled: true,
|
||||||
|
lockoutThreshold: 3,
|
||||||
|
lockoutDurationSeconds: 300,
|
||||||
|
lockoutCounterResetSeconds: 30
|
||||||
|
});
|
||||||
|
|
||||||
|
handlePopUpToggle("identity", false);
|
||||||
|
navigate({
|
||||||
|
to: "/organization/identities/$identityId",
|
||||||
|
params: {
|
||||||
|
identityId: createdId
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: `Successfully ${popUp?.identity?.data ? "updated" : "created"} identity`,
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
|
|
||||||
|
reset();
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+30
-37
@@ -152,47 +152,40 @@ export const IdentityOciAuthForm = ({
|
|||||||
accessTokenNumUsesLimit,
|
accessTokenNumUsesLimit,
|
||||||
accessTokenTrustedIps
|
accessTokenTrustedIps
|
||||||
}: FormData) => {
|
}: FormData) => {
|
||||||
try {
|
if (!identityId) return;
|
||||||
if (!identityId) return;
|
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
await updateMutateAsync({
|
await updateMutateAsync({
|
||||||
organizationId: orgId,
|
organizationId: orgId,
|
||||||
tenancyOcid,
|
tenancyOcid,
|
||||||
allowedUsernames,
|
allowedUsernames,
|
||||||
identityId,
|
identityId,
|
||||||
accessTokenTTL: Number(accessTokenTTL),
|
accessTokenTTL: Number(accessTokenTTL),
|
||||||
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
||||||
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
||||||
accessTokenTrustedIps
|
accessTokenTrustedIps
|
||||||
});
|
|
||||||
} else {
|
|
||||||
await addMutateAsync({
|
|
||||||
organizationId: orgId,
|
|
||||||
identityId,
|
|
||||||
tenancyOcid,
|
|
||||||
allowedUsernames: allowedUsernames || undefined,
|
|
||||||
accessTokenTTL: Number(accessTokenTTL),
|
|
||||||
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
|
||||||
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
|
||||||
accessTokenTrustedIps
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
handlePopUpToggle("identityAuthMethod", false);
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
|
|
||||||
type: "success"
|
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
reset();
|
await addMutateAsync({
|
||||||
} catch {
|
organizationId: orgId,
|
||||||
createNotification({
|
identityId,
|
||||||
text: `Failed to ${isUpdate ? "update" : "configure"} identity`,
|
tenancyOcid,
|
||||||
type: "error"
|
allowedUsernames: allowedUsernames || undefined,
|
||||||
|
accessTokenTTL: Number(accessTokenTTL),
|
||||||
|
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
||||||
|
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
||||||
|
accessTokenTrustedIps
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handlePopUpToggle("identityAuthMethod", false);
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
|
|
||||||
|
reset();
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+46
-53
@@ -204,63 +204,56 @@ export const IdentityOidcAuthForm = ({
|
|||||||
claimMetadataMapping,
|
claimMetadataMapping,
|
||||||
boundSubject
|
boundSubject
|
||||||
}: FormData) => {
|
}: FormData) => {
|
||||||
try {
|
if (!identityId) {
|
||||||
if (!identityId) {
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
await updateMutateAsync({
|
await updateMutateAsync({
|
||||||
identityId,
|
identityId,
|
||||||
organizationId: orgId,
|
organizationId: orgId,
|
||||||
oidcDiscoveryUrl,
|
oidcDiscoveryUrl,
|
||||||
caCert,
|
caCert,
|
||||||
boundIssuer,
|
boundIssuer,
|
||||||
boundAudiences,
|
boundAudiences,
|
||||||
boundClaims: Object.fromEntries(boundClaims.map((entry) => [entry.key, entry.value])),
|
boundClaims: Object.fromEntries(boundClaims.map((entry) => [entry.key, entry.value])),
|
||||||
claimMetadataMapping: claimMetadataMapping
|
claimMetadataMapping: claimMetadataMapping
|
||||||
? Object.fromEntries(claimMetadataMapping.map((entry) => [entry.key, entry.value]))
|
? Object.fromEntries(claimMetadataMapping.map((entry) => [entry.key, entry.value]))
|
||||||
: undefined,
|
: undefined,
|
||||||
boundSubject,
|
boundSubject,
|
||||||
accessTokenTTL: Number(accessTokenTTL),
|
accessTokenTTL: Number(accessTokenTTL),
|
||||||
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
||||||
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
||||||
accessTokenTrustedIps
|
accessTokenTrustedIps
|
||||||
});
|
|
||||||
} else {
|
|
||||||
await addMutateAsync({
|
|
||||||
identityId,
|
|
||||||
oidcDiscoveryUrl,
|
|
||||||
caCert,
|
|
||||||
boundIssuer,
|
|
||||||
boundAudiences,
|
|
||||||
boundClaims: Object.fromEntries(boundClaims.map((entry) => [entry.key, entry.value])),
|
|
||||||
claimMetadataMapping: claimMetadataMapping
|
|
||||||
? Object.fromEntries(claimMetadataMapping.map((entry) => [entry.key, entry.value]))
|
|
||||||
: undefined,
|
|
||||||
boundSubject,
|
|
||||||
organizationId: orgId,
|
|
||||||
accessTokenTTL: Number(accessTokenTTL),
|
|
||||||
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
|
||||||
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
|
||||||
accessTokenTrustedIps
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
handlePopUpToggle("identityAuthMethod", false);
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
|
|
||||||
type: "success"
|
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
reset();
|
await addMutateAsync({
|
||||||
} catch {
|
identityId,
|
||||||
createNotification({
|
oidcDiscoveryUrl,
|
||||||
text: `Failed to ${isUpdate ? "update" : "configure"} identity`,
|
caCert,
|
||||||
type: "error"
|
boundIssuer,
|
||||||
|
boundAudiences,
|
||||||
|
boundClaims: Object.fromEntries(boundClaims.map((entry) => [entry.key, entry.value])),
|
||||||
|
claimMetadataMapping: claimMetadataMapping
|
||||||
|
? Object.fromEntries(claimMetadataMapping.map((entry) => [entry.key, entry.value]))
|
||||||
|
: undefined,
|
||||||
|
boundSubject,
|
||||||
|
organizationId: orgId,
|
||||||
|
accessTokenTTL: Number(accessTokenTTL),
|
||||||
|
accessTokenMaxTTL: Number(accessTokenMaxTTL),
|
||||||
|
accessTokenNumUsesLimit: Number(accessTokenNumUsesLimit),
|
||||||
|
accessTokenTrustedIps
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handlePopUpToggle("identityAuthMethod", false);
|
||||||
|
|
||||||
|
createNotification({
|
||||||
|
text: `Successfully ${isUpdate ? "updated" : "configured"} auth method`,
|
||||||
|
type: "success"
|
||||||
|
});
|
||||||
|
|
||||||
|
reset();
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+18
-40
@@ -56,53 +56,31 @@ export const IdentitySection = withPermission(
|
|||||||
const isEnterprise = subscription?.slug === "enterprise";
|
const isEnterprise = subscription?.slug === "enterprise";
|
||||||
|
|
||||||
const onDeleteIdentitySubmit = async (identityId: string) => {
|
const onDeleteIdentitySubmit = async (identityId: string) => {
|
||||||
try {
|
await deleteMutateAsync({
|
||||||
await deleteMutateAsync({
|
identityId,
|
||||||
identityId,
|
organizationId: orgId
|
||||||
organizationId: orgId
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully deleted identity",
|
text: "Successfully deleted identity",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
handlePopUpClose("deleteIdentity");
|
handlePopUpClose("deleteIdentity");
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
const error = err as any;
|
|
||||||
const text = error?.response?.data?.message ?? "Failed to delete identity";
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const onDeleteTemplateSubmit = async (templateId: string) => {
|
const onDeleteTemplateSubmit = async (templateId: string) => {
|
||||||
try {
|
await deleteTemplateMutateAsync({
|
||||||
await deleteTemplateMutateAsync({
|
templateId,
|
||||||
templateId,
|
organizationId: orgId
|
||||||
organizationId: orgId
|
});
|
||||||
});
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: "Successfully deleted template",
|
text: "Successfully deleted template",
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
|
|
||||||
handlePopUpClose("deleteTemplate");
|
handlePopUpClose("deleteTemplate");
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
const error = err as any;
|
|
||||||
const text = error?.response?.data?.message ?? "Failed to delete template";
|
|
||||||
|
|
||||||
createNotification({
|
|
||||||
text,
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user