mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
misc: addressed minor kms issues
This commit is contained in:
@@ -69,7 +69,9 @@ export const useUpdateProjectKms = (projectId: string) => {
|
|||||||
mutationFn: async (
|
mutationFn: async (
|
||||||
updatedData: { type: KmsType.Internal } | { type: KmsType.External; kmsId: string }
|
updatedData: { type: KmsType.Internal } | { type: KmsType.External; kmsId: string }
|
||||||
) => {
|
) => {
|
||||||
const { data } = await apiRequest.patch(`/api/v1/workspace/${projectId}/kms`, updatedData);
|
const { data } = await apiRequest.patch(`/api/v1/workspace/${projectId}/kms`, {
|
||||||
|
kms: updatedData
|
||||||
|
});
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ export const AddExternalKmsSchema = z.object({
|
|||||||
.refine((v) => slugify(v) === v, {
|
.refine((v) => slugify(v) === v, {
|
||||||
message: "Alias must be a valid slug"
|
message: "Alias must be a valid slug"
|
||||||
}),
|
}),
|
||||||
description: z.string().trim().min(1).optional(),
|
description: z.string().trim().optional(),
|
||||||
provider: ExternalKmsInputSchema
|
provider: ExternalKmsInputSchema
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ export const AwsKmsForm = ({ onCompleted, onCancel, kms }: Props) => {
|
|||||||
resolver: zodResolver(AddExternalKmsSchema),
|
resolver: zodResolver(AddExternalKmsSchema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
slug: kms?.slug,
|
slug: kms?.slug,
|
||||||
description: kms?.description,
|
description: kms?.description ?? "",
|
||||||
provider: {
|
provider: {
|
||||||
type: ExternalKmsProvider.AWS,
|
type: ExternalKmsProvider.AWS,
|
||||||
inputs: {
|
inputs: {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import {
|
|||||||
useOrganization,
|
useOrganization,
|
||||||
useWorkspace
|
useWorkspace
|
||||||
} from "@app/context";
|
} from "@app/context";
|
||||||
import { usePopUp } from "@app/hooks";
|
import { usePopUp, useToggle } from "@app/hooks";
|
||||||
import {
|
import {
|
||||||
useGetActiveProjectKms,
|
useGetActiveProjectKms,
|
||||||
useGetExternalKmsList,
|
useGetExternalKmsList,
|
||||||
@@ -51,18 +51,36 @@ const BackupConfirmationModal = ({
|
|||||||
org?: Organization;
|
org?: Organization;
|
||||||
workspace?: Workspace;
|
workspace?: Workspace;
|
||||||
}) => {
|
}) => {
|
||||||
|
const [isGeneratingBackup, setGeneratingBackup] = useToggle();
|
||||||
const downloadKmsBackup = async () => {
|
const downloadKmsBackup = async () => {
|
||||||
if (!workspace || !org) {
|
if (!workspace || !org) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { secretManager } = await fetchProjectKmsBackup(workspace.id);
|
setGeneratingBackup.on();
|
||||||
|
|
||||||
const [, , kmsFunction] = secretManager.split(".");
|
try {
|
||||||
const file = secretManager;
|
const { secretManager } = await fetchProjectKmsBackup(workspace.id);
|
||||||
|
|
||||||
const blob = new Blob([file], { type: "text/plain;charset=utf-8" });
|
const [, , kmsFunction] = secretManager.split(".");
|
||||||
FileSaver.saveAs(blob, `kms-backup-${org.slug}-${workspace.slug}-${kmsFunction}.infisical.txt`);
|
const file = secretManager;
|
||||||
|
|
||||||
|
const blob = new Blob([file], { type: "text/plain;charset=utf-8" });
|
||||||
|
FileSaver.saveAs(
|
||||||
|
blob,
|
||||||
|
`kms-backup-${org.slug}-${workspace.slug}-${kmsFunction}.infisical.txt`
|
||||||
|
);
|
||||||
|
|
||||||
|
onOpenChange(false);
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
createNotification({
|
||||||
|
text: "Failed to create KMS backup",
|
||||||
|
type: "error"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
setGeneratingBackup.off();
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -72,7 +90,9 @@ const BackupConfirmationModal = ({
|
|||||||
In case of interruptions with your configured external KMS, you can load a backup to set
|
In case of interruptions with your configured external KMS, you can load a backup to set
|
||||||
the project's KMS back to the default Infisical KMS.
|
the project's KMS back to the default Infisical KMS.
|
||||||
</p>
|
</p>
|
||||||
<Button onClick={downloadKmsBackup}>Generate</Button>
|
<Button onClick={downloadKmsBackup} isLoading={isGeneratingBackup}>
|
||||||
|
Generate
|
||||||
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
onClick={() => onOpenChange(false)}
|
onClick={() => onOpenChange(false)}
|
||||||
colorSchema="secondary"
|
colorSchema="secondary"
|
||||||
|
|||||||
Reference in New Issue
Block a user