Add more missing ACME stuff

# Conflicts:
#	frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/ProfileRow.tsx

# Conflicts:
#	frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/CreateProfileModal.tsx
This commit is contained in:
Fang-Pen Lin
2025-10-28 11:00:50 -07:00
parent 3916d48ba4
commit 2d8126c011
4 changed files with 36 additions and 13 deletions

View File

@@ -225,11 +225,8 @@ export const certificateProfileServiceFactory = ({
message: "API enrollment requires API configuration"
});
}
if (data.enrollmentType === EnrollmentType.ACME && !data.acmeConfig) {
throw new ForbiddenRequestError({
message: "ACME enrollment requires ACME configuration"
});
}
// TODO: acme type currently doesn't require config obj, but add a check in the future if
// we have options
// Create enrollment configs and profile
const profile = await certificateProfileDAL.transaction(async (tx) => {

View File

@@ -5,7 +5,7 @@ export type TCertificateProfile = {
certificateTemplateId: string;
slug: string;
description?: string;
enrollmentType: "api" | "est";
enrollmentType: "api" | "est" | "acme";
estConfigId?: string;
apiConfigId?: string;
createdAt: string;
@@ -44,7 +44,7 @@ export type TCreateCertificateProfileDTO = {
certificateTemplateId: string;
slug: string;
description?: string;
enrollmentType: "api" | "est";
enrollmentType: "api" | "est" | "acme";
estConfig?: {
disableBootstrapCaValidation?: boolean;
passphrase: string;
@@ -54,6 +54,7 @@ export type TCreateCertificateProfileDTO = {
autoRenew?: boolean;
renewBeforeDays?: number;
};
acmeConfig?: {};
};
export type TUpdateCertificateProfileDTO = {
@@ -69,6 +70,7 @@ export type TUpdateCertificateProfileDTO = {
autoRenew?: boolean;
renewBeforeDays?: number;
};
acmeConfig?: {};
};
export type TDeleteCertificateProfileDTO = {
@@ -81,7 +83,7 @@ export type TListCertificateProfilesDTO = {
offset?: number;
search?: string;
includeConfigs?: boolean;
enrollmentType?: "api" | "est";
enrollmentType?: "api" | "est" | "acme";
};
export type TGetCertificateProfileByIdDTO = {

View File

@@ -72,7 +72,8 @@ const createSchema = z
autoRenew: z.boolean().optional(),
renewBeforeDays: z.number().min(1).max(365).optional()
})
.optional()
.optional(),
acmeConfig: z.object({}).optional()
})
.refine(
(data) => {
@@ -82,6 +83,9 @@ const createSchema = z
if (data.enrollmentType === "api" && !data.apiConfig) {
return false;
}
if (data.enrollmentType === "acme" && !data.acmeConfig) {
return false;
}
return true;
},
{
@@ -188,7 +192,8 @@ export const CreateProfileModal = ({ isOpen, onClose, profile, mode = "create" }
autoRenew: profile.apiConfig?.autoRenew || false,
renewBeforeDays: profile.apiConfig?.renewBeforeDays || 30
}
: undefined
: undefined,
acmeConfig: profile.enrollmentType === "acme" ? {} : undefined
}
: {
slug: "",
@@ -199,7 +204,8 @@ export const CreateProfileModal = ({ isOpen, onClose, profile, mode = "create" }
apiConfig: {
autoRenew: false,
renewBeforeDays: 30
}
},
acmeConfig: {}
}
});
@@ -230,7 +236,8 @@ export const CreateProfileModal = ({ isOpen, onClose, profile, mode = "create" }
autoRenew: profile.apiConfig?.autoRenew || false,
renewBeforeDays: profile.apiConfig?.renewBeforeDays || 30
}
: undefined
: undefined,
acmeConfig: profile.enrollmentType === "acme" ? {} : undefined
});
}
}, [isEdit, profile, reset]);
@@ -249,6 +256,8 @@ export const CreateProfileModal = ({ isOpen, onClose, profile, mode = "create" }
updateData.estConfig = data.estConfig;
} else if (data.enrollmentType === "api" && data.apiConfig) {
updateData.apiConfig = data.apiConfig;
} else if (data.enrollmentType === "acme" && data.acmeConfig) {
updateData.acmeConfig = data.acmeConfig;
}
await updateProfile.mutateAsync(updateData);
@@ -549,6 +558,20 @@ export const CreateProfileModal = ({ isOpen, onClose, profile, mode = "create" }
</div>
)}
{/* ACME Configuration */}
{watchedEnrollmentType === "acme" && (
<div className="mb-4 space-y-4">
<Controller
control={control}
name="acmeConfig"
render={({ field, fieldState: { error } }) => (
<FormControl isError={Boolean(error)} errorText={error?.message}>
<div className="flex items-center gap-2">FIXME: ACME configuration</div>
</FormControl>
)}
/>
</div>
)}
{watchedAutoRenew && (
<div className="mb-4 space-y-4">
<Controller

View File

@@ -82,7 +82,8 @@ export const ProfileRow = ({ profile, onEditProfile, onDeleteProfile }: Props) =
const getEnrollmentTypeBadge = (enrollmentType: string) => {
const config = {
api: { variant: "ghost" as const, label: "API" },
est: { variant: "ghost" as const, label: "EST" }
est: { variant: "ghost" as const, label: "EST" },
acme: { variant: "ghost" as const, label: "ACME" }
} as const;
const configKey = Object.keys(config).includes(enrollmentType)