Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
improvement(kms): migrate project KMIP clients to v3 (#8306)
Andrew Huang16965b686d2f
diff --git a/frontend/src/helpers/kms.ts b/frontend/src/helpers/kms.tsindex 1511b9435b..1c20bf7a2e 100644--- a/frontend/src/helpers/kms.ts+++ b/frontend/src/helpers/kms.ts@@ -39,6 +39,9 @@ export const keyUsageDefaultOption: Record<[KmsKeyUsage.GENERATE_VERIFY_MAC]: HmacAlgorithm.HMAC_SHA_256};+export const formatKmsKeyAlgorithm = (algorithm: string): string =>+ algorithm.replaceAll("_", "-").toUpperCase();+export const getDefaultSigningAlgorithm = (cmek: TCmek): SigningAlgorithm => {if (cmek?.algorithm?.startsWith("ML_DSA")) {return cmek.algorithm as unknown as SigningAlgorithm;diff --git a/frontend/src/pages/kms/KmipPage/KmipPage.tsx b/frontend/src/pages/kms/KmipPage/KmipPage.tsxindex 92183e706f..117d802c44 100644--- a/frontend/src/pages/kms/KmipPage/KmipPage.tsx+++ b/frontend/src/pages/kms/KmipPage/KmipPage.tsx@@ -2,7 +2,7 @@ import { Helmet } from "react-helmet";import { useTranslation } from "react-i18next";import { ProjectPermissionCan } from "@app/components/permissions";-import { PageHeader } from "@app/components/v2";+import { PageHeader } from "@app/components/v3";import { ProjectPermissionKmipActions, ProjectPermissionSub } from "@app/context";import { ProjectType } from "@app/hooks/api/projects/types";@@ -16,8 +16,8 @@ export const KmipPage = () => {<Helmet><title>{t("common.head-title", { title: "KMS" })}</title></Helmet>- <div className="mx-auto flex flex-col justify-between bg-page text-foreground-inverse">- <div className="mx-auto mb-6 w-full max-w-8xl">+ <div className="mx-auto flex flex-col bg-page text-foreground">+ <div className="mx-auto mb-6 flex w-full max-w-8xl flex-col gap-8"><PageHeaderscope={ProjectType.KMS}title="KMIP"diff --git a/frontend/src/pages/kms/KmipPage/components/CreateKmipClientCertificateModal.tsx b/frontend/src/pages/kms/KmipPage/components/CreateKmipClientCertificateModal.tsxindex 074565f964..3bcd0906db 100644--- a/frontend/src/pages/kms/KmipPage/components/CreateKmipClientCertificateModal.tsx+++ b/frontend/src/pages/kms/KmipPage/components/CreateKmipClientCertificateModal.tsx@@ -1,25 +1,39 @@import { Controller, useForm } from "react-hook-form";-import { faCopy, faInfoCircle, faQuestionCircle } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";import { zodResolver } from "@hookform/resolvers/zod";+import { CircleHelpIcon, CopyIcon, InfoIcon } from "lucide-react";import { z } from "zod";import { createNotification } from "@app/components/notifications";import {Button,- FormControl,- FormLabel,+ Field,+ FieldDescription,+ FieldError,+ FieldLabel,IconButton,Input,- Modal,- ModalClose,- ModalContent,Select,+ SelectContent,SelectItem,+ SelectTrigger,+ SelectValue,+ Sheet,+ SheetClose,+ SheetContent,+ SheetDescription,+ SheetFooter,+ SheetHeader,+ SheetTitle,TextArea,- Tooltip-} from "@app/components/v2";-import { certKeyAlgorithms, isPqcAlgorithm } from "@app/hooks/api/certificates/constants";+ Tooltip,+ TooltipContent,+ TooltipTrigger+} from "@app/components/v3";+import {+ certKeyAlgorithms,+ certKeyAlgorithmToNameMap,+ isPqcAlgorithm+} from "@app/hooks/api/certificates/constants";import { CertKeyAlgorithm } from "@app/hooks/api/certificates/enums";import { useGenerateKmipClientCertificate } from "@app/hooks/api/kmip";import { KmipClientCertificate, TKmipClient } from "@app/hooks/api/kmip/types";@@ -119,182 +133,208 @@ const KmipClientCertificateForm = ({};return (- <form onSubmit={handleSubmit(handleKmipClientSubmit)}>- <Controller- control={control}- name="requestMethod"- render={({ field: { onChange, value } }) => (- <FormControl- label={- <FormLabel- label="Request Method"- icon={- <Tooltip- content={- <div className="space-y-2">- <p>- <strong>Managed:</strong> Infisical generates and manages the private key- for you.- </p>- <p>- <strong>CSR:</strong> Provide your own Certificate Signing Request. Use- this when your device (e.g., Dell iDRAC) generates its own private key.- </p>- </div>- }- >- <FontAwesomeIcon icon={faQuestionCircle} size="sm" />- </Tooltip>- }- />- }- >- <Select- value={value}- onValueChange={(val) => onChange(val as RequestMethod)}- className="w-full"- >- <SelectItem value={RequestMethod.MANAGED}>Managed</SelectItem>- <SelectItem value={RequestMethod.CSR}>Certificate Signing Request (CSR)</SelectItem>- </Select>- </FormControl>- )}- />-- <Controller- control={control}- name="ttl"- render={({ field, fieldState: { error } }) => (- <FormControl label="TTL" isError={Boolean(error)} errorText={error?.message} isRequired>- <Input {...field} placeholder="2 days, 1d, 2h, 1y, ..." />- </FormControl>- )}- />+ <form onSubmit={handleSubmit(handleKmipClientSubmit)} className="flex min-h-0 flex-1 flex-col">+ <div className="thin-scrollbar flex-1 space-y-4 overflow-y-auto p-4">+ <Controller+ control={control}+ name="requestMethod"+ render={({ field: { onChange, value } }) => (+ <Field>+ <div className="flex items-center gap-2">+ <FieldLabel htmlFor="kmip-cert-method">Request Method</FieldLabel>+ <Tooltip>+ <TooltipTrigger asChild>+ <button type="button" aria-label="About request methods">+ <CircleHelpIcon className="size-3.5" />+ </button>+ </TooltipTrigger>+ <TooltipContent>+ <div className="max-w-72 space-y-2">+ <p>+ <strong>Managed:</strong> Infisical generates and manages the private key+ for you.+ </p>+ <p>+ <strong>CSR:</strong> Provide your own Certificate Signing Request. Use this+ when your device (e.g., Dell iDRAC) generates its own private key.+ </p>+ </div>+ </TooltipContent>+ </Tooltip>+ </div>+ <Select value={value} onValueChange={(val) => onChange(val as RequestMethod)}>+ <SelectTrigger id="kmip-cert-method" className="w-full">+ <SelectValue />+ </SelectTrigger>+ <SelectContent>+ <SelectItem value={RequestMethod.MANAGED}>Managed</SelectItem>+ <SelectItem value={RequestMethod.CSR}>+ Certificate Signing Request (CSR)+ </SelectItem>+ </SelectContent>+ </Select>+ </Field>+ )}+ />- {requestMethod === RequestMethod.MANAGED && (<Controllercontrol={control}- name="keyAlgorithm"- defaultValue={CertKeyAlgorithm.RSA_2048}- render={({ field: { onChange, ...field }, fieldState: { error } }) => (- <FormControl- label="Key Algorithm"- errorText={error?.message}- isError={Boolean(error)}- helperText="This defines the key algorithm to use for signing the client certificate."- >- <Select- defaultValue={field.value}+ name="ttl"+ render={({ field, fieldState: { error } }) => (+ <Field data-invalid={Boolean(error)}>+ <FieldLabel htmlFor="kmip-cert-ttl">+ TTL{" "}+ <span aria-hidden className="text-danger">+ *+ </span>+ </FieldLabel>+ <Input{...field}- onValueChange={(e) => onChange(e)}- className="w-full"- >- {certKeyAlgorithms- .filter(({ value }) => !isPqcAlgorithm(value))- .map(({ label, value }) => (- <SelectItem value={String(value || "")} key={label}>- {label}- </SelectItem>- ))}- </Select>- </FormControl>+ id="kmip-cert-ttl"+ placeholder="2 days, 1d, 2h, 1y, ..."+ aria-required+ isError={Boolean(error)}+ />+ <FieldError>{error?.message}</FieldError>+ </Field>)}/>- )}- {requestMethod === RequestMethod.CSR && (- <>+ {requestMethod === RequestMethod.MANAGED && (<Controllercontrol={control}- name="csr"- render={({ field, fieldState: { error } }) => (- <FormControl- label="Certificate Signing Request (CSR)"- isRequired- errorText={error?.message}- isError={Boolean(error)}- >- <TextArea- {...field}- spellCheck={false}- placeholder={- "-----BEGIN CERTIFICATE REQUEST-----\n" +- "MIIByDCCAU4CAQAwfjELMAkGA1UEBhMCVVMx...\n" +- "-----END CERTIFICATE REQUEST-----"- }- rows={8}- className="w-full font-mono text-xs"- />- </FormControl>+ name="keyAlgorithm"+ defaultValue={CertKeyAlgorithm.RSA_2048}+ render={({ field: { onChange, value }, fieldState: { error } }) => (+ <Field data-invalid={Boolean(error)}>+ <FieldLabel htmlFor="kmip-cert-algorithm">Key Algorithm</FieldLabel>+ <Select value={value} onValueChange={onChange}>+ <SelectTrigger+ id="kmip-cert-algorithm"+ className="w-full"+ isError={Boolean(error)}+ >+ <SelectValue />+ </SelectTrigger>+ <SelectContent>+ {certKeyAlgorithms+ .filter(({ value: algorithm }) => !isPqcAlgorithm(algorithm))+ .map(({ label, value: algorithm }) => (+ <SelectItem value={String(algorithm || "")} key={label}>+ {certKeyAlgorithmToNameMap[algorithm] || label}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ <FieldDescription>+ This defines the key algorithm used to sign the client certificate.+ </FieldDescription>+ <FieldError>{error?.message}</FieldError>+ </Field>)}/>+ )}- {kmipClient && (- <div className="mt-4 rounded-md border border-border-control bg-surface-hover p-4">- <div className="mb-3 flex items-center text-sm font-medium text-foreground-secondary">- <FontAwesomeIcon icon={faInfoCircle} className="mr-2" />- Certificate Subject Values- </div>- <p className="mb-3 text-xs text-label">- The signed certificate will use these fixed values for CN and OU. If your device- requires you to specify subject values when generating the CSR, use the values- below.- </p>- <div className="space-y-2">- <div className="flex items-center justify-between rounded bg-surface-active px-3 py-2">- <div>- <div className="text-xs text-muted">CN (Common Name) = KMIP Client ID</div>- <div className="font-mono text-sm text-foreground">{kmipClient.id}</div>- </div>- <IconButton- ariaLabel="Copy Client ID"- variant="plain"- size="sm"- onClick={() => handleCopyToClipboard(kmipClient.id, "Client ID")}- >- <FontAwesomeIcon icon={faCopy} />- </IconButton>+ {requestMethod === RequestMethod.CSR && (+ <>+ <Controller+ control={control}+ name="csr"+ render={({ field, fieldState: { error } }) => (+ <Field data-invalid={Boolean(error)}>+ <FieldLabel htmlFor="kmip-cert-csr">+ Certificate Signing Request (CSR){" "}+ <span aria-hidden className="text-danger">+ *+ </span>+ </FieldLabel>+ <TextArea+ {...field}+ id="kmip-cert-csr"+ aria-required+ isError={Boolean(error)}+ spellCheck={false}+ placeholder={+ "-----BEGIN CERTIFICATE REQUEST-----\n" ++ "MIIByDCCAU4CAQAwfjELMAkGA1UEBhMCVVMx...\n" ++ "-----END CERTIFICATE REQUEST-----"+ }+ rows={8}+ className="font-mono"+ />+ <FieldError>{error?.message}</FieldError>+ </Field>+ )}+ />++ {kmipClient && (+ <div className="rounded-md border border-border bg-container p-4">+ <div className="mb-3 flex items-center gap-2 text-sm font-medium text-foreground">+ <InfoIcon className="size-4" />+ Certificate Subject Values</div>- <div className="flex items-center justify-between rounded bg-surface-active px-3 py-2">- <div>- <div className="text-xs text-muted">OU (Organizational Unit) = Project ID</div>- <div className="font-mono text-sm text-foreground">{kmipClient.projectId}</div>+ <p className="mb-3 text-xs text-label">+ The signed certificate will use these fixed values for CN and OU. If your device+ requires you to specify subject values when generating the CSR, use the values+ below.+ </p>+ <div className="space-y-2">+ <div className="flex items-center justify-between gap-2 rounded bg-card px-3 py-2">+ <div>+ <div className="text-xs text-muted">CN (Common Name) = KMIP Client ID</div>+ <div className="font-mono text-sm break-all text-foreground">+ {kmipClient.id}+ </div>+ </div>+ <IconButton+ aria-label="Copy Client ID"+ variant="ghost"+ size="sm"+ type="button"+ onClick={() => handleCopyToClipboard(kmipClient.id, "Client ID")}+ >+ <CopyIcon />+ </IconButton>+ </div>+ <div className="flex items-center justify-between gap-2 rounded bg-card px-3 py-2">+ <div>+ <div className="text-xs text-muted">+ OU (Organizational Unit) = Project ID+ </div>+ <div className="font-mono text-sm break-all text-foreground">+ {kmipClient.projectId}+ </div>+ </div>+ <IconButton+ aria-label="Copy Project ID"+ variant="ghost"+ size="sm"+ type="button"+ onClick={() => handleCopyToClipboard(kmipClient.projectId, "Project ID")}+ >+ <CopyIcon />+ </IconButton></div>- <IconButton- ariaLabel="Copy Project ID"- variant="plain"- size="sm"- onClick={() => handleCopyToClipboard(kmipClient.projectId, "Project ID")}- >- <FontAwesomeIcon icon={faCopy} />- </IconButton></div>+ <p className="mt-3 text-xs text-muted">+ Note: Any O (Organization), L (Locality), ST (State), or C (Country) values in+ your CSR will be included in the certificate.+ </p></div>- <p className="mt-3 text-xs text-muted">- Note: Any O (Organization), L (Locality), ST (State), or C (Country) values in your- CSR will be included in the certificate.- </p>- </div>- )}- </>- )}-- <div className="mt-8 flex items-center">- <Button- className="mr-4"- size="sm"- type="submit"- isLoading={isSubmitting}- isDisabled={isSubmitting}- >- {requestMethod === RequestMethod.CSR ? "Sign Certificate" : "Generate Certificate"}- </Button>- <ModalClose asChild>- <Button colorSchema="secondary" variant="plain">+ )}+ </>+ )}+ </div>+ <SheetFooter className="justify-end border-t">+ <SheetClose asChild>+ <Button variant="ghost" type="button">Cancel</Button>- </ModalClose>- </div>+ </SheetClose>+ <Button variant="project" type="submit" isPending={isSubmitting} isDisabled={isSubmitting}>+ {requestMethod === RequestMethod.CSR ? "Sign Certificate" : "Generate Certificate"}+ </Button>+ </SheetFooter></form>);};@@ -306,14 +346,33 @@ export const CreateKmipClientCertificateModal = ({displayNewClientCertificate}: Props) => {return (- <Modal isOpen={isOpen} onOpenChange={onOpenChange}>- <ModalContent title="KMIP client certificate">- <KmipClientCertificateForm- onComplete={() => onOpenChange(false)}- displayNewClientCertificate={displayNewClientCertificate}- kmipClient={kmipClient}- />- </ModalContent>- </Modal>+ <Sheet open={isOpen} onOpenChange={onOpenChange}>+ <SheetContent+ onOpenAutoFocus={(event) => {+ const ttlInput = (event.currentTarget as HTMLElement).querySelector<HTMLInputElement>(+ "#kmip-cert-ttl"+ );+ if (ttlInput) {+ event.preventDefault();+ ttlInput.focus();+ }+ }}+ >+ <SheetHeader>+ <SheetTitle>KMIP Client Certificate</SheetTitle>+ <SheetDescription>+ Generate a private key or sign a certificate signing request for this client.+ </SheetDescription>+ </SheetHeader>+ {isOpen && (+ <KmipClientCertificateForm+ key={kmipClient?.id}+ onComplete={() => onOpenChange(false)}+ displayNewClientCertificate={displayNewClientCertificate}+ kmipClient={kmipClient}+ />+ )}+ </SheetContent>+ </Sheet>);};diff --git a/frontend/src/pages/kms/KmipPage/components/DeleteKmipClientModal.tsx b/frontend/src/pages/kms/KmipPage/components/DeleteKmipClientModal.tsxindex 2d6accf76d..aadc46972e 100644--- a/frontend/src/pages/kms/KmipPage/components/DeleteKmipClientModal.tsx+++ b/frontend/src/pages/kms/KmipPage/components/DeleteKmipClientModal.tsx@@ -1,5 +1,5 @@import { createNotification } from "@app/components/notifications";-import { DeleteActionModal } from "@app/components/v2";+import { Alert, AlertDescription, DeleteConfirmDialog } from "@app/components/v3";import { useDeleteKmipClients } from "@app/hooks/api/kmip";import { TKmipClient } from "@app/hooks/api/kmip/types";@@ -31,12 +31,21 @@ export const DeleteKmipClientModal = ({ isOpen, onOpenChange, kmipClient }: Prop};return (- <DeleteActionModal+ <DeleteConfirmDialogisOpen={isOpen}- title={`Are you sure you want to delete ${name}?`}- onChange={onOpenChange}- deleteKey="confirm"- onDeleteApproved={handleDeleteKmipClient}+ title={`Delete KMIP Client ${name}?`}+ description={+ <Alert variant="danger" appearance="borderless">+ <AlertDescription>+ This permanently removes the KMIP client {name}. This cannot be undone.+ </AlertDescription>+ </Alert>+ }+ onOpenChange={onOpenChange}+ confirmKey="confirm"+ confirmLabel="Delete KMIP Client"+ isPending={deleteKmipClients.isPending}+ onConfirm={handleDeleteKmipClient}/>);};diff --git a/frontend/src/pages/kms/KmipPage/components/KmipClientCertificateModal.tsx b/frontend/src/pages/kms/KmipPage/components/KmipClientCertificateModal.tsxindex 81694e0252..f3146c08d9 100644--- a/frontend/src/pages/kms/KmipPage/components/KmipClientCertificateModal.tsx+++ b/frontend/src/pages/kms/KmipPage/components/KmipClientCertificateModal.tsx@@ -1,6 +1,19 @@-import { Modal, ModalContent } from "@app/components/v2";+import { useState } from "react";+import FileSaver from "file-saver";+import { CheckIcon, CopyIcon, DownloadIcon, EyeIcon, EyeOffIcon } from "lucide-react";++import {+ Dialog,+ DialogContent,+ DialogHeader,+ DialogTitle,+ IconButton,+ Tooltip,+ TooltipContent,+ TooltipTrigger+} from "@app/components/v3";+import { useTimedReset } from "@app/hooks";import { KmipClientCertificate } from "@app/hooks/api/kmip/types";-import { CertificateContent } from "@app/pages/cert-manager/CertificatesPage/components/CertificateContent";type Props = {isOpen: boolean;@@ -8,12 +21,115 @@ type Props = {certificate: KmipClientCertificate;};+const CertificateSection = ({+ title,+ value,+ filename,+ isSensitive = false+}: {+ title: string;+ value: string;+ filename?: string;+ isSensitive?: boolean;+}) => {+ const [isRevealed, setIsRevealed] = useState(false);+ const [copyLabel, isCopied, setCopyLabel] = useTimedReset<string>({+ initialState: "Copy to clipboard"+ });++ return (+ <section className="flex flex-col gap-2">+ <div className="flex items-center justify-between gap-2">+ <h3 className="font-medium text-foreground">{title}</h3>+ <div className="flex items-center gap-1">+ {isSensitive && (+ <IconButton+ variant="ghost"+ size="sm"+ aria-label={isRevealed ? `Hide ${title}` : `Reveal ${title}`}+ onClick={() => setIsRevealed((previous) => !previous)}+ >+ {isRevealed ? <EyeOffIcon /> : <EyeIcon />}+ </IconButton>+ )}+ <Tooltip>+ <TooltipTrigger asChild>+ <IconButton+ variant="ghost"+ size="sm"+ aria-label={`Copy ${title}`}+ onClick={() => {+ navigator.clipboard.writeText(value);+ setCopyLabel("Copied");+ }}+ >+ {isCopied ? <CheckIcon /> : <CopyIcon />}+ </IconButton>+ </TooltipTrigger>+ <TooltipContent>{copyLabel}</TooltipContent>+ </Tooltip>+ {filename && (+ <Tooltip>+ <TooltipTrigger asChild>+ <IconButton+ variant="ghost"+ size="sm"+ aria-label={`Download ${title}`}+ onClick={() =>+ FileSaver.saveAs(+ new Blob([value], { type: "text/plain;charset=utf-8" }),+ filename+ )+ }+ >+ <DownloadIcon />+ </IconButton>+ </TooltipTrigger>+ <TooltipContent>Download</TooltipContent>+ </Tooltip>+ )}+ </div>+ </div>+ <pre className="max-h-56 overflow-auto rounded-md border border-border bg-container p-3 font-mono text-xs break-all whitespace-pre-wrap text-foreground">+ {isSensitive && !isRevealed ? "••••••••••••••••" : value}+ </pre>+ </section>+ );+};+export const KmipClientCertificateModal = ({ isOpen, onOpenChange, certificate }: Props) => {+ if (!certificate) return null;+return (- <Modal isOpen={isOpen} onOpenChange={onOpenChange}>- <ModalContent title="KMIP client certificate">- <CertificateContent {...certificate} />- </ModalContent>- </Modal>+ <Dialog open={isOpen} onOpenChange={onOpenChange}>+ <DialogContent>+ <DialogHeader>+ <DialogTitle>KMIP Client Certificate</DialogTitle>+ </DialogHeader>+ <div className="flex flex-col gap-5">+ <CertificateSection title="Serial Number" value={certificate.serialNumber} />+ <CertificateSection+ title="Certificate Body"+ value={certificate.certificate}+ filename="cert.pem"+ />+ {certificate.certificateChain && (+ <CertificateSection+ title="Certificate Chain"+ value={certificate.certificateChain}+ filename="chain.pem"+ />+ )}+ {certificate.privateKey && (+ <CertificateSection+ title="Certificate Private Key"+ value={certificate.privateKey}+ filename="private_key.txt"+ isSensitive+ />+ )}+ </div>+ </DialogContent>+ </Dialog>);};diff --git a/frontend/src/pages/kms/KmipPage/components/KmipClientModal.tsx b/frontend/src/pages/kms/KmipPage/components/KmipClientModal.tsxindex cf57caabd8..9ecaebf825 100644--- a/frontend/src/pages/kms/KmipPage/components/KmipClientModal.tsx+++ b/frontend/src/pages/kms/KmipPage/components/KmipClientModal.tsx@@ -6,13 +6,19 @@ import { createNotification } from "@app/components/notifications";import {Button,Checkbox,- FormControl,+ Field,+ FieldError,+ FieldLabel,Input,- Modal,- ModalClose,- ModalContent,+ Sheet,+ SheetClose,+ SheetContent,+ SheetDescription,+ SheetFooter,+ SheetHeader,+ SheetTitle,TextArea-} from "@app/components/v2";+} from "@app/components/v3";import { useProject } from "@app/context";import { useCreateKmipClient, useUpdateKmipClient } from "@app/hooks/api/kmip";import { KmipPermission, TKmipClient } from "@app/hooks/api/kmip/types";@@ -30,7 +36,7 @@ const KMIP_PERMISSIONS_OPTIONS = [] as const;const formSchema = z.object({- name: z.string().trim().min(1),+ name: z.string().trim().min(1, "Name is required"),description: z.string().max(500).optional(),permissions: z.object({[KmipPermission.Check]: z.boolean().optional(),@@ -107,79 +113,113 @@ const KmipClientForm = ({ onComplete, kmipClient }: FormProps) => {};return (- <form onSubmit={handleSubmit(handleKmipClientSubmit)}>- <FormControl- errorText={errors.name?.message}- isError={Boolean(errors.name?.message)}- label="Name"- >- <Input autoFocus placeholder="My KMIP Client" {...register("name")} autoComplete="off" />- </FormControl>- <FormControl- label="Description (optional)"- errorText={errors.description?.message}- isError={Boolean(errors.description?.message)}- >- <TextArea- className="max-h-80 min-h-40 max-w-full min-w-full"- {...register("description")}+ <form onSubmit={handleSubmit(handleKmipClientSubmit)} className="flex min-h-0 flex-1 flex-col">+ <div className="thin-scrollbar flex-1 space-y-4 overflow-y-auto p-4">+ <Field data-invalid={Boolean(errors.name)}>+ <FieldLabel htmlFor="kmip-client-name">+ Name{" "}+ <span aria-hidden className="text-danger">+ *+ </span>+ </FieldLabel>+ <Input+ id="kmip-client-name"+ autoFocus+ placeholder="My KMIP Client"+ {...register("name")}+ autoComplete="off"+ aria-required+ isError={Boolean(errors.name)}+ />+ <FieldError>{errors.name?.message}</FieldError>+ </Field>+ <Field data-invalid={Boolean(errors.description)}>+ <FieldLabel htmlFor="kmip-client-description">Description (optional)</FieldLabel>+ <TextArea+ id="kmip-client-description"+ {...register("description")}+ isError={Boolean(errors.description)}+ />+ <FieldError>{errors.description?.message}</FieldError>+ </Field>+ <Controller+ control={control}+ name="permissions"+ render={({ field: { onChange, value }, fieldState: { error } }) => {+ return (+ <Field data-invalid={Boolean(error)}>+ <span+ id="kmip-client-permissions-label"+ className="text-sm font-medium text-accent"+ >+ Permissions+ </span>+ <div+ role="group"+ aria-labelledby="kmip-client-permissions-label"+ className="grid grid-cols-1 gap-3 sm:grid-cols-2"+ >+ {KMIP_PERMISSIONS_OPTIONS.map(({ label, value: optionValue }) => {+ return (+ <label+ htmlFor={`kmip-client-${optionValue}`}+ key={optionValue}+ className="flex items-center gap-2 text-sm text-foreground"+ >+ <Checkbox+ id={`kmip-client-${optionValue}`}+ variant="project"+ isChecked={value[optionValue]}+ onCheckedChange={(state) => {+ onChange({+ ...value,+ [optionValue]: state === true+ });+ }}+ />+ {label}+ </label>+ );+ })}+ </div>+ <FieldError>{error?.message}</FieldError>+ </Field>+ );+ }}/>- </FormControl>- <Controller- control={control}- name="permissions"- render={({ field: { onChange, value }, fieldState: { error } }) => {- return (- <FormControl label="Permissions" errorText={error?.message} isError={Boolean(error)}>- <div className="mt-2 mb-7 grid grid-cols-2 gap-2">- {KMIP_PERMISSIONS_OPTIONS.map(({ label, value: optionValue }) => {- return (- <Checkbox- id={optionValue}- key={optionValue}- isChecked={value[optionValue]}- onCheckedChange={(state) => {- onChange({- ...value,- [optionValue]: state- });- }}- >- {label}- </Checkbox>- );- })}- </div>- </FormControl>- );- }}- />- <div className="flex items-center">- <Button- className="mr-4"- size="sm"- type="submit"- isLoading={isSubmitting}- isDisabled={isSubmitting}- >- {isUpdate ? "Update" : "Add"} KMIP client- </Button>- <ModalClose asChild>- <Button colorSchema="secondary" variant="plain">+ </div>+ <SheetFooter className="justify-end border-t">+ <SheetClose asChild>+ <Button variant="ghost" type="button">Cancel</Button>- </ModalClose>- </div>+ </SheetClose>+ <Button variant="project" type="submit" isPending={isSubmitting} isDisabled={isSubmitting}>+ {isUpdate ? "Update" : "Add"} KMIP Client+ </Button>+ </SheetFooter></form>);};export const KmipClientModal = ({ isOpen, onOpenChange, kmipClient }: Props) => {return (- <Modal isOpen={isOpen} onOpenChange={onOpenChange}>- <ModalContent title={`${kmipClient ? "Update" : "Add"} KMIP Client`}>- <KmipClientForm onComplete={() => onOpenChange(false)} kmipClient={kmipClient} />- </ModalContent>- </Modal>+ <Sheet open={isOpen} onOpenChange={onOpenChange}>+ <SheetContent>+ <SheetHeader>+ <SheetTitle>{kmipClient ? "Update" : "Add"} KMIP Client</SheetTitle>+ <SheetDescription>+ Set the client name and the KMIP operations it can perform.+ </SheetDescription>+ </SheetHeader>+ {isOpen && (+ <KmipClientForm+ key={kmipClient?.id ?? "new"}+ onComplete={() => onOpenChange(false)}+ kmipClient={kmipClient}+ />+ )}+ </SheetContent>+ </Sheet>);};diff --git a/frontend/src/pages/kms/KmipPage/components/KmipClientTable.tsx b/frontend/src/pages/kms/KmipPage/components/KmipClientTable.tsxindex 981ae13305..a96d59ae84 100644--- a/frontend/src/pages/kms/KmipPage/components/KmipClientTable.tsx+++ b/frontend/src/pages/kms/KmipPage/components/KmipClientTable.tsx@@ -1,41 +1,49 @@import {- faArrowDown,- faArrowUp,- faArrowUpRightFromSquare,- faCertificate,- faEdit,- faEllipsis,- faMagnifyingGlass,- faPlus,- faTrash,- faUser-} from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { motion } from "motion/react";+ ChevronDownIcon,+ FileBadgeIcon,+ MoreHorizontalIcon,+ PencilIcon,+ PlusIcon,+ SearchIcon,+ TrashIcon+} from "lucide-react";import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal";import { ProjectPermissionCan } from "@app/components/permissions";import {Button,+ Card,+ CardAction,+ CardContent,+ CardDescription,+ CardHeader,+ CardTitle,+ DocumentationLinkBadge,DropdownMenu,DropdownMenuContent,DropdownMenuItem,DropdownMenuTrigger,- EmptyState,+ Empty,+ EmptyDescription,+ EmptyHeader,+ EmptyTitle,IconButton,- Input,+ InputGroup,+ InputGroupAddon,+ InputGroupInput,Pagination,- Spinner,+ Skeleton,Table,- TableContainer,- TableSkeleton,- TBody,- Td,- Th,- THead,+ TableBody,+ TableCell,+ TableHead,+ TableHeader,+ TableHeadLabel,+ TableRow,Tooltip,- Tr-} from "@app/components/v2";+ TooltipContent,+ TooltipTrigger+} from "@app/components/v3";import {ProjectPermissionKmipActions,ProjectPermissionSub,@@ -112,12 +120,6 @@ export const KmipClientTable = () => {"upgradePlan"] as const);- const handleSort = () => {- setOrderDirection((prev) =>- prev === OrderByDirection.ASC ? OrderByDirection.DESC : OrderByDirection.ASC- );- };-const cannotEditKmipClient = permission.cannot(ProjectPermissionKmipActions.UpdateClients,ProjectPermissionSub.Kmip@@ -134,40 +136,23 @@ export const KmipClientTable = () => {);return (- <motion.div- key="kmip-clients-tab"- transition={{ duration: 0.15 }}- initial={{ opacity: 0, translateX: 30 }}- animate={{ opacity: 1, translateX: 0 }}- exit={{ opacity: 0, translateX: 30 }}- >- <div className="mb-6 rounded-lg border border-border-control bg-surface-base p-4">- <div className="mb-4 flex items-center justify-between">- <p className="text-xl font-medium whitespace-nowrap text-foreground">KMIP Clients</p>- <div className="flex w-full justify-end pr-4">- <a- target="_blank"- rel="noopener noreferrer"- href="https://infisical.com/docs/documentation/platform/kms"- >- <span className="flex w-max cursor-pointer items-center rounded-md border border-border-strong bg-surface-active px-4 py-2 text-foreground-secondary duration-200 hover:border-project/40 hover:bg-project/10 hover:text-foreground-inverse">- Documentation{" "}- <FontAwesomeIcon- icon={faArrowUpRightFromSquare}- className="mb-[0.06rem] ml-1 text-xs"- />- </span>- </a>- </div>+ <Card>+ <CardHeader>+ <CardTitle>+ KMIP Clients+ <DocumentationLinkBadge href="https://infisical.com/docs/documentation/platform/kms" />+ </CardTitle>+ <CardDescription>+ Manage clients that connect to this project's KMIP server.+ </CardDescription>+ <CardAction><ProjectPermissionCanI={ProjectPermissionKmipActions.CreateClients}a={ProjectPermissionSub.Kmip}>{(isAllowed) => (<Button- colorSchema="primary"- type="submit"- leftIcon={<FontAwesomeIcon icon={faPlus} />}+ variant="project"onClick={() => {if (subscription && !subscription.kmip) {handlePopUpOpen("upgradePlan", {@@ -180,175 +165,200 @@ export const KmipClientTable = () => {}}isDisabled={!isAllowed}>+ <PlusIcon />Add KMIP Client</Button>)}</ProjectPermissionCan>- </div>- <Input- containerClassName="mb-4"- value={search}- onChange={(e) => setSearch(e.target.value)}- leftIcon={<FontAwesomeIcon icon={faMagnifyingGlass} />}- placeholder="Search clients by name..."- />- <TableContainer>+ </CardAction>+ </CardHeader>+ <CardContent>+ <InputGroup className="mb-4">+ <InputGroupAddon align="inline-start">+ <SearchIcon />+ </InputGroupAddon>+ <InputGroupInput+ value={search}+ onChange={(e) => setSearch(e.target.value)}+ placeholder="Search clients by name..."+ aria-label="Search KMIP clients by name"+ />+ </InputGroup>+ {!isPending && kmipClients.length === 0 ? (+ <Empty className="border">+ <EmptyHeader>+ <EmptyTitle>+ {debouncedSearch.trim()+ ? "No KMIP clients match your search"+ : "No KMIP clients yet"}+ </EmptyTitle>+ <EmptyDescription>+ {debouncedSearch.trim()+ ? "Try a different search term."+ : "Add a KMIP client to grant access to your KMS project."}+ </EmptyDescription>+ </EmptyHeader>+ </Empty>+ ) : (<Table>- <THead>- <Tr className="h-14">- <Th>- <div className="flex items-center">- Name- <IconButton- variant="plain"- className="ml-2"- ariaLabel="sort"- onClick={handleSort}- >- <FontAwesomeIcon- icon={orderDirection === OrderByDirection.DESC ? faArrowUp : faArrowDown}- />- </IconButton>- </div>- </Th>- <Th>Description</Th>- <Th>Permissions</Th>- <Th className="w-16">{isFetching ? <Spinner size="xs" /> : null}</Th>- </Tr>- </THead>- <TBody>- {isPending && <TableSkeleton columns={3} innerKey="project-kmip-clients" />}+ <TableHeader>+ <TableRow>+ <TableHead+ sortDirection={+ orderDirection === OrderByDirection.ASC ? "ascending" : "descending"+ }+ onSortChange={(direction) =>+ setOrderDirection(+ direction === "descending" ? OrderByDirection.DESC : OrderByDirection.ASC+ )+ }+ >+ Name+ <ChevronDownIcon+ className={orderDirection === OrderByDirection.DESC ? "rotate-180" : undefined}+ />+ </TableHead>+ <TableHead>+ <TableHeadLabel>Description</TableHeadLabel>+ </TableHead>+ <TableHead>+ <TableHeadLabel>Permissions</TableHeadLabel>+ </TableHead>+ <TableHead variant="action">+ {isFetching && !isPending ? (+ <span className="sr-only">Refreshing clients</span>+ ) : null}+ </TableHead>+ </TableRow>+ </TableHeader>+ <TableBody>+ {isPending &&+ [0, 1, 2].map((row) => (+ <TableRow key={row}>+ {[0, 1, 2, 3].map((cell) => (+ <TableCell key={cell}>+ <Skeleton className="h-4 w-full" />+ </TableCell>+ ))}+ </TableRow>+ ))}{!isPending &&kmipClients.length > 0 &&kmipClients.map((kmipClient) => {const { name, id, description, permissions } = kmipClient;return (- <Tr className="group h-10 hover:bg-surface-hover" key={`st-v3-${id}`}>- <Td>{name}</Td>- <Td className="max-w-80 break-all">{description}</Td>- <Td className="max-w-40">{[permissions.join(", ")]}</Td>- <Td className="flex justify-end">+ <TableRow key={id}>+ <TableCell>{name}</TableCell>+ <TableCell className="max-w-80 break-all">+ {description?.trim() || <span className="text-muted italic">none</span>}+ </TableCell>+ <TableCell className="max-w-40">+ {permissions.length ? permissions.join(", ") : "—"}+ </TableCell>+ <TableCell variant="action"><DropdownMenu><DropdownMenuTrigger asChild><IconButton- variant="plain"- colorSchema="primary"- className="ml-4 p-0 data-[state=open]:text-project"- ariaLabel="More options"+ variant="ghost"+ size="sm"+ aria-label={`Options for ${name}`}>- <FontAwesomeIcon size="lg" icon={faEllipsis} />+ <MoreHorizontalIcon /></IconButton></DropdownMenuTrigger>- <DropdownMenuContent className="min-w-[160px]">- <Tooltip- content={- cannotGenerateKmipClientCertificate ? "Access Restricted" : ""- }- position="left"- >- <div>+ <DropdownMenuContent align="end">+ <Tooltip open={cannotGenerateKmipClientCertificate ? undefined : false}>+ <TooltipTrigger asChild><DropdownMenuItemonClick={() =>handlePopUpOpen("generateKmipClientCert", kmipClient)}- icon={<FontAwesomeIcon icon={faCertificate} />}- iconPos="left"isDisabled={cannotGenerateKmipClientCertificate}+ isDisabledFocusable={cannotGenerateKmipClientCertificate}>+ <FileBadgeIcon />Generate Certificate</DropdownMenuItem>- </div>+ </TooltipTrigger>+ <TooltipContent side="left">Access Restricted</TooltipContent></Tooltip>- <Tooltip- content={cannotEditKmipClient ? "Access Restricted" : ""}- position="left"- >- <div>+ <Tooltip open={cannotEditKmipClient ? undefined : false}>+ <TooltipTrigger asChild><DropdownMenuItemonClick={() => handlePopUpOpen("upsertKmipClient", kmipClient)}- icon={<FontAwesomeIcon icon={faEdit} />}- iconPos="left"isDisabled={cannotEditKmipClient}+ isDisabledFocusable={cannotEditKmipClient}>+ <PencilIcon />Edit KMIP Client</DropdownMenuItem>- </div>+ </TooltipTrigger>+ <TooltipContent side="left">Access Restricted</TooltipContent></Tooltip>- <Tooltip- content={cannotDeleteKmipClient ? "Access Restricted" : ""}- position="left"- >- <div>+ <Tooltip open={cannotDeleteKmipClient ? undefined : false}>+ <TooltipTrigger asChild><DropdownMenuItemonClick={() => handlePopUpOpen("deleteKmipClient", kmipClient)}- icon={<FontAwesomeIcon icon={faTrash} />}- iconPos="left"isDisabled={cannotDeleteKmipClient}+ isDisabledFocusable={cannotDeleteKmipClient}+ variant="danger">+ <TrashIcon />Delete KMIP Client</DropdownMenuItem>- </div>+ </TooltipTrigger>+ <TooltipContent side="left">Access Restricted</TooltipContent></Tooltip></DropdownMenuContent></DropdownMenu>- </Td>- </Tr>+ </TableCell>+ </TableRow>);})}- </TBody>+ </TableBody></Table>- {!isPending && totalCount > 0 && (- <Pagination- count={totalCount}- page={page}- perPage={perPage}- onChangePage={(newPage) => setPage(newPage)}- onChangePerPage={handlePerPageChange}- />- )}- {!isPending && kmipClients.length === 0 && (- <EmptyState- title={- debouncedSearch.trim().length > 0- ? "No KMIP clients match search filter"- : "No KMIP clients have been added to this project"- }- icon={faUser}- />- )}- </TableContainer>- <DeleteKmipClientModal- isOpen={popUp.deleteKmipClient.isOpen}- onOpenChange={(isOpen) => handlePopUpToggle("deleteKmipClient", isOpen)}- kmipClient={popUp.deleteKmipClient.data as TKmipClient}- />- <KmipClientModal- isOpen={popUp.upsertKmipClient.isOpen}- onOpenChange={(isOpen) => handlePopUpToggle("upsertKmipClient", isOpen)}- kmipClient={popUp.upsertKmipClient.data as TKmipClient | null}- />- <CreateKmipClientCertificateModal- isOpen={popUp.generateKmipClientCert.isOpen}- onOpenChange={(isOpen) => handlePopUpToggle("generateKmipClientCert", isOpen)}- kmipClient={popUp.generateKmipClientCert.data as TKmipClient | null}- displayNewClientCertificate={(certificate) =>- handlePopUpOpen("displayKmipClientCert", certificate)- }- />- <KmipClientCertificateModal- isOpen={popUp.displayKmipClientCert.isOpen}- onOpenChange={(isOpen) => handlePopUpToggle("displayKmipClientCert", isOpen)}- certificate={popUp.displayKmipClientCert.data}- />- <UpgradePlanModal- paywallKey="kms.kmip-client"- isOpen={popUp.upgradePlan.isOpen}- onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}- text="Your current plan does not include access to KMIP. To unlock this feature, please upgrade to Infisical Enterprise plan."- isEnterpriseFeature={popUp.upgradePlan.data?.isEnterpriseFeature}- />- </div>- </motion.div>+ )}+ {!isPending && totalCount > 0 && (+ <Pagination+ count={totalCount}+ page={page}+ perPage={perPage}+ onChangePage={(newPage) => setPage(newPage)}+ onChangePerPage={handlePerPageChange}+ />+ )}+ </CardContent>+ <DeleteKmipClientModal+ isOpen={popUp.deleteKmipClient.isOpen}+ onOpenChange={(isOpen) => handlePopUpToggle("deleteKmipClient", isOpen)}+ kmipClient={popUp.deleteKmipClient.data as TKmipClient}+ />+ <KmipClientModal+ isOpen={popUp.upsertKmipClient.isOpen}+ onOpenChange={(isOpen) => handlePopUpToggle("upsertKmipClient", isOpen)}+ kmipClient={popUp.upsertKmipClient.data as TKmipClient | null}+ />+ <CreateKmipClientCertificateModal+ isOpen={popUp.generateKmipClientCert.isOpen}+ onOpenChange={(isOpen) => handlePopUpToggle("generateKmipClientCert", isOpen)}+ kmipClient={popUp.generateKmipClientCert.data as TKmipClient | null}+ displayNewClientCertificate={(certificate) =>+ handlePopUpOpen("displayKmipClientCert", certificate)+ }+ />+ <KmipClientCertificateModal+ isOpen={popUp.displayKmipClientCert.isOpen}+ onOpenChange={(isOpen) => handlePopUpToggle("displayKmipClientCert", isOpen)}+ certificate={popUp.displayKmipClientCert.data}+ />+ <UpgradePlanModal+ paywallKey="kms.kmip-client"+ isOpen={popUp.upgradePlan.isOpen}+ onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}+ text="Your current plan does not include access to KMIP. To unlock this feature, please upgrade to Infisical Enterprise plan."+ isEnterpriseFeature={popUp.upgradePlan.data?.isEnterpriseFeature}+ />+ </Card>);};diff --git a/frontend/src/pages/kms/OverviewPage/components/CmekModal.tsx b/frontend/src/pages/kms/OverviewPage/components/CmekModal.tsxindex 1e096890c2..8cf643fde9 100644--- a/frontend/src/pages/kms/OverviewPage/components/CmekModal.tsx+++ b/frontend/src/pages/kms/OverviewPage/components/CmekModal.tsx@@ -3,27 +3,33 @@ import { zodResolver } from "@hookform/resolvers/zod";import { z } from "zod";import { createNotification } from "@app/components/notifications";-import {- Button,- FormControl,- Input,- Modal,- ModalClose,- ModalContent,- Select,- SelectItem,- TextArea-} from "@app/components/v2";import {Badge,+ Button,Field,FieldContent,FieldDescription,+ FieldError,+ FieldLabel,FieldTitle,+ Input,+ Select,+ SelectContent,+ SelectItem,+ SelectTrigger,+ SelectValue,+ Sheet,+ SheetClose,+ SheetContent,+ SheetDescription,+ SheetFooter,+ SheetHeader,+ SheetTitle,+ TextArea,Toggle} from "@app/components/v3";import { useProject, useSubscription } from "@app/context";-import { keyUsageDefaultOption, kmsKeyUsageOptions } from "@app/helpers/kms";+import { formatKmsKeyAlgorithm, keyUsageDefaultOption, kmsKeyUsageOptions } from "@app/helpers/kms";import {AllowedEncryptionKeyAlgorithms,AsymmetricKeyAlgorithm,@@ -121,151 +127,181 @@ const CmekForm = ({ onComplete, cmek }: FormProps) => {const selectedKeyUsage = watch("keyUsage");return (- <form onSubmit={handleSubmit(handleCreateCmek)}>- <FormControl- helperText="Name must be slug-friendly"- errorText={errors.name?.message}- isError={Boolean(errors.name?.message)}- label="Name"- >- <Input autoFocus placeholder="my-secret-key" {...register("name")} autoComplete="off" />- </FormControl>- <div className="flex w-full items-center gap-2">- {!isUpdate && (- <>- <Controller- control={control}- name="keyUsage"- render={({ field: { onChange, ...field }, fieldState: { error } }) => (- <FormControl- className="w-full"- tooltipText={- <div className="space-y-4">- {Object.entries(KmsKeyUsage).map(([key, value]) => (- <div key={`key-usage-${key}`}>- <p className="font-bold">{kmsKeyUsageOptions[value].label}</p>- <p>{kmsKeyUsageOptions[value].tooltip}</p>- </div>- ))}- </div>- }- label="Key Usage"- errorText={error?.message}- isError={Boolean(error)}- >- <Select- defaultValue={field.value}- onValueChange={(e) => {- if (keyUsageDefaultOption[e as KmsKeyUsage]) {- setValue("algorithm", keyUsageDefaultOption[e as KmsKeyUsage], {- shouldDirty: true,- shouldValidate: true- });- }-- onChange(e);- }}- className="w-full"- >- {Object.entries(KmsKeyUsage)?.map(([key, value]) => (- <SelectItem value={value} key={`key-usage-${key}`}>- {kmsKeyUsageOptions[value].label}- </SelectItem>- ))}- </Select>- </FormControl>- )}- />- <Controller- control={control}- name="algorithm"- render={({ field: { onChange, ...field }, fieldState: { error } }) => (- <FormControl- className="w-full"- label="Algorithm"- errorText={error?.message}- isError={Boolean(error)}- >- <Select- defaultValue={field.value}- value={field.value}- onValueChange={onChange}- className="w-full"- >- {Object.entries(AllowedEncryptionKeyAlgorithms)- // eslint-disable-next-line @typescript-eslint/no-unused-vars- ?.filter(([_, value]) => {- if (selectedKeyUsage === KmsKeyUsage.ENCRYPT_DECRYPT) {- return Object.values(SymmetricKeyAlgorithm).includes(- value as unknown as SymmetricKeyAlgorithm- );- }- if (selectedKeyUsage === KmsKeyUsage.SIGN_VERIFY) {- return Object.values(AsymmetricKeyAlgorithm).includes(- value as unknown as AsymmetricKeyAlgorithm- );+ <form onSubmit={handleSubmit(handleCreateCmek)} className="flex min-h-0 flex-1 flex-col">+ <div className="thin-scrollbar flex-1 space-y-4 overflow-y-auto p-4">+ <Field data-invalid={Boolean(errors.name)}>+ <FieldLabel htmlFor="cmek-name">+ Name{" "}+ <span aria-hidden className="text-danger">+ *+ </span>+ </FieldLabel>+ <Input+ id="cmek-name"+ autoFocus+ placeholder="my-secret-key"+ {...register("name")}+ autoComplete="off"+ aria-required+ isError={Boolean(errors.name)}+ />+ <FieldDescription>Name must be slug-friendly.</FieldDescription>+ <FieldError>{errors.name?.message}</FieldError>+ </Field>+ <div className="space-y-4">+ {!isUpdate && (+ <>+ <Controller+ control={control}+ name="keyUsage"+ render={({ field: { onChange, value: keyUsage }, fieldState: { error } }) => (+ <Field data-invalid={Boolean(error)}>+ <FieldLabel htmlFor="cmek-key-usage">Key Usage</FieldLabel>+ <Select+ value={keyUsage}+ onValueChange={(e) => {+ onChange(e);+ if (keyUsageDefaultOption[e as KmsKeyUsage]) {+ setValue("algorithm", keyUsageDefaultOption[e as KmsKeyUsage], {+ shouldDirty: true,+ shouldValidate: true+ });}- if (selectedKeyUsage === KmsKeyUsage.GENERATE_VERIFY_MAC) {- return Object.values(HmacAlgorithm).includes(- value as unknown as HmacAlgorithm- );- }-- return false;- })- // eslint-disable-next-line @typescript-eslint/no-unused-vars- .map(([_, value]) => {- const isPqc = value.startsWith("ML_DSA");- const isDisabled = isPqc && !subscription?.kmsPqc;- const isLegacyHmac =- value === HmacAlgorithm.HMAC_SHA_1 ||- value === HmacAlgorithm.HMAC_SHA_224;- return (- <SelectItem- value={value}- key={`encryption-algorithm-${value}`}- isDisabled={isDisabled}- >- <div className="flex items-center gap-2">- <span className="uppercase">{value.replaceAll("-", " ")}</span>- {isDisabled && <Badge variant="info">Enterprise</Badge>}- {isLegacyHmac && <Badge variant="warning">Legacy</Badge>}- </div>+ }}+ >+ <SelectTrigger+ id="cmek-key-usage"+ className="w-full"+ isError={Boolean(error)}+ >+ <SelectValue />+ </SelectTrigger>+ <SelectContent>+ {Object.entries(KmsKeyUsage)?.map(([key, value]) => (+ <SelectItem value={value} key={`key-usage-${key}`}>+ {kmsKeyUsageOptions[value].label}</SelectItem>- );- })}- </Select>- </FormControl>- )}- />- </>+ ))}+ </SelectContent>+ </Select>+ <FieldDescription>{kmsKeyUsageOptions[keyUsage].tooltip}</FieldDescription>+ <FieldError>{error?.message}</FieldError>+ </Field>+ )}+ />+ <Controller+ control={control}+ name="algorithm"+ render={({ field: { onChange, value: algorithm }, fieldState: { error } }) => (+ <Field data-invalid={Boolean(error)}>+ <FieldLabel htmlFor="cmek-algorithm">Algorithm</FieldLabel>+ <Select key={selectedKeyUsage} value={algorithm} onValueChange={onChange}>+ <SelectTrigger+ id="cmek-algorithm"+ className="w-full"+ isError={Boolean(error)}+ >+ <SelectValue />+ </SelectTrigger>+ <SelectContent>+ {Object.entries(AllowedEncryptionKeyAlgorithms)+ // eslint-disable-next-line @typescript-eslint/no-unused-vars+ ?.filter(([_, value]) => {+ if (selectedKeyUsage === KmsKeyUsage.ENCRYPT_DECRYPT) {+ return Object.values(SymmetricKeyAlgorithm).includes(+ value as unknown as SymmetricKeyAlgorithm+ );+ }+ if (selectedKeyUsage === KmsKeyUsage.SIGN_VERIFY) {+ return Object.values(AsymmetricKeyAlgorithm).includes(+ value as unknown as AsymmetricKeyAlgorithm+ );+ }+ if (selectedKeyUsage === KmsKeyUsage.GENERATE_VERIFY_MAC) {+ return Object.values(HmacAlgorithm).includes(+ value as unknown as HmacAlgorithm+ );+ }++ return false;+ })+ // eslint-disable-next-line @typescript-eslint/no-unused-vars+ .map(([_, value]) => {+ const isPqc = value.startsWith("ML_DSA");+ const isDisabled = isPqc && !subscription?.kmsPqc;+ const isLegacyHmac =+ value === HmacAlgorithm.HMAC_SHA_1 ||+ value === HmacAlgorithm.HMAC_SHA_224;+ return (+ <SelectItem+ value={value}+ key={`encryption-algorithm-${value}`}+ disabled={isDisabled}+ >+ <div className="flex items-center gap-2">+ <span>{formatKmsKeyAlgorithm(value)}</span>+ {isDisabled && <Badge variant="info">Enterprise</Badge>}+ {isLegacyHmac && <Badge variant="warning">Legacy</Badge>}+ </div>+ </SelectItem>+ );+ })}+ </SelectContent>+ </Select>+ <FieldError>{error?.message}</FieldError>+ </Field>+ )}+ />+ </>+ )}+ </div>+ <Field data-invalid={Boolean(errors.description)}>+ <FieldLabel htmlFor="cmek-description">Description (optional)</FieldLabel>+ <TextArea+ id="cmek-description"+ {...register("description")}+ isError={Boolean(errors.description)}+ />+ <FieldError>{errors.description?.message}</FieldError>+ </Field>+ {!isUpdate && (+ <Controller+ control={control}+ name="isExportable"+ render={({ field: { onChange, value } }) => (+ <Field orientation="horizontal">+ <FieldContent>+ <FieldTitle>Allow Export</FieldTitle>+ <FieldDescription>+ Allow users with the export permission to export this key's material. This+ cannot be changed after the key is created.+ </FieldDescription>+ </FieldContent>+ <Toggle+ id="is-exportable"+ aria-label="Allow Export"+ variant="project"+ checked={value}+ onCheckedChange={onChange}+ />+ </Field>+ )}+ />)}- </div>- <FormControl- label="Description (optional)"- errorText={errors.description?.message}- isError={Boolean(errors.description?.message)}- >- <TextArea- className="max-h-80 min-h-40 max-w-full min-w-full"- {...register("description")}- />- </FormControl>- {!isUpdate && (<Controllercontrol={control}- name="isExportable"+ name="hasDeleteProtection"render={({ field: { onChange, value } }) => (- <Field orientation="horizontal" className="mb-6">+ <Field orientation="horizontal"><FieldContent>- <FieldTitle>Allow Export</FieldTitle>+ <FieldTitle>Delete Protection</FieldTitle><FieldDescription>- Allow users with the export permission to export this key's material. This- cannot be changed after the key is created.+ Prevents this key from being deleted while enabled.</FieldDescription></FieldContent><Toggle- id="is-exportable"+ id="has-delete-protection"+ aria-label="Delete Protection"variant="project"checked={value}onCheckedChange={onChange}@@ -273,53 +309,35 @@ const CmekForm = ({ onComplete, cmek }: FormProps) => {</Field>)}/>- )}- <Controller- control={control}- name="hasDeleteProtection"- render={({ field: { onChange, value } }) => (- <Field orientation="horizontal" className="mb-6">- <FieldContent>- <FieldTitle>Delete Protection</FieldTitle>- <FieldDescription>- Prevents this key from being deleted while enabled.- </FieldDescription>- </FieldContent>- <Toggle- id="has-delete-protection"- variant="project"- checked={value}- onCheckedChange={onChange}- />- </Field>- )}- />- <div className="flex items-center">- <Button- className="mr-4"- size="sm"- type="submit"- isLoading={isSubmitting}- isDisabled={isSubmitting}- >- {isUpdate ? "Update" : "Add"} Key- </Button>- <ModalClose asChild>- <Button colorSchema="secondary" variant="plain">+ </div>+ <SheetFooter className="justify-end border-t">+ <SheetClose asChild>+ <Button variant="ghost" type="button">Cancel</Button>- </ModalClose>- </div>+ </SheetClose>+ <Button variant="project" type="submit" isPending={isSubmitting} isDisabled={isSubmitting}>+ {isUpdate ? "Update" : "Add"} Key+ </Button>+ </SheetFooter></form>);};export const CmekModal = ({ isOpen, onOpenChange, cmek }: Props) => {return (- <Modal isOpen={isOpen} onOpenChange={onOpenChange}>- <ModalContent title={`${cmek ? "Update" : "Add"} Key`}>- <CmekForm onComplete={() => onOpenChange(false)} cmek={cmek} />- </ModalContent>- </Modal>+ <Sheet open={isOpen} onOpenChange={onOpenChange}>+ <SheetContent>+ <SheetHeader>+ <SheetTitle>{cmek ? "Update" : "Add"} Key</SheetTitle>+ <SheetDescription>+ Configure the key and its supported cryptographic operations.+ </SheetDescription>+ </SheetHeader>+ {isOpen && (+ <CmekForm key={cmek?.id ?? "new"} onComplete={() => onOpenChange(false)} cmek={cmek} />+ )}+ </SheetContent>+ </Sheet>);};diff --git a/frontend/src/pages/kms/OverviewPage/components/CmekTable.tsx b/frontend/src/pages/kms/OverviewPage/components/CmekTable.tsxindex c42ad6bcc6..82d4ce6d8e 100644--- a/frontend/src/pages/kms/OverviewPage/components/CmekTable.tsx+++ b/frontend/src/pages/kms/OverviewPage/components/CmekTable.tsx@@ -1,4 +1,4 @@-import { useEffect, useRef, useState } from "react";+import { ReactNode, useEffect, useRef, useState } from "react";import {CheckIcon,ChevronDownIcon,@@ -10,9 +10,9 @@ import {FileSignatureIcon,ImportIcon,InfoIcon,+ KeyIcon,LockIcon,PencilIcon,- PlusIcon,RotateCwIcon,SearchIcon,TrashIcon,@@ -27,7 +27,6 @@ import { Spinner } from "@app/components/v2";import {Badge,Button,- ButtonGroup,Card,CardAction,CardContent,@@ -69,7 +68,7 @@ import {useProject,useProjectPermission} from "@app/context";-import { kmsKeyUsageOptions } from "@app/helpers/kms";+import { formatKmsKeyAlgorithm, kmsKeyUsageOptions } from "@app/helpers/kms";import {getUserTablePreference,PreferenceKey,@@ -117,6 +116,32 @@ const getStatusBadgeProps = (return { variant: "success", label: "Active" };};+const KeyAction = ({+ children,+ onClick,+ disabledReason,+ variant+}: {+ children: ReactNode;+ onClick: () => void;+ disabledReason?: string;+ variant?: "danger";+}) => (+ <Tooltip open={disabledReason ? undefined : false}>+ <TooltipTrigger asChild>+ <DropdownMenuItem+ onClick={onClick}+ isDisabled={Boolean(disabledReason)}+ isDisabledFocusable={Boolean(disabledReason)}+ variant={variant}+ >+ {children}+ </DropdownMenuItem>+ </TooltipTrigger>+ <TooltipContent side="left">{disabledReason}</TooltipContent>+ </Tooltip>+);+export const CmekTable = () => {const { currentProject } = useProject();const { permission } = useProjectPermission();@@ -329,57 +354,54 @@ export const CmekTable = () => {</CardTitle><CardDescription>Manage keys and perform cryptographic operations.</CardDescription><CardAction>- <ButtonGroup>- <ProjectPermissionCan- I={ProjectPermissionActions.Create}- a={ProjectPermissionSub.Cmek}- >- {(isAllowed) => (- <Tooltip open={!isAllowed ? undefined : false}>- <TooltipTrigger asChild>- <Button- className="rounded-r-none"- variant="project"- onClick={() => handlePopUpOpen("upsertKey", null)}- isDisabled={!isAllowed}- >- <PlusIcon className="mr-2 size-4" />- Add Key- </Button>- </TooltipTrigger>- <TooltipContent>Access Denied</TooltipContent>- </Tooltip>- )}- </ProjectPermissionCan>- <DropdownMenu>- <DropdownMenuTrigger asChild>- <IconButton variant="project" aria-label="More key options">- <ChevronDownIcon />- </IconButton>- </DropdownMenuTrigger>- <DropdownMenuContent align="end">- <ProjectPermissionCan- I={ProjectPermissionActions.Create}- a={ProjectPermissionSub.Cmek}- >- {(isAllowed) => (- <Tooltip open={!isAllowed ? undefined : false}>- <TooltipTrigger className="block w-full">- <DropdownMenuItem- onClick={() => handlePopUpOpen("importKeys")}- isDisabled={!isAllowed}- >- <ImportIcon className="size-4" />- Import Keys- </DropdownMenuItem>- </TooltipTrigger>- <TooltipContent side="left">Access Restricted</TooltipContent>- </Tooltip>- )}- </ProjectPermissionCan>- </DropdownMenuContent>- </DropdownMenu>- </ButtonGroup>+ <DropdownMenu>+ <DropdownMenuTrigger asChild>+ <Button variant="project">+ <ChevronDownIcon />+ Add Key+ </Button>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="end">+ <ProjectPermissionCan+ I={ProjectPermissionActions.Create}+ a={ProjectPermissionSub.Cmek}+ >+ {(isAllowed) => (+ <Tooltip open={!isAllowed ? undefined : false}>+ <TooltipTrigger className="block w-full">+ <DropdownMenuItem+ onClick={() => handlePopUpOpen("upsertKey", null)}+ isDisabled={!isAllowed}+ >+ <KeyIcon className="size-4" />+ Create Key+ </DropdownMenuItem>+ </TooltipTrigger>+ <TooltipContent side="left">Access Restricted</TooltipContent>+ </Tooltip>+ )}+ </ProjectPermissionCan>+ <ProjectPermissionCan+ I={ProjectPermissionActions.Create}+ a={ProjectPermissionSub.Cmek}+ >+ {(isAllowed) => (+ <Tooltip open={!isAllowed ? undefined : false}>+ <TooltipTrigger className="block w-full">+ <DropdownMenuItem+ onClick={() => handlePopUpOpen("importKeys")}+ isDisabled={!isAllowed}+ >+ <ImportIcon className="size-4" />+ Import Keys+ </DropdownMenuItem>+ </TooltipTrigger>+ <TooltipContent side="left">Access Restricted</TooltipContent>+ </Tooltip>+ )}+ </ProjectPermissionCan>+ </DropdownMenuContent>+ </DropdownMenu></CardAction></CardHeader><CardContent>@@ -496,6 +518,21 @@ export const CmekTable = () => {const cannotExportKey = isAsymmetricKey? (cannotExportPrivateKey || !isExportable) && cannotReadKey: cannotExportPrivateKey || !isExportable;+ const disabledKeyReason = isDisabled ? "This key is disabled" : undefined;+ let exportDisabledReason = disabledKeyReason;+ if (cannotExportKey) {+ exportDisabledReason =+ cannotExportPrivateKey && (!isAsymmetricKey || cannotReadKey)+ ? "Access Restricted"+ : "This key was created as non-exportable";+ }+ let deleteDisabledReason: string | undefined;+ if (cannotDeleteKey) {+ deleteDisabledReason = "Access Restricted";+ } else if (hasDeleteProtection) {+ deleteDisabledReason =+ "Disable delete protection on this key before deleting it";+ }return (<TableRow@@ -591,7 +628,7 @@ export const CmekTable = () => {</Tooltip></div></TableCell>- <TableCell className="uppercase">{algorithm}</TableCell>+ <TableCell>{formatKmsKeyAlgorithm(algorithm)}</TableCell><TableCell><Badge variant={variant}>{label}</Badge></TableCell>@@ -619,84 +656,98 @@ export const CmekTable = () => {<DropdownMenuContent align="end" className="min-w-[160px]">{keyUsage === KmsKeyUsage.ENCRYPT_DECRYPT && (<>- <DropdownMenuItem+ <KeyActiononClick={() => handlePopUpOpen("encryptData", cmek)}- isDisabled={cannotEncryptData || isDisabled}+ disabledReason={+ cannotEncryptData ? "Access Restricted" : disabledKeyReason+ }><LockIcon className="mr-2 size-4" />Encrypt Data- </DropdownMenuItem>- <DropdownMenuItem+ </KeyAction>+ <KeyActiononClick={() => handlePopUpOpen("decryptData", cmek)}- isDisabled={cannotDecryptData || isDisabled}+ disabledReason={+ cannotDecryptData ? "Access Restricted" : disabledKeyReason+ }><UnlockIcon className="mr-2 size-4" />Decrypt Data- </DropdownMenuItem>+ </KeyAction></>)}{keyUsage === KmsKeyUsage.SIGN_VERIFY && (<>- <DropdownMenuItem+ <KeyActiononClick={() => handlePopUpOpen("signData", cmek)}- isDisabled={cannotSignData || isDisabled}+ disabledReason={+ cannotSignData ? "Access Restricted" : disabledKeyReason+ }><FileSignatureIcon className="mr-2 size-4" />Sign Data- </DropdownMenuItem>- <DropdownMenuItem+ </KeyAction>+ <KeyActiononClick={() => handlePopUpOpen("verifyData", cmek)}- isDisabled={cannotVerifyData || isDisabled}+ disabledReason={+ cannotVerifyData ? "Access Restricted" : disabledKeyReason+ }><CircleCheckIcon className="mr-2 size-4" />Verify Data- </DropdownMenuItem>+ </KeyAction></>)}{keyUsage === KmsKeyUsage.GENERATE_VERIFY_MAC && (<>- <DropdownMenuItem+ <KeyActiononClick={() => handlePopUpOpen("generateMac", cmek)}- isDisabled={cannotGenerateMac || isDisabled}+ disabledReason={+ cannotGenerateMac ? "Access Restricted" : disabledKeyReason+ }><FileSignatureIcon className="mr-2 size-4" />Generate MAC- </DropdownMenuItem>- <DropdownMenuItem+ </KeyAction>+ <KeyActiononClick={() => handlePopUpOpen("verifyMac", cmek)}- isDisabled={cannotVerifyMac || isDisabled}+ disabledReason={+ cannotVerifyMac ? "Access Restricted" : disabledKeyReason+ }><CircleCheckIcon className="mr-2 size-4" />Verify MAC- </DropdownMenuItem>+ </KeyAction></>)}- <DropdownMenuItem+ <KeyActiononClick={() => handlePopUpOpen("exportKey", cmek)}- isDisabled={cannotExportKey || isDisabled}+ disabledReason={exportDisabledReason}><DownloadIcon className="mr-2 size-4" />Export Key- </DropdownMenuItem>- <DropdownMenuItem+ </KeyAction>+ <KeyActiononClick={() => handlePopUpOpen("upsertKey", cmek)}- isDisabled={cannotEditKey}+ disabledReason={cannotEditKey ? "Access Restricted" : undefined}><PencilIcon className="mr-2 size-4" />Edit Key- </DropdownMenuItem>+ </KeyAction>{keyUsage === KmsKeyUsage.ENCRYPT_DECRYPT && (- <DropdownMenuItem+ <KeyActiononClick={() => handlePopUpOpen("rotateKey", cmek)}- isDisabled={cannotRotateKey || isDisabled}+ disabledReason={+ cannotRotateKey ? "Access Restricted" : disabledKeyReason+ }><RotateCwIcon className="mr-2 size-4" />Rotate Key- </DropdownMenuItem>+ </KeyAction>)}- <DropdownMenuItem+ <KeyActiononClick={() => handleDisableCmek(cmek)}- isDisabled={cannotEditKey}+ disabledReason={cannotEditKey ? "Access Restricted" : undefined}>{isDisabled ? (<CircleCheckIcon className="mr-2 size-4" />@@ -704,28 +755,15 @@ export const CmekTable = () => {<CircleXIcon className="mr-2 size-4" />)}{isDisabled ? "Enable" : "Disable"} Key- </DropdownMenuItem>- <Tooltip- open={cannotDeleteKey || hasDeleteProtection ? undefined : false}+ </KeyAction>+ <KeyAction+ onClick={() => handlePopUpOpen("deleteKey", cmek)}+ disabledReason={deleteDisabledReason}+ variant="danger">- <TooltipTrigger asChild>- <div>- <DropdownMenuItem- onClick={() => handlePopUpOpen("deleteKey", cmek)}- isDisabled={cannotDeleteKey || hasDeleteProtection}- variant="danger"- >- <TrashIcon className="mr-2 size-4" />- Delete Key- </DropdownMenuItem>- </div>- </TooltipTrigger>- <TooltipContent side="left">- {cannotDeleteKey- ? "Access Restricted"- : "Disable delete protection on this key before deleting it"}- </TooltipContent>- </Tooltip>+ <TrashIcon className="mr-2 size-4" />+ Delete Key+ </KeyAction></DropdownMenuContent></DropdownMenu></div>