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
feat: review comments addressed
=09db9e340b82
diff --git a/backend/src/server/routes/v2/pki-templates-router.ts b/backend/src/server/routes/v2/pki-templates-router.tsindex b6b969706c..e481af0a24 100644--- a/backend/src/server/routes/v2/pki-templates-router.ts+++ b/backend/src/server/routes/v2/pki-templates-router.ts@@ -26,7 +26,7 @@ export const registerPkiTemplatesRouter = async (server: FastifyZodProvider) =>tags: [ApiDocsTags.PkiCertificateTemplates],body: z.object({name: slugSchema(),- caId: z.string(),+ caName: slugSchema({ field: "caName" }),projectId: z.string(),commonName: validateTemplateRegexField,subjectAlternativeName: validateTemplateRegexField,@@ -72,7 +72,7 @@ export const registerPkiTemplatesRouter = async (server: FastifyZodProvider) =>}),body: z.object({name: slugSchema().optional(),- caId: z.string(),+ caName: slugSchema(),projectId: z.string(),commonName: validateTemplateRegexField.optional(),subjectAlternativeName: validateTemplateRegexField.optional(),diff --git a/backend/src/services/pki-templates/pki-templates-service.ts b/backend/src/services/pki-templates/pki-templates-service.tsindex e72a2198ae..97f910d6e5 100644--- a/backend/src/services/pki-templates/pki-templates-service.ts+++ b/backend/src/services/pki-templates/pki-templates-service.ts@@ -56,7 +56,13 @@ type TPkiTemplatesServiceFactoryDep = {permissionService: Pick<TPermissionServiceFactory, "getProjectPermission">;certificateAuthorityDAL: Pick<TCertificateAuthorityDALFactory,- "findByIdWithAssociatedCa" | "findById" | "transaction" | "create" | "updateById" | "findWithAssociatedCa"+ | "findByIdWithAssociatedCa"+ | "findById"+ | "transaction"+ | "create"+ | "updateById"+ | "findWithAssociatedCa"+ | "findOne">;internalCaFns: ReturnType<typeof InternalCertificateAuthorityFns>;kmsService: Pick<TKmsServiceFactory, "generateKmsKey" | "decryptWithKmsKey" | "encryptWithKmsKey">;@@ -92,20 +98,22 @@ export const pkiTemplatesServiceFactory = ({actorId,actorAuthMethod,actorOrgId,- caId,+ caName,commonName,extendedKeyUsages,keyUsages,name,subjectAlternativeName,- ttl+ ttl,+ projectId}: TCreatePkiTemplateDTO) => {- const ca = await certificateAuthorityDAL.findById(caId);+ const ca = await certificateAuthorityDAL.findOne({ name: caName, projectId });if (!ca) {throw new NotFoundError({- message: `CA with ID ${caId} not found`+ message: `CA with name ${caName} not found`});}+const { permission } = await permissionService.getProjectPermission({actor,actorId,@@ -126,7 +134,7 @@ export const pkiTemplatesServiceFactory = ({}const newTemplate = await pkiTemplatesDAL.create({- caId,+ caId: ca.id,name,commonName,subjectAlternativeName,@@ -143,7 +151,7 @@ export const pkiTemplatesServiceFactory = ({actorId,actorAuthMethod,actorOrgId,- caId,+ caName,commonName,extendedKeyUsages,keyUsages,@@ -173,13 +181,15 @@ export const pkiTemplatesServiceFactory = ({subject(ProjectPermissionSub.CertificateTemplates, { name: templateName }));- if (caId) {- const ca = await certificateAuthorityDAL.findById(caId);+ let caId;+ if (caName) {+ const ca = await certificateAuthorityDAL.findOne({ name: caName, projectId });if (!ca || ca.projectId !== certTemplate.projectId) {throw new NotFoundError({- message: `CA with ID ${caId} not found`+ message: `CA with name ${caName} not found`});}+ caId = ca.id;}if (name) {diff --git a/backend/src/services/pki-templates/pki-templates-types.ts b/backend/src/services/pki-templates/pki-templates-types.tsindex 72d245de12..8dd18c8a93 100644--- a/backend/src/services/pki-templates/pki-templates-types.ts+++ b/backend/src/services/pki-templates/pki-templates-types.ts@@ -2,7 +2,7 @@ import { TProjectPermission } from "@app/lib/types";import { CertExtendedKeyUsage, CertKeyUsage } from "@app/services/certificate/certificate-types";export type TCreatePkiTemplateDTO = {- caId: string;+ caName: string;name: string;commonName: string;subjectAlternativeName: string;@@ -13,7 +13,7 @@ export type TCreatePkiTemplateDTO = {export type TUpdatePkiTemplateDTO = {templateName: string;- caId?: string;+ caName?: string;name?: string;commonName?: string;subjectAlternativeName?: string;diff --git a/frontend/src/hooks/api/certificateTemplates/types.ts b/frontend/src/hooks/api/certificateTemplates/types.tsindex 3e3e728f84..1c2a471780 100644--- a/frontend/src/hooks/api/certificateTemplates/types.ts+++ b/frontend/src/hooks/api/certificateTemplates/types.ts@@ -65,7 +65,7 @@ export type TDeleteCertificateTemplateDTO = {};export type TCreateCertificateTemplateV2DTO = {- caId: string;+ caName: string;name: string;commonName: string;subjectAlternativeName: string;@@ -77,7 +77,7 @@ export type TCreateCertificateTemplateV2DTO = {export type TUpdateCertificateTemplateV2DTO = {templateName: string;- caId?: string;+ caName?: string;name?: string;commonName?: string;subjectAlternativeName?: string;diff --git a/frontend/src/pages/cert-manager/PkiTemplateListPage/PkiTemplateListPage.tsx b/frontend/src/pages/cert-manager/PkiTemplateListPage/PkiTemplateListPage.tsxindex 7adf86bc76..8957753608 100644--- a/frontend/src/pages/cert-manager/PkiTemplateListPage/PkiTemplateListPage.tsx+++ b/frontend/src/pages/cert-manager/PkiTemplateListPage/PkiTemplateListPage.tsx@@ -130,7 +130,7 @@ export const PkiTemplateListPage = () => {<THead><Tr><Th>Name</Th>- <Th>CA</Th>+ <Th>Issuing CA</Th><Th className="w-64">Last Updated At</Th><Th /></Tr>diff --git a/frontend/src/pages/cert-manager/PkiTemplateListPage/components/PkiTemplateForm.tsx b/frontend/src/pages/cert-manager/PkiTemplateListPage/components/PkiTemplateForm.tsxindex 0a78ddac26..19022b4b99 100644--- a/frontend/src/pages/cert-manager/PkiTemplateListPage/components/PkiTemplateForm.tsx+++ b/frontend/src/pages/cert-manager/PkiTemplateListPage/components/PkiTemplateForm.tsx@@ -1,4 +1,5 @@import { Controller, useForm } from "react-hook-form";+import { faQuestionCircle } from "@fortawesome/free-regular-svg-icons";import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";import { zodResolver } from "@hookform/resolvers/zod";@@ -133,7 +134,7 @@ export const PkiTemplateForm = ({ certTemplate, handlePopUpToggle }: Props) => {await updateCertTemplate({templateName: certTemplate.name,projectId: currentWorkspace.id,- caId: ca.id,+ caName: ca.name,name,commonName,subjectAlternativeName,@@ -153,7 +154,7 @@ export const PkiTemplateForm = ({ certTemplate, handlePopUpToggle }: Props) => {} else {await createCertTemplate({projectId: currentWorkspace.id,- caId: ca.id,+ caName: ca.name,name,commonName,subjectAlternativeName,