Skip to content

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

CA endpoint fix

Carlos Monastyrski7df07c04d324
diff --git a/backend/src/server/routes/v1/certificate-authority-routers/certificate-authority-endpoints.ts b/backend/src/server/routes/v1/certificate-authority-routers/certificate-authority-endpoints.ts
index 0c34ef739f..c6137c097f 100644
--- a/backend/src/server/routes/v1/certificate-authority-routers/certificate-authority-endpoints.ts
+++ b/backend/src/server/routes/v1/certificate-authority-routers/certificate-authority-endpoints.ts
@@ -49,13 +49,16 @@ export const registerCertificateAuthorityEndpoints = <
hide: false,
operationId: `list${caTypeNameForOpId}CertificateAuthoritiesV1`,
tags: [ApiDocsTags.PkiCertificateAuthorities],
+ querystring: z.object({
+ projectId: z.string().uuid().optional()
+ }),
response: {
200: responseSchema.array()
}
},
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
handler: async (req) => {
- const projectId = req.certManagerProjectId;
+ const projectId = req.query.projectId ?? req.certManagerProjectId;
const certificateAuthorities = (await server.services.certificateAuthority.listCertificateAuthoritiesByProjectId(
{ projectId, type: caType },
diff --git a/backend/src/server/routes/v1/certificate-policy-router.ts b/backend/src/server/routes/v1/certificate-policy-router.ts
index 73d6dda222..ad9008078e 100644
--- a/backend/src/server/routes/v1/certificate-policy-router.ts
+++ b/backend/src/server/routes/v1/certificate-policy-router.ts
@@ -257,7 +257,8 @@ export const registerCertificatePolicyRouter = async (server: FastifyZodProvider
querystring: z.object({
offset: z.coerce.number().min(0).default(0),
limit: z.coerce.number().min(1).max(100).default(20),
- search: z.string().optional()
+ search: z.string().optional(),
+ projectId: z.string().uuid().optional()
}),
response: {
200: z.object({
@@ -268,22 +269,24 @@ export const registerCertificatePolicyRouter = async (server: FastifyZodProvider
},
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
handler: async (req) => {
+ const { projectId: explicitProjectId, ...query } = req.query;
+ const projectId = explicitProjectId ?? req.certManagerProjectId;
const { policies, totalCount } = await server.services.certificatePolicy.listPolicies({
actor: req.permission.type,
actorId: req.permission.id,
actorAuthMethod: req.permission.authMethod!,
actorOrgId: req.permission.orgId,
- projectId: req.certManagerProjectId,
- ...req.query
+ projectId,
+ ...query
});
await server.services.auditLog.createAuditLog({
...req.auditLogInfo,
- projectId: req.certManagerProjectId,
+ projectId,
event: {
type: EventType.LIST_CERTIFICATE_POLICIES,
metadata: {
- projectId: req.certManagerProjectId
+ projectId
}
}
});
diff --git a/backend/src/server/routes/v1/certificate-profiles-router.ts b/backend/src/server/routes/v1/certificate-profiles-router.ts
index 586c3eeb69..bb69b7c98f 100644
--- a/backend/src/server/routes/v1/certificate-profiles-router.ts
+++ b/backend/src/server/routes/v1/certificate-profiles-router.ts
@@ -274,7 +274,8 @@ export const registerCertificateProfilesRouter = async (
search: z.string().optional(),
enrollmentType: z.nativeEnum(EnrollmentType).optional(),
issuerType: z.nativeEnum(IssuerType).optional(),
- caId: z.string().uuid().optional()
+ caId: z.string().uuid().optional(),
+ projectId: z.string().uuid().optional()
}),
response: {
200: z.object({
@@ -344,13 +345,14 @@ export const registerCertificateProfilesRouter = async (
},
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
handler: async (req) => {
+ const { projectId: explicitProjectId, ...query } = req.query;
const { profiles, totalCount } = await server.services.certificateProfile.listProfiles({
actor: req.permission.type,
actorId: req.permission.id,
actorAuthMethod: req.permission.authMethod,
actorOrgId: req.permission.orgId,
- projectId: req.certManagerProjectId,
- ...req.query
+ projectId: explicitProjectId ?? req.certManagerProjectId,
+ ...query
});
await server.services.auditLog.createAuditLog({
diff --git a/backend/src/server/routes/v1/certificate-router.ts b/backend/src/server/routes/v1/certificate-router.ts
index df4e77178d..83c24296df 100644
--- a/backend/src/server/routes/v1/certificate-router.ts
+++ b/backend/src/server/routes/v1/certificate-router.ts
@@ -633,6 +633,13 @@ export const registerCertificateRouter = async (server: FastifyZodProvider) => {
.uuid()
.optional()
.describe("Filter to certificate requests for profiles attached to a specific Application."),
+ projectId: z
+ .string()
+ .uuid()
+ .optional()
+ .describe(
+ "Optional explicit cert-manager project. Defaults to the org's default cert-manager project; required when the org has multiple cert-manager projects and you want to target a non-default one."
+ ),
sortBy: z.string().trim().optional(),
sortOrder: z.enum(["asc", "desc"]).optional(),
metadata: z
@@ -675,8 +682,8 @@ export const registerCertificateRouter = async (server: FastifyZodProvider) => {
},
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
handler: async (req) => {
- const { metadata, ...filters } = req.body;
- const projectId = req.certManagerProjectId;
+ const { metadata, projectId: explicitProjectId, ...filters } = req.body;
+ const projectId = explicitProjectId ?? req.certManagerProjectId;
const { certificateRequests, totalCount } = await server.services.certificateRequest.listCertificateRequests({
actor: req.permission.type,
diff --git a/backend/src/server/routes/v1/pki-alert-router.ts b/backend/src/server/routes/v1/pki-alert-router.ts
index be8ba1b2c1..c670482229 100644
--- a/backend/src/server/routes/v1/pki-alert-router.ts
+++ b/backend/src/server/routes/v1/pki-alert-router.ts
@@ -47,6 +47,7 @@ export const registerPkiAlertRouter = async (server: FastifyZodProvider) => {
filters: z.array(PkiFilterRuleSchema),
enabled: z.boolean(),
projectId: z.string().uuid(),
+ applicationId: z.string().uuid().nullable(),
notificationConfig: NotificationConfigSchema.nullable(),
channels: z.array(
z.object({
@@ -110,7 +111,8 @@ export const registerPkiAlertRouter = async (server: FastifyZodProvider) => {
eventType: z.nativeEnum(PkiAlertEventType).optional(),
enabled: z.coerce.boolean().optional(),
limit: z.coerce.number().min(1).max(100).default(20),
- offset: z.coerce.number().min(0).default(0)
+ offset: z.coerce.number().min(0).default(0),
+ projectId: z.string().uuid().optional()
}),
response: {
200: z.object({
@@ -123,6 +125,7 @@ export const registerPkiAlertRouter = async (server: FastifyZodProvider) => {
alertBefore: z.string().optional(),
filters: z.array(PkiFilterRuleSchema),
enabled: z.boolean(),
+ applicationId: z.string().uuid().nullable(),
notificationConfig: NotificationConfigSchema.nullable(),
channels: z.array(
z.object({
@@ -150,13 +153,14 @@ export const registerPkiAlertRouter = async (server: FastifyZodProvider) => {
}
},
handler: async (req) => {
+ const { projectId: explicitProjectId, ...query } = req.query;
const alerts = await server.services.pkiAlertV2.listAlerts({
actor: req.permission.type,
actorId: req.permission.id,
actorAuthMethod: req.permission.authMethod,
actorOrgId: req.permission.orgId,
- projectId: req.certManagerProjectId,
- ...req.query
+ projectId: explicitProjectId ?? req.certManagerProjectId,
+ ...query
});
return alerts;
@@ -189,6 +193,7 @@ export const registerPkiAlertRouter = async (server: FastifyZodProvider) => {
filters: z.array(PkiFilterRuleSchema),
enabled: z.boolean(),
projectId: z.string().uuid(),
+ applicationId: z.string().uuid().nullable(),
notificationConfig: NotificationConfigSchema.nullable(),
channels: z.array(
z.object({
@@ -257,6 +262,7 @@ export const registerPkiAlertRouter = async (server: FastifyZodProvider) => {
filters: z.array(PkiFilterRuleSchema),
enabled: z.boolean(),
projectId: z.string().uuid(),
+ applicationId: z.string().uuid().nullable(),
notificationConfig: NotificationConfigSchema.nullable(),
channels: z.array(
z.object({
@@ -328,6 +334,7 @@ export const registerPkiAlertRouter = async (server: FastifyZodProvider) => {
filters: z.array(PkiFilterRuleSchema),
enabled: z.boolean(),
projectId: z.string().uuid(),
+ applicationId: z.string().uuid().nullable(),
notificationConfig: NotificationConfigSchema.nullable(),
channels: z.array(
z.object({
diff --git a/backend/src/services/certificate-v3/certificate-v3-service.ts b/backend/src/services/certificate-v3/certificate-v3-service.ts
index 874cb6003d..a40962b55a 100644
--- a/backend/src/services/certificate-v3/certificate-v3-service.ts
+++ b/backend/src/services/certificate-v3/certificate-v3-service.ts
@@ -175,7 +175,8 @@ const validateProfileAndPermissions = async ({
acmeAccountDAL,
permissionService,
requiredEnrollmentType,
- isInternal = false
+ isInternal = false,
+ applicationId
}: {
profileId: string;
actor?: ActorType;
@@ -184,9 +185,10 @@ const validateProfileAndPermissions = async ({
actorOrgId?: string;
certificateProfileDAL: Pick<TCertificateProfileDALFactory, "findByIdWithConfigs">;
acmeAccountDAL: Pick<TPkiAcmeAccountDALFactory, "findById">;
- permissionService: Pick<TPermissionServiceFactory, "getProjectPermission">;
+ permissionService: Pick<TPermissionServiceFactory, "getProjectPermission" | "getResourcePermission">;
requiredEnrollmentType: EnrollmentType;
isInternal?: boolean;
+ applicationId?: string;
}) => {
const profile = await certificateProfileDAL.findByIdWithConfigs(profileId);
if (!profile) {
@@ -232,6 +234,24 @@ const validateProfileAndPermissions = async ({
return profile;
}
+ if (applicationId && (actor === ActorType.USER || actor === ActorType.IDENTITY)) {
+ const { permission } = await permissionService.getResourcePermission({
+ actor,
+ actorId,
+ projectId: profile.projectId,
+ resourceType: ResourceType.CertificateApplication,
+ resourceId: applicationId,
+ actorAuthMethod: actorAuthMethod || null,
+ actorOrgId
+ });
+
+ ForbiddenError.from(permission).throwUnlessCan(
+ ProjectPermissionCertificateProfileActions.IssueCert,
+ ProjectPermissionSub.CertificateProfiles
+ );
+ return profile;
+ }
+
const { permission } = await permissionService.getProjectPermission({
actor,
actorId,
@@ -785,7 +805,8 @@ export const certificateV3ServiceFactory = ({
acmeAccountDAL,
permissionService,
requiredEnrollmentType: EnrollmentType.API,
- isInternal: actor === ActorType.EST_ACCOUNT || actor === ActorType.SCEP_ACCOUNT
+ isInternal: actor === ActorType.EST_ACCOUNT || actor === ActorType.SCEP_ACCOUNT,
+ applicationId: explicitApplicationId
});
const applicationId = await $resolveApplicationIdForProfile(profile, explicitApplicationId, {
@@ -1373,7 +1394,8 @@ export const certificateV3ServiceFactory = ({
acmeAccountDAL,
permissionService,
requiredEnrollmentType: enrollmentType,
- isInternal: actor === ActorType.EST_ACCOUNT || actor === ActorType.SCEP_ACCOUNT
+ isInternal: actor === ActorType.EST_ACCOUNT || actor === ActorType.SCEP_ACCOUNT,
+ applicationId: explicitApplicationId
});
const applicationId = await $resolveApplicationIdForProfile(profile, explicitApplicationId, {
actor,
@@ -1757,7 +1779,8 @@ export const certificateV3ServiceFactory = ({
acmeAccountDAL,
permissionService,
requiredEnrollmentType: EnrollmentType.API,
- isInternal: actor === ActorType.EST_ACCOUNT || actor === ActorType.SCEP_ACCOUNT
+ isInternal: actor === ActorType.EST_ACCOUNT || actor === ActorType.SCEP_ACCOUNT,
+ applicationId: explicitApplicationId
});
const applicationId = await $resolveApplicationIdForProfile(profile, explicitApplicationId, {
actor,
diff --git a/backend/src/services/pki-alert-v2/pki-alert-v2-service.ts b/backend/src/services/pki-alert-v2/pki-alert-v2-service.ts
index 717b47d283..9184719760 100644
--- a/backend/src/services/pki-alert-v2/pki-alert-v2-service.ts
+++ b/backend/src/services/pki-alert-v2/pki-alert-v2-service.ts
@@ -167,6 +167,7 @@ export const pkiAlertV2ServiceFactory = ({
filters: (alert.filters ?? []) as TPkiFilterRule[],
enabled: alert.enabled ?? true,
projectId: alert.projectId,
+ applicationId: alert.applicationId ?? null,
channels: (alert.channels || []).map((channel) => {
const config = decryptChannelConfig<TChannelConfig>(channel, decryptor);
diff --git a/backend/src/services/pki-alert-v2/pki-alert-v2-types.ts b/backend/src/services/pki-alert-v2/pki-alert-v2-types.ts
index 5819eb17ae..64eb18ec39 100644
--- a/backend/src/services/pki-alert-v2/pki-alert-v2-types.ts
+++ b/backend/src/services/pki-alert-v2/pki-alert-v2-types.ts
@@ -354,6 +354,7 @@ export type TAlertV2Response = {
filters: TPkiFilters;
enabled: boolean;
projectId: string;
+ applicationId: string | null;
channels: Array<{
id: string;
channelType: PkiAlertChannelType;