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(pki): show disabled certificate profiles for API enrollment (#7535)
Saif Ur Rahman395a977d18a2
diff --git a/frontend/src/hooks/api/ca/mutations.tsx b/frontend/src/hooks/api/ca/mutations.tsxindex 5ca104e41a..aa45df7b43 100644--- a/frontend/src/hooks/api/ca/mutations.tsx+++ b/frontend/src/hooks/api/ca/mutations.tsx@@ -2,6 +2,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";import { apiRequest } from "@app/config/request";+import { certificateProfileKeys } from "../certificateProfiles/queries";import { projectKeys } from "../projects";import { CaRenewalStatus, CaType } from "./enums";import { caKeys } from "./queries";@@ -174,7 +175,7 @@ export const useCreateCertificateV3 = () => {});queryClient.invalidateQueries({- queryKey: ["certificate-profiles"]+ queryKey: certificateProfileKeys.all});}});diff --git a/frontend/src/hooks/api/certificateProfiles/mutations.tsx b/frontend/src/hooks/api/certificateProfiles/mutations.tsxindex e38d8ce262..3e1ae8bdb6 100644--- a/frontend/src/hooks/api/certificateProfiles/mutations.tsx+++ b/frontend/src/hooks/api/certificateProfiles/mutations.tsx@@ -23,7 +23,7 @@ export const useCreateCertificateProfile = () => {},onSuccess: () => {queryClient.invalidateQueries({- queryKey: ["certificate-profiles", "list"]+ queryKey: certificateProfileKeys.lists()});queryClient.invalidateQueries({ queryKey: pkiApplicationKeys.all });}@@ -42,7 +42,7 @@ export const useUpdateCertificateProfile = () => {},onSuccess: (_, { profileId }) => {queryClient.invalidateQueries({- queryKey: ["certificate-profiles", "list"]+ queryKey: certificateProfileKeys.lists()});queryClient.invalidateQueries({queryKey: certificateProfileKeys.getById(profileId)@@ -64,7 +64,7 @@ export const useDeleteCertificateProfile = () => {},onSuccess: (_, { profileId }) => {queryClient.invalidateQueries({- queryKey: ["certificate-profiles", "list"]+ queryKey: certificateProfileKeys.lists()});queryClient.removeQueries({queryKey: certificateProfileKeys.getById(profileId)diff --git a/frontend/src/hooks/api/certificateProfiles/queries.tsx b/frontend/src/hooks/api/certificateProfiles/queries.tsxindex 50f53dec30..2df27de645 100644--- a/frontend/src/hooks/api/certificateProfiles/queries.tsx+++ b/frontend/src/hooks/api/certificateProfiles/queries.tsx@@ -15,6 +15,8 @@ import {} from "./types";export const certificateProfileKeys = {+ all: ["certificate-profiles"] as const,+ lists: () => [...certificateProfileKeys.all, "list"] as const,list: (params: {limit?: number;offset?: number;@@ -23,23 +25,23 @@ export const certificateProfileKeys = {enrollmentType?: string;expiringDays?: number;applicationId?: string;- }) => ["certificate-profiles", "list", params],- getById: (profileId: string) => ["certificate-profiles", "get-by-id", profileId],- getBySlug: (slug: string) => ["certificate-profiles", "get-by-slug", slug],+ }) => [...certificateProfileKeys.lists(), params],+ getById: (profileId: string) => [...certificateProfileKeys.all, "get-by-id", profileId],+ getBySlug: (slug: string) => [...certificateProfileKeys.all, "get-by-slug", slug],getCertificates: (profileId: string, params?: Omit<TGetProfileCertificatesDTO, "profileId">) => [- "certificate-profiles",+ ...certificateProfileKeys.all,"certificates",profileId,params],getMetrics: (profileId: string, params?: Omit<TGetProfileMetricsDTO, "profileId">) => [- "certificate-profiles",+ ...certificateProfileKeys.all,"metrics",profileId,params],revealAcmeEabSecret: (profileId: string) => [- "certificate-profiles",+ ...certificateProfileKeys.all,"reveal-acme-eab-secret",profileId]diff --git a/frontend/src/hooks/api/certificates/mutations.tsx b/frontend/src/hooks/api/certificates/mutations.tsxindex 559d3ee12e..a5e53f6ff6 100644--- a/frontend/src/hooks/api/certificates/mutations.tsx+++ b/frontend/src/hooks/api/certificates/mutations.tsx@@ -2,6 +2,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";import { apiRequest } from "@app/config/request";+import { certificateProfileKeys } from "../certificateProfiles/queries";import { pkiSubscriberKeys } from "../pkiSubscriber/queries";import { projectKeys } from "../projects";import { certKeys } from "./queries";@@ -38,7 +39,7 @@ export const useDeleteCert = () => {queryKey: certKeys.getCertificateById(id)});queryClient.invalidateQueries({- queryKey: ["certificate-profiles", "list"]+ queryKey: certificateProfileKeys.lists()});queryClient.invalidateQueries({queryKey: pkiSubscriberKeys.allPkiSubscriberCertificates()@@ -72,7 +73,7 @@ export const useRevokeCert = () => {queryKey: certKeys.getCertificateById(id)});queryClient.invalidateQueries({- queryKey: ["certificate-profiles", "list"]+ queryKey: certificateProfileKeys.lists()});queryClient.invalidateQueries({queryKey: pkiSubscriberKeys.allPkiSubscriberCertificates()@@ -123,7 +124,7 @@ export const useRenewCertificate = () => {queryKey: certKeys.getCertificateById(certificateId)});queryClient.invalidateQueries({- queryKey: ["certificate-profiles", "list"]+ queryKey: certificateProfileKeys.lists()});queryClient.invalidateQueries({queryKey: pkiSubscriberKeys.allPkiSubscriberCertificates()@@ -242,7 +243,7 @@ export const useUnifiedCertificateIssuance = () => {},onSuccess: () => {queryClient.invalidateQueries({- queryKey: ["certificate-profiles", "list"]+ queryKey: certificateProfileKeys.lists()});queryClient.invalidateQueries({queryKey: pkiSubscriberKeys.allPkiSubscriberCertificates()diff --git a/frontend/src/hooks/api/pkiApplications/mutations.ts b/frontend/src/hooks/api/pkiApplications/mutations.tsindex 4705a69e9a..81f47dcfd0 100644--- a/frontend/src/hooks/api/pkiApplications/mutations.ts+++ b/frontend/src/hooks/api/pkiApplications/mutations.ts@@ -5,6 +5,7 @@ import { apiRequest } from "@app/config/request";import { approvalGrantQuery } from "../approvalGrants/queries";import { approvalPolicyQuery } from "../approvalPolicies/queries";import { approvalRequestQuery } from "../approvalRequests/queries";+import { certificateProfileKeys } from "../certificateProfiles/queries";import { pkiApplicationKeys } from "./queries";import {TAddPkiApplicationMemberDTO,@@ -29,8 +30,10 @@ import {const BASE_URL = "/api/v1/cert-manager/applications";-const invalidateAll = (qc: ReturnType<typeof useQueryClient>) =>+const invalidateAll = (qc: ReturnType<typeof useQueryClient>) => {qc.invalidateQueries({ queryKey: pkiApplicationKeys.all });+ qc.invalidateQueries({ queryKey: certificateProfileKeys.lists() });+};export const useCreatePkiApplication = () => {const qc = useQueryClient();diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateIssuanceModal.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateIssuanceModal.tsxindex 5a58daca35..3516032b57 100644--- a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateIssuanceModal.tsx+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateIssuanceModal.tsx@@ -291,15 +291,31 @@ export const CertificateIssuanceModal = ({const { data: appProfiles } = useListPkiApplicationProfiles(applicationId ?? "");- const availableProfiles = useMemo(() => {+ const profileOptions = useMemo(() => {const allProfiles = profilesData?.certificateProfiles ?? [];- if (!applicationId) return allProfiles;+ if (!applicationId) return allProfiles.map((profile) => ({ profile, isApiEnabled: true }));const apiEnabledProfileIds = new Set((appProfiles ?? []).filter((p) => Boolean(p.apiConfigId)).map((p) => p.profileId));- return allProfiles.filter((p) => apiEnabledProfileIds.has(p.id));+ return allProfiles+ .map((profile) => ({+ profile,+ isApiEnabled: apiEnabledProfileIds.has(profile.id)+ }))+ .sort(+ (a, b) =>+ Number(b.isApiEnabled) - Number(a.isApiEnabled) ||+ a.profile.slug.localeCompare(b.profile.slug)+ );}, [profilesData?.certificateProfiles, appProfiles, applicationId]);+ const availableProfiles = useMemo(+ () => profileOptions.filter((option) => option.isApiEnabled).map((option) => option.profile),+ [profileOptions]+ );++ const hasDisabledProfiles = profileOptions.some((option) => !option.isApiEnabled);+const { mutateAsync: issueCertificate } = useUnifiedCertificateIssuance();const isAdcsProfileRef = useRef(false);@@ -704,21 +720,34 @@ export const CertificateIssuanceModal = ({<SelectValue placeholder="Select a certificate profile" /></SelectTrigger><SelectContent position="popper">- {availableProfiles.length === 0 && applicationId ? (+ {profileOptions.length === 0 && applicationId ? (<div className="px-3 py-3 text-xs leading-snug whitespace-normal text-muted">- Only profiles with API enrollment configured on this- Application are listed here. Configure API enrollment under- this Application's Settings tab.+ No certificate profiles are attached to this Application. Add+ one under this Application's Settings tab.</div>) : (- availableProfiles.map((profile) => (- <SelectItem key={profile.id} value={profile.id}>+ profileOptions.map(({ profile, isApiEnabled }) => (+ <SelectItem+ key={profile.id}+ value={profile.id}+ disabled={!isApiEnabled}+ description={+ isApiEnabled ? undefined : "API enrollment not configured"+ }+ >{profile.slug}</SelectItem>)))}</SelectContent></Select>+ {hasDisabledProfiles && (+ <FieldDescription>+ Profiles without API enrollment configured can't be used+ here. Configure API enrollment under this Application's+ Settings tab.+ </FieldDescription>+ )}{isAdcsProfile && (<FieldDescription>{externalCaHint}</FieldDescription>)}