Skip to content

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

Minor fix on adcs signing flow

Carlos Monastyrskic4af68ef16db
diff --git a/backend/src/lib/gateway-v2/adcs-rpc.ts b/backend/src/lib/gateway-v2/adcs-rpc.ts
index a2ba40cd68..59064c36c8 100644
--- a/backend/src/lib/gateway-v2/adcs-rpc.ts
+++ b/backend/src/lib/gateway-v2/adcs-rpc.ts
@@ -5,7 +5,6 @@ import { logger } from "@app/lib/logger";
export type AdcsRpcEndpoint = "/v1/test" | "/v1/discover-ca" | "/v1/templates" | "/v1/enroll";
export type AdcsRpcRequestBody = {
- host: string;
username: string;
password: string;
caName?: string;
diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.ts
index e4243deb76..402e9e08ee 100644
--- a/backend/src/server/routes/index.ts
+++ b/backend/src/server/routes/index.ts
@@ -2955,6 +2955,7 @@ export const registerRoutes = async (
internalCertificateAuthorityDAL,
permissionService,
appConnectionDAL,
+ appConnectionService,
caAutoRenewalQueue
});
diff --git a/backend/src/server/routes/v1/certificate-authority-routers/internal-certificate-authority-router.ts b/backend/src/server/routes/v1/certificate-authority-routers/internal-certificate-authority-router.ts
index 6b5470582a..05c5c3f487 100644
--- a/backend/src/server/routes/v1/certificate-authority-routers/internal-certificate-authority-router.ts
+++ b/backend/src/server/routes/v1/certificate-authority-routers/internal-certificate-authority-router.ts
@@ -866,7 +866,8 @@ export const registerInternalCertificateAuthorityRouter = async (server: Fastify
actor: req.permission.type,
actorId: req.permission.id,
actorAuthMethod: req.permission.authMethod,
- actorOrgId: req.permission.orgId
+ actorOrgId: req.permission.orgId,
+ permissionActor: req.permission
});
await server.services.auditLog.createAuditLog({
@@ -963,7 +964,8 @@ export const registerInternalCertificateAuthorityRouter = async (server: Fastify
actor: req.permission.type,
actorId: req.permission.id,
actorAuthMethod: req.permission.authMethod,
- actorOrgId: req.permission.orgId
+ actorOrgId: req.permission.orgId,
+ permissionActor: req.permission
});
await server.services.auditLog.createAuditLog({
diff --git a/backend/src/services/app-connection/adcs/adcs-connection-fns.ts b/backend/src/services/app-connection/adcs/adcs-connection-fns.ts
index 75fd4fe913..1d6d336cba 100644
--- a/backend/src/services/app-connection/adcs/adcs-connection-fns.ts
+++ b/backend/src/services/app-connection/adcs/adcs-connection-fns.ts
@@ -10,10 +10,6 @@ import { AppConnection } from "@app/services/app-connection/app-connection-enums
import { ADCSConnectionMethod } from "./adcs-connection-enums";
import { TADCSConnectionConfig } from "./adcs-connection-types";
-// The gateway routes ADCS operations by ALPN, so the target host/port carried in
-// the client certificate is not used. A stable placeholder keeps routing happy.
-const ADCS_TARGET_HOST = "adcs";
-
export type TADCSGatewayDeps = {
gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">;
gatewayPoolService?: Pick<TGatewayPoolServiceFactory, "resolveEffectiveGatewayId">;
@@ -63,7 +59,7 @@ export const executeAdcsGatewayOperation = async <T>(
const connectionDetails = await gatewayV2Service.getPlatformConnectionDetailsByGatewayId({
gatewayId,
- targetHost: ADCS_TARGET_HOST,
+ targetHost: args.credentials.host,
targetPort: 0
});
if (!connectionDetails) {
@@ -76,7 +72,6 @@ export const executeAdcsGatewayOperation = async <T>(
port,
endpoint: args.endpoint,
body: {
- host: args.credentials.host,
username: args.credentials.username,
password: args.credentials.password,
caName: args.caName,
diff --git a/backend/src/services/certificate-authority/ca-signing-config/ca-signing-config-service.ts b/backend/src/services/certificate-authority/ca-signing-config/ca-signing-config-service.ts
index aa7a4bf81c..0831d2dd1e 100644
--- a/backend/src/services/certificate-authority/ca-signing-config/ca-signing-config-service.ts
+++ b/backend/src/services/certificate-authority/ca-signing-config/ca-signing-config-service.ts
@@ -7,7 +7,10 @@ import {
ProjectPermissionSub
} from "@app/ee/services/permission/project-permission";
import { BadRequestError, NotFoundError } from "@app/lib/errors";
+import { OrgServiceActor } from "@app/lib/types";
import { TAppConnectionDALFactory } from "@app/services/app-connection/app-connection-dal";
+import { AppConnection } from "@app/services/app-connection/app-connection-enums";
+import { TAppConnectionServiceFactory } from "@app/services/app-connection/app-connection-service";
import { ActorAuthMethod, ActorType } from "@app/services/auth/auth-type";
import { TCaAutoRenewalQueueFactory } from "../ca-auto-renewal-queue";
@@ -37,6 +40,7 @@ type TCaSigningConfigServiceFactoryDep = {
internalCertificateAuthorityDAL: Pick<TInternalCertificateAuthorityDALFactory, "findOne" | "updateById">;
permissionService: Pick<TPermissionServiceFactory, "getProjectPermission">;
appConnectionDAL: Pick<TAppConnectionDALFactory, "findById">;
+ appConnectionService: Pick<TAppConnectionServiceFactory, "validateAppConnectionUsageById">;
caAutoRenewalQueue: Pick<
TCaAutoRenewalQueueFactory,
"queueVenafiInstall" | "queueAdcsInstall" | "queueNativeAdcsInstall"
@@ -51,6 +55,7 @@ export const caSigningConfigServiceFactory = ({
internalCertificateAuthorityDAL,
permissionService,
appConnectionDAL,
+ appConnectionService,
caAutoRenewalQueue
}: TCaSigningConfigServiceFactoryDep) => {
const validateAppConnectionOrg = async (connectionId: string, actorOrgId: string) => {
@@ -60,6 +65,10 @@ export const caSigningConfigServiceFactory = ({
}
};
+ const validateAdcsAppConnectionUsage = async (connectionId: string, projectId: string, actor: OrgServiceActor) => {
+ await appConnectionService.validateAppConnectionUsageById(AppConnection.ADCS, { connectionId, projectId }, actor);
+ };
+
const getSigningConfigByCaId = async (internalCaId: string) => {
const config = await caSigningConfigDAL.findByCaId(internalCaId);
if (!config) {
@@ -77,12 +86,14 @@ export const caSigningConfigServiceFactory = ({
actor,
actorId,
actorAuthMethod,
- actorOrgId
+ actorOrgId,
+ permissionActor
}: TCreateCaSigningConfigDTO & {
actor: ActorType;
actorId: string;
actorAuthMethod: ActorAuthMethod;
actorOrgId: string;
+ permissionActor: OrgServiceActor;
}) => {
const ca = await certificateAuthorityDAL.findByIdWithAssociatedCa(caId);
if (!ca) throw new NotFoundError({ message: `CA with ID ${caId} not found` });
@@ -146,7 +157,7 @@ export const caSigningConfigServiceFactory = ({
throw new BadRequestError({ message: "Destination config is required for ADCS signing" });
}
AdcsDestinationConfigSchema.parse(destinationConfig);
- await validateAppConnectionOrg(appConnectionId, actorOrgId);
+ await validateAdcsAppConnectionUsage(appConnectionId, ca.projectId, permissionActor);
}
const isExternalCa =
@@ -224,12 +235,14 @@ export const caSigningConfigServiceFactory = ({
actor,
actorId,
actorAuthMethod,
- actorOrgId
+ actorOrgId,
+ permissionActor
}: TUpdateCaSigningConfigDTO & {
actor: ActorType;
actorId: string;
actorAuthMethod: ActorAuthMethod;
actorOrgId: string;
+ permissionActor: OrgServiceActor;
}) => {
const ca = await certificateAuthorityDAL.findByIdWithAssociatedCa(caId);
if (!ca) throw new NotFoundError({ message: `CA with ID ${caId} not found` });
@@ -291,7 +304,7 @@ export const caSigningConfigServiceFactory = ({
if (existing.type === CaSigningConfigType.Adcs) {
if (appConnectionId !== undefined) {
- await validateAppConnectionOrg(appConnectionId, actorOrgId);
+ await validateAdcsAppConnectionUsage(appConnectionId, ca.projectId, permissionActor);
updateData.appConnectionId = appConnectionId;
}
if (destinationConfig !== undefined) {