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
misc: addressed comment
Sheen Capadngan2d02949604e3
diff --git a/backend/src/services/certificate-authority/certificate-authority-dal.ts b/backend/src/services/certificate-authority/certificate-authority-dal.tsindex 02cc3013d2..ac89999f6b 100644--- a/backend/src/services/certificate-authority/certificate-authority-dal.ts+++ b/backend/src/services/certificate-authority/certificate-authority-dal.ts@@ -386,12 +386,35 @@ export const certificateAuthorityDALFactory = (db: TDbClient) => {}};+ // External CAs of one type across all of the org's projects, excluding soft-deleted projects. Used to+ // grandfather deprecated CA types: an org that already runs one can keep adding more, everyone else+ // is turned away at creation.+ const countExternalCasByOrgIdAndType = async (orgId: string, type: string, tx?: Knex) => {+ try {+ const doc = await (tx || db.replicaNode())(TableName.CertificateAuthority)+ .join(+ TableName.ExternalCertificateAuthority,+ `${TableName.CertificateAuthority}.id`,+ `${TableName.ExternalCertificateAuthority}.caId`+ )+ .join(TableName.Project, `${TableName.CertificateAuthority}.projectId`, `${TableName.Project}.id`)+ .where(`${TableName.ExternalCertificateAuthority}.type`, type)+ .where(`${TableName.Project}.orgId`, orgId)+ .whereNull(`${TableName.Project}.deleteAfter`)+ .count();+ return Number(doc?.[0]?.count ?? 0);+ } catch (error) {+ throw new DatabaseError({ error, name: "Count External CAs By Org ID And Type - Certificate Authority" });+ }+ };+return {...caOrm,findWithAssociatedCa,buildCertificateChain,findByIdWithAssociatedCa,findByNameAndProjectIdWithAssociatedCa,- countInternalCasByOrgId+ countInternalCasByOrgId,+ countExternalCasByOrgIdAndType};};diff --git a/backend/src/services/certificate-authority/certificate-authority-service.ts b/backend/src/services/certificate-authority/certificate-authority-service.tsindex 1ab54f6a83..da6edc5b31 100644--- a/backend/src/services/certificate-authority/certificate-authority-service.ts+++ b/backend/src/services/certificate-authority/certificate-authority-service.ts@@ -73,7 +73,10 @@ import {AzureAdCsCertificateAuthorityFns,castDbEntryToAzureAdCsCertificateAuthority} from "./azure-ad-cs/azure-ad-cs-certificate-authority-fns";-import { TUpdateAzureAdCsCertificateAuthorityDTO } from "./azure-ad-cs/azure-ad-cs-certificate-authority-types";+import {+ TCreateAzureAdCsCertificateAuthorityDTO,+ TUpdateAzureAdCsCertificateAuthorityDTO+} from "./azure-ad-cs/azure-ad-cs-certificate-authority-types";import { TCertificateAuthorityDALFactory } from "./certificate-authority-dal";import { CaType } from "./certificate-authority-enums";import { TCertificateAuthoritySecretDALFactory } from "./certificate-authority-secret-dal";@@ -128,6 +131,7 @@ type TCertificateAuthorityServiceFactoryDep = {| "findWithAssociatedCa"| "findByNameAndProjectIdWithAssociatedCa"| "countInternalCasByOrgId"+ | "countExternalCasByOrgIdAndType">;externalCertificateAuthorityDAL: Pick<TExternalCertificateAuthorityDALFactory, "create" | "update" | "findOne">;internalCertificateAuthorityService: TInternalCertificateAuthorityServiceFactory;@@ -380,10 +384,27 @@ export const certificateAuthorityServiceFactory = ({});}+ // Azure ADCS (Web Enrollment) is deprecated in favour of the Microsoft ADCS connection. Orgs+ // already running one can keep adding more so we don't strand them; everyone else is turned awayif (type === CaType.AZURE_AD_CS) {- throw new BadRequestError({- message:- "Creating new Azure ADCS (Web Enrollment) certificate authorities is no longer supported. Use the Microsoft ADCS connection instead."+ const existingAzureAdCsCount = await certificateAuthorityDAL.countExternalCasByOrgIdAndType(+ actor.orgId,+ CaType.AZURE_AD_CS+ );++ if (existingAzureAdCsCount === 0) {+ throw new BadRequestError({+ message:+ "Azure ADCS (Web Enrollment) is deprecated and no longer available for new setups. Use the Microsoft ADCS certificate authority instead."+ });+ }++ return azureAdCsFns.createCertificateAuthority({+ name,+ projectId,+ configuration: configuration as TCreateAzureAdCsCertificateAuthorityDTO["configuration"],+ status,+ actor});}