Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

Address PR comments

Carlos Monastyrskif31153af367d
diff --git a/backend/src/ee/services/audit-log/audit-log-types.ts b/backend/src/ee/services/audit-log/audit-log-types.ts
index 37622e528d..678c6dec63 100644
--- a/backend/src/ee/services/audit-log/audit-log-types.ts
+++ b/backend/src/ee/services/audit-log/audit-log-types.ts
@@ -3017,7 +3017,6 @@ type TCaKeySourceAuditMetadata = {
keySource?: string;
hsmConnectorId?: string;
hsmConnectorName?: string;
- hsmKeyLabel?: string;
appConnectionId?: string;
appConnectionName?: string;
externalKeyId?: string;
diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.ts
index f38c8e9422..ef609c0de5 100644
--- a/backend/src/lib/api-docs/constants.ts
+++ b/backend/src/lib/api-docs/constants.ts
@@ -2853,7 +2853,7 @@ export const CertificateAuthorities = {
hsmConnectorId:
"The ID of the HSM Connector to generate and store the CA's signing key in. Required when keySource is 'hsm'.",
hsmKeyLabel:
- "The label of the CA's signing key on the HSM. Not user-supplied: it is the HSM Connector's configured key name prefix followed by a per-CA label built from the CA name and a random 5-character suffix (ca-<name>-<slug>).",
+ "Deprecated: use externalKeyId, which holds the same key label for HSM-backed CAs. The label of the CA's signing key on the HSM.",
appConnectionId:
"The ID of the AWS connection used to create the CA's signing key in AWS KMS and to sign with it. Required when keySource is 'aws-kms'.",
appConnectionName: "The name of the AWS connection the CA's signing key is reached through. Not user-supplied.",
@@ -2861,7 +2861,7 @@ export const CertificateAuthorities = {
region:
"The AWS region the CA's signing key is created in. Required when keySource is 'aws-kms', and returned when reading the CA.",
externalKeyId:
- "The ARN of the CA's signing key in AWS KMS. Not user-supplied: the key is created when the CA is created.",
+ "The identifier of the CA's signing key in its key source: the key ARN for AWS KMS, or the key label for HSM. Not user-supplied: the key is created when the CA is created.",
crlDistributionPointUrls:
"Additional CRL Distribution Point URLs (HTTP/HTTPS) embedded in every certificate issued by this CA. Up to 4 URLs; the Infisical-managed CRL endpoint is included by default unless disabled.",
disableManagedCrlDistributionPointUrl:
diff --git a/backend/src/services/certificate-authority/ca-key-source/hsm-ca-key-source.ts b/backend/src/services/certificate-authority/ca-key-source/hsm-ca-key-source.ts
index a4d24a49a9..12b9ef00bb 100644
--- a/backend/src/services/certificate-authority/ca-key-source/hsm-ca-key-source.ts
+++ b/backend/src/services/certificate-authority/ca-key-source/hsm-ca-key-source.ts
@@ -61,7 +61,8 @@ export const hsmCaKeySourceFactory = ({
return {
hsmConnectorId: reference.hsmConnectorId ?? undefined,
hsmConnectorName: hsmConnector?.name,
- hsmKeyLabel: reference.externalKeyId ?? undefined
+ hsmKeyLabel: reference.externalKeyId ?? undefined,
+ externalKeyId: reference.externalKeyId ?? undefined
};
},
diff --git a/backend/src/services/certificate-authority/certificate-authority-fns.ts b/backend/src/services/certificate-authority/certificate-authority-fns.ts
index 88fd3e42d6..296c1fd0d5 100644
--- a/backend/src/services/certificate-authority/certificate-authority-fns.ts
+++ b/backend/src/services/certificate-authority/certificate-authority-fns.ts
@@ -732,7 +732,6 @@ const CA_KEY_SOURCE_AUDIT_FIELDS = [
"keySource",
"hsmConnectorId",
"hsmConnectorName",
- "hsmKeyLabel",
"appConnectionId",
"appConnectionName",
"externalKeyId",
diff --git a/backend/src/services/certificate-authority/internal/internal-certificate-authority-schemas.ts b/backend/src/services/certificate-authority/internal/internal-certificate-authority-schemas.ts
index dfa83c04f7..8d4cef6b69 100644
--- a/backend/src/services/certificate-authority/internal/internal-certificate-authority-schemas.ts
+++ b/backend/src/services/certificate-authority/internal/internal-certificate-authority-schemas.ts
@@ -77,7 +77,12 @@ export const InternalCertificateAuthorityConfigurationSchema = z
.uuid()
.optional()
.describe(CertificateAuthorities.CONFIGURATIONS.INTERNAL.hsmConnectorId),
- hsmKeyLabel: z.string().optional().describe(CertificateAuthorities.CONFIGURATIONS.INTERNAL.hsmKeyLabel),
+ hsmKeyLabel: z
+ .string()
+ .optional()
+ .describe(
+ JSON.stringify({ deprecated: true, description: CertificateAuthorities.CONFIGURATIONS.INTERNAL.hsmKeyLabel })
+ ),
appConnectionId: z
.string()
.uuid()
diff --git a/frontend/src/components/license/UpgradeGate/index.ts b/frontend/src/components/license/UpgradeGate/index.ts
index 38feb163ec..df205081a1 100644
--- a/frontend/src/components/license/UpgradeGate/index.ts
+++ b/frontend/src/components/license/UpgradeGate/index.ts
@@ -29,7 +29,6 @@ export {
export { hasEnvironmentCapacity } from "./environment-limit";
export type { UpgradeIntent } from "./upgrade-intents";
export {
- AwsKmsCaSigningUpgradeIntent,
BillingPlan,
BillingProduct,
buildUpgradeReturnPath,
diff --git a/frontend/src/components/license/UpgradeGate/upgrade-intents.ts b/frontend/src/components/license/UpgradeGate/upgrade-intents.ts
index f363d0d0b1..5e3ed97f4f 100644
--- a/frontend/src/components/license/UpgradeGate/upgrade-intents.ts
+++ b/frontend/src/components/license/UpgradeGate/upgrade-intents.ts
@@ -37,7 +37,6 @@ export const UpgradeFeature = {
CertificateAuthorities: "certificate-authorities",
ExternalCertificateAuthorities: "external-certificate-authorities",
PostQuantumCertificates: "post-quantum-certificates",
- AwsKmsCaSigning: "aws-kms-ca-signing",
CertificateIssuanceLimits: "certificate-issuance-limits",
Pam: "pam",
PamAccountLimit: "pam-account-limit",
@@ -313,16 +312,6 @@ export const PostQuantumCertificatesUpgradeIntent = {
"Post-quantum certificate algorithms are included with the Enterprise plan. Review the plan to continue."
} satisfies UpgradeIntent;
-export const AwsKmsCaSigningUpgradeIntent = {
- featureKey: UpgradeFeature.AwsKmsCaSigning,
- productKey: BillingProduct.CertificateManagement,
- planKey: BillingPlan.Enterprise,
- upgradeLabel: "Unlock AWS KMS Signing Keys",
- title: "Keep CA Keys in AWS KMS",
- description:
- "Keeping certificate authority signing keys in AWS KMS is included with the Enterprise plan. Review the plan to continue."
-} satisfies UpgradeIntent;
-
export const CertificateIssuanceLimitsUpgradeIntent = {
featureKey: UpgradeFeature.CertificateIssuanceLimits,
productKey: BillingProduct.CertificateManagement,
diff --git a/frontend/src/hooks/api/ca/types.ts b/frontend/src/hooks/api/ca/types.ts
index 7b91b2f501..7d7706f491 100644
--- a/frontend/src/hooks/api/ca/types.ts
+++ b/frontend/src/hooks/api/ca/types.ts
@@ -160,7 +160,6 @@ export type TInternalCertificateAuthority = {
keySource?: CertKeySource;
hsmConnectorId?: string;
hsmConnectorName?: string;
- hsmKeyLabel?: string;
appConnectionId?: string;
appConnectionName?: string;
region?: string;
diff --git a/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaDetailsSection.tsx b/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaDetailsSection.tsx
index c36982947a..1dbb7d3b8e 100644
--- a/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaDetailsSection.tsx
+++ b/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaDetailsSection.tsx
@@ -321,11 +321,11 @@ export const CaDetailsSection = ({ caId }: Props) => {
{ca.configuration.hsmConnectorName ?? ca.configuration.hsmConnectorId ?? "-"}
</DetailValue>
</Detail>
- {ca.configuration.hsmKeyLabel && (
+ {ca.configuration.externalKeyId && (
<Detail>
<DetailLabel>HSM Key Label</DetailLabel>
<DetailValue className="font-mono text-xs break-all">
- {ca.configuration.hsmKeyLabel}
+ {ca.configuration.externalKeyId}
</DetailValue>
</Detail>
)}
diff --git a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaSection.tsx b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaSection.tsx
index fe5899d0e3..110969a038 100644
--- a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaSection.tsx
+++ b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaSection.tsx
@@ -95,7 +95,7 @@ export const CaSection = () => {
const caPendingDelete = caPendingDeleteData as TInternalCertificateAuthority | undefined;
const pendingDeleteHsmKeyLabel =
caPendingDelete?.configuration?.keySource === CertKeySource.Hsm
- ? caPendingDelete?.configuration?.hsmKeyLabel
+ ? caPendingDelete?.configuration?.externalKeyId
: undefined;
const pendingDeleteAwsKmsKeyArn =
caPendingDelete?.configuration?.keySource === CertKeySource.AwsKms
diff --git a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CreateCaWizard/CreateCaWizard.tsx b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CreateCaWizard/CreateCaWizard.tsx
index 7f6de12840..a5caa1100e 100644
--- a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CreateCaWizard/CreateCaWizard.tsx
+++ b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CreateCaWizard/CreateCaWizard.tsx
@@ -100,11 +100,6 @@ export const CreateCaWizard = ({ isOpen, onOpenChange }: Props) => {
enabled: isOpen && Boolean(subscription?.pkiAwsKmsSigning)
});
- const awsConnectionOptions = useMemo(
- () => awsConnections.map((c) => ({ id: c.id, name: c.name })),
- [awsConnections]
- );
-
const buildDefaultValues = (): CaWizardForm => ({
...DEFAULT_VALUES,
isOcspEnabled: Boolean(subscription?.pkiOcsp)
@@ -250,7 +245,7 @@ export const CreateCaWizard = ({ isOpen, onOpenChange }: Props) => {
form={form}
hsmConnectorOptions={hsmConnectorOptions}
isHsmConnectorsLoading={isHsmConnectorsLoading}
- awsConnectionOptions={awsConnectionOptions}
+ awsConnectionOptions={awsConnections}
isAwsConnectionsLoading={isAwsConnectionsLoading}
/>
)}
diff --git a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CreateCaWizard/KeyValidityStep.tsx b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CreateCaWizard/KeyValidityStep.tsx
index 31e754373b..40e8cb3ef9 100644
--- a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CreateCaWizard/KeyValidityStep.tsx
+++ b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CreateCaWizard/KeyValidityStep.tsx
@@ -1,8 +1,9 @@
+import { useState } from "react";
import { Controller, UseFormReturn } from "react-hook-form";
-import { Link } from "@tanstack/react-router";
+import { SingleValue } from "react-select";
+import { AppConnectionOption } from "@app/components/app-connections";
import {
- AwsKmsCaSigningUpgradeIntent,
PostQuantumCertificatesUpgradeIntent,
useUpgradeGate
} from "@app/components/license/UpgradeGate";
@@ -23,36 +24,42 @@ import {
SelectTrigger,
SelectValue
} from "@app/components/v3";
-import { useOrganization, useProjectPermission, useSubscription } from "@app/context";
+import { useProject, useProjectPermission, useSubscription } from "@app/context";
import {
+ ProjectPermissionAppConnectionActions,
ProjectPermissionHsmConnectorActions,
ProjectPermissionSub
} from "@app/context/ProjectPermissionContext/types";
+import { APP_CONNECTION_MAP } from "@app/helpers/appConnections";
+import { TAvailableAppConnection } from "@app/hooks/api/appConnections";
+import { AppConnection } from "@app/hooks/api/appConnections/enums";
import { InternalCaType } from "@app/hooks/api/ca/enums";
import { certKeyAlgorithms, isPqcAlgorithm } from "@app/hooks/api/certificates/constants";
import { CertKeyAlgorithm } from "@app/hooks/api/certificates/enums";
import { CertKeySource } from "@app/hooks/api/signers";
+import { AddAppConnectionModal } from "@app/pages/organization/AppConnections/AppConnectionsPage/components";
import { CaWizardForm } from "./schemas";
-import {
- AwsConnectionOption,
- HsmConnectorOption,
- isKeyAlgorithmSupportedByKeySource
-} from "./types";
+import { HsmConnectorOption, isKeyAlgorithmSupportedByKeySource } from "./types";
+
+const CREATE_AWS_CONNECTION_OPTION = {
+ id: `_create:${AppConnection.AWS}`,
+ name: `Create ${APP_CONNECTION_MAP[AppConnection.AWS].name} Connection`
+};
const KEY_SOURCE_DESCRIPTIONS: Record<CertKeySource, string> = {
[CertKeySource.Infisical]: "Infisical generates and manages the CA keypair for you.",
[CertKeySource.Hsm]:
"The CA keypair is generated on a Hardware Security Module and every signature is performed there.",
[CertKeySource.AwsKms]:
- "The CA keypair is generated in AWS KMS and every signature is performed there. The private key never leaves AWS."
+ "The CA keypair is generated in AWS KMS and every signature is performed there."
};
type Props = {
form: UseFormReturn<CaWizardForm>;
hsmConnectorOptions: HsmConnectorOption[];
isHsmConnectorsLoading: boolean;
- awsConnectionOptions: AwsConnectionOption[];
+ awsConnectionOptions: TAvailableAppConnection[];
isAwsConnectionsLoading: boolean;
};
@@ -64,11 +71,19 @@ export const KeyValidityStep = ({
isAwsConnectionsLoading
}: Props) => {
const { subscription } = useSubscription();
- const { currentOrg } = useOrganization();
const { openUpgradeGate, upgradeGate } = useUpgradeGate();
const isHsmLicensed = Boolean(subscription?.hsm);
const isAwsKmsLicensed = Boolean(subscription?.pkiAwsKmsSigning);
+ const { currentProject } = useProject();
const { permission } = useProjectPermission();
+ const [isCreateAwsConnectionOpen, setIsCreateAwsConnectionOpen] = useState(false);
+ const [createdAwsConnection, setCreatedAwsConnection] = useState<TAvailableAppConnection | null>(
+ null
+ );
+ const canCreateAppConnection = permission.can(
+ ProjectPermissionAppConnectionActions.Create,
+ ProjectPermissionSub.AppConnections
+ );
const canAttachHsm = permission.can(
ProjectPermissionHsmConnectorActions.Attach,
ProjectPermissionSub.HsmConnectors
@@ -94,13 +109,6 @@ export const KeyValidityStep = ({
<Select
value={field.value}
onValueChange={(value) => {
- if (value === CertKeySource.AwsKms && !isAwsKmsLicensed) {
- openUpgradeGate({
- intent: AwsKmsCaSigningUpgradeIntent,
- paywallKey: "cert-manager.ca-key-source"
- });
- return;
- }
field.onChange(value);
if (
!isKeyAlgorithmSupportedByKeySource(
@@ -128,7 +136,7 @@ export const KeyValidityStep = ({
)}
</div>
</SelectItem>
- <SelectItem value={CertKeySource.AwsKms}>
+ <SelectItem value={CertKeySource.AwsKms} disabled={!isAwsKmsLicensed}>
<div className="flex items-center gap-2">
AWS KMS
{!isAwsKmsLicensed && <Badge variant="info">Enterprise</Badge>}
@@ -191,33 +199,31 @@ export const KeyValidityStep = ({
AWS Connection <span className="text-danger">*</span>
</FieldLabel>
<FieldContent>
- <FilterableSelect<AwsConnectionOption>
+ <FilterableSelect
isLoading={isAwsConnectionsLoading}
- options={awsConnectionOptions}
- value={awsConnectionOptions.find((o) => o.id === field.value) ?? null}
- onChange={(selected) => {
- const opt = selected as AwsConnectionOption | null;
- field.onChange(opt?.id ?? null);
+ options={[
+ ...(canCreateAppConnection ? [CREATE_AWS_CONNECTION_OPTION] : []),
+ ...awsConnectionOptions
+ ]}
+ value={
+ [...awsConnectionOptions, createdAwsConnection].find(
+ (option) => option?.id === field.value
+ ) ?? null
+ }
+ onChange={(newValue) => {
+ const selected = newValue as SingleValue<{ id: string }>;
+ if (selected?.id === CREATE_AWS_CONNECTION_OPTION.id) {
+ setIsCreateAwsConnectionOpen(true);
+ return;
+ }
+ field.onChange(selected?.id ?? null);
}}
- getOptionLabel={(opt) => opt.name}
- getOptionValue={(opt) => opt.id}
+ getOptionLabel={(option) => option.name}
+ getOptionValue={(option) => option.id}
+ components={{ Option: AppConnectionOption }}
placeholder="Select an AWS connection..."
- /* eslint-disable-next-line react/no-unstable-nested-components */
noOptionsMessage={() =>
- awsConnectionOptions.length === 0 ? (
- <>
- No AWS connections yet.{" "}
- <Link
- to="/organizations/$orgId/cert-manager/app-connections"
- params={{ orgId: currentOrg.id }}
- className="underline"
- >
- Add an AWS connection
- </Link>
- </>
- ) : (
- "No match."
- )
+ "No AWS connections available. Contact an admin to create one."
}
isError={Boolean(error)}
/>
@@ -358,6 +364,19 @@ export const KeyValidityStep = ({
/>
</>
)}
+ {isAwsKms && (
+ <AddAppConnectionModal
+ isOpen={isCreateAwsConnectionOpen}
+ onOpenChange={setIsCreateAwsConnectionOpen}
+ projectType={currentProject.type}
+ projectId={currentProject.id}
+ app={AppConnection.AWS}
+ onComplete={(connection) => {
+ setCreatedAwsConnection(connection);
+ form.setValue("appConnectionId", connection.id, { shouldValidate: true });
+ }}
+ />
+ )}
{upgradeGate}
</FieldGroup>
);
diff --git a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CreateCaWizard/types.ts b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CreateCaWizard/types.ts
index 21634b76ed..e8bb559f59 100644
--- a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CreateCaWizard/types.ts
+++ b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CreateCaWizard/types.ts
@@ -32,8 +32,6 @@ export const isKeyAlgorithmSupportedByKeySource = (
export type HsmConnectorOption = { id: string; name: string; slotLabel: string };
-export type AwsConnectionOption = { id: string; name: string };
-
export type WizardStep = {
name: string;
shortDescription: string;