Skip to content

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

Fixes on certificates not setting an application ID

Carlos Monastyrski5ff149ab266d
diff --git a/backend/src/ee/services/audit-log/audit-log-types.ts b/backend/src/ee/services/audit-log/audit-log-types.ts
index 27a3165180..c9cdef38bc 100644
--- a/backend/src/ee/services/audit-log/audit-log-types.ts
+++ b/backend/src/ee/services/audit-log/audit-log-types.ts
@@ -3141,6 +3141,7 @@ interface CreateCertificateInventoryView {
filters?: Record<string, unknown>;
columns?: string[];
isShared?: boolean;
+ applicationId?: string;
};
}
@@ -3152,6 +3153,7 @@ interface UpdateCertificateInventoryView {
filters?: Record<string, unknown>;
columns?: string[];
isShared?: boolean;
+ applicationId?: string;
};
}
@@ -3160,6 +3162,7 @@ interface DeleteCertificateInventoryView {
metadata: {
viewId: string;
name: string;
+ applicationId?: string;
};
}
@@ -3736,6 +3739,7 @@ interface IssueCertificateFromProfile {
certificateId: string;
commonName: string;
profileName: string;
+ applicationId?: string;
};
}
@@ -3746,6 +3750,7 @@ interface SignCertificateFromProfile {
certificateId: string;
profileName: string;
commonName: string;
+ applicationId?: string;
};
}
@@ -3754,6 +3759,7 @@ interface OrderCertificateFromProfile {
metadata: {
certificateProfileId: string;
profileName: string;
+ applicationId?: string;
};
}
@@ -4224,6 +4230,7 @@ interface GetPkiSyncCertificatesEvent {
count: number;
certificateIds: string[];
destination: string;
+ applicationId?: string;
};
}
@@ -4292,6 +4299,7 @@ interface PkiSyncSetDefaultCertificateEvent {
pkiSyncId: string;
name: string;
certificateId: string;
+ applicationId?: string;
};
}
@@ -4300,6 +4308,7 @@ interface PkiSyncClearDefaultCertificateEvent {
metadata: {
pkiSyncId: string;
name: string;
+ applicationId?: string;
};
}
diff --git a/backend/src/server/routes/v1/cert-manager-access-routers/identities-router.ts b/backend/src/server/routes/v1/cert-manager-access-routers/identities-router.ts
index 47315dba1e..ea56e3ee02 100644
--- a/backend/src/server/routes/v1/cert-manager-access-routers/identities-router.ts
+++ b/backend/src/server/routes/v1/cert-manager-access-routers/identities-router.ts
@@ -104,7 +104,7 @@ export const registerCertManagerAccessIdentitiesRouter = async (server: FastifyZ
config: { rateLimit: readLimit },
schema: {
operationId: "getCertManagerIdentity",
- params: z.object({ identityId: z.string().trim().min(1) }),
+ params: z.object({ identityId: z.string().trim().uuid() }),
response: {
200: z.object({
identityMembership: z.object({
@@ -148,7 +148,7 @@ export const registerCertManagerAccessIdentitiesRouter = async (server: FastifyZ
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
schema: {
operationId: "addCertManagerIdentity",
- params: z.object({ identityId: z.string().trim().min(1) }),
+ params: z.object({ identityId: z.string().trim().uuid() }),
body: z.object({
role: z.string().trim().optional().default(ProjectMembershipRole.NoAccess),
roles: z
@@ -205,7 +205,7 @@ export const registerCertManagerAccessIdentitiesRouter = async (server: FastifyZ
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
schema: {
operationId: "updateCertManagerIdentity",
- params: z.object({ identityId: z.string().trim().min(1) }),
+ params: z.object({ identityId: z.string().trim().uuid() }),
body: RolesUpdateBodySchema,
response: { 200: z.object({ identityMembership: IdentityProjectMembershipsSchema.omit({ projectId: true }) }) }
},
@@ -237,7 +237,7 @@ export const registerCertManagerAccessIdentitiesRouter = async (server: FastifyZ
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
schema: {
operationId: "removeCertManagerIdentity",
- params: z.object({ identityId: z.string().trim().min(1) }),
+ params: z.object({ identityId: z.string().trim().uuid() }),
response: { 200: z.object({ identityMembership: IdentityProjectMembershipsSchema.omit({ projectId: true }) }) }
},
handler: async (req) => {
diff --git a/backend/src/server/routes/v1/cert-manager-access-routers/roles-router.ts b/backend/src/server/routes/v1/cert-manager-access-routers/roles-router.ts
index ec354e336a..fc9bb8ab4a 100644
--- a/backend/src/server/routes/v1/cert-manager-access-routers/roles-router.ts
+++ b/backend/src/server/routes/v1/cert-manager-access-routers/roles-router.ts
@@ -78,7 +78,7 @@ export const registerCertManagerAccessRolesRouter = async (server: FastifyZodPro
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
schema: {
operationId: "updateCertManagerRole",
- params: z.object({ roleId: z.string().trim().min(1) })
+ params: z.object({ roleId: z.string().trim().uuid() })
},
handler: async () => {
throw new BadRequestError({ message: CERT_MANAGER_CUSTOM_ROLE_ERROR });
@@ -92,7 +92,7 @@ export const registerCertManagerAccessRolesRouter = async (server: FastifyZodPro
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
schema: {
operationId: "deleteCertManagerRole",
- params: z.object({ roleId: z.string().trim().min(1) })
+ params: z.object({ roleId: z.string().trim().uuid() })
},
handler: async () => {
throw new BadRequestError({ message: CERT_MANAGER_CUSTOM_ROLE_ERROR });
diff --git a/backend/src/server/routes/v1/cert-manager-access-routers/users-router.ts b/backend/src/server/routes/v1/cert-manager-access-routers/users-router.ts
index 6954ac8545..2bfddfa653 100644
--- a/backend/src/server/routes/v1/cert-manager-access-routers/users-router.ts
+++ b/backend/src/server/routes/v1/cert-manager-access-routers/users-router.ts
@@ -23,7 +23,7 @@ export const registerCertManagerAccessUsersRouter = async (server: FastifyZodPro
schema: {
hide: false,
operationId: "listCertManagerUsers",
- tags: [ApiDocsTags.PkiCertificates],
+ tags: [ApiDocsTags.ProjectUsers],
description: "List Certificate Manager users.",
response: {
200: z.object({
@@ -59,7 +59,7 @@ export const registerCertManagerAccessUsersRouter = async (server: FastifyZodPro
config: { rateLimit: readLimit },
schema: {
operationId: "getCertManagerUser",
- params: z.object({ userId: z.string().trim().min(1) }),
+ params: z.object({ userId: z.string().trim().uuid() }),
response: {
200: z.object({
membership: ProjectMembershipsSchema.extend({
@@ -89,7 +89,7 @@ export const registerCertManagerAccessUsersRouter = async (server: FastifyZodPro
schema: {
hide: false,
operationId: "inviteCertManagerUsers",
- tags: [ApiDocsTags.PkiCertificates],
+ tags: [ApiDocsTags.ProjectUsers],
description: "Invite users to Certificate Manager.",
body: z.object({
emails: z
@@ -159,7 +159,7 @@ export const registerCertManagerAccessUsersRouter = async (server: FastifyZodPro
config: { rateLimit: writeLimit },
schema: {
operationId: "updateCertManagerUser",
- params: z.object({ userId: z.string().trim().min(1) }),
+ params: z.object({ userId: z.string().trim().uuid() }),
body: RolesUpdateBodySchema,
response: { 200: z.object({ roles: ProjectUserMembershipRolesSchema.array() }) }
},
@@ -236,7 +236,7 @@ export const registerCertManagerAccessUsersRouter = async (server: FastifyZodPro
config: { rateLimit: writeLimit },
schema: {
operationId: "removeCertManagerUser",
- params: z.object({ userId: z.string().trim().min(1) }),
+ params: z.object({ userId: z.string().trim().uuid() }),
response: { 200: z.object({ membership: ProjectMembershipsSchema.omit({ projectId: true }) }) }
},
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
diff --git a/backend/src/server/routes/v1/certificate-inventory-view-router.ts b/backend/src/server/routes/v1/certificate-inventory-view-router.ts
index 7eda2ef0f7..1a4590e54a 100644
--- a/backend/src/server/routes/v1/certificate-inventory-view-router.ts
+++ b/backend/src/server/routes/v1/certificate-inventory-view-router.ts
@@ -150,7 +150,8 @@ export const registerCertificateInventoryViewRouter = async (server: FastifyZodP
name: view.name,
filters: req.body.filters,
columns: req.body.columns,
- isShared: req.body.isShared
+ isShared: req.body.isShared,
+ ...(view.applicationId && { applicationId: view.applicationId })
}
}
});
@@ -209,7 +210,8 @@ export const registerCertificateInventoryViewRouter = async (server: FastifyZodP
name: view.name,
filters: req.body.filters,
columns: req.body.columns,
- isShared: req.body.isShared
+ isShared: req.body.isShared,
+ ...(view.applicationId && { applicationId: view.applicationId })
}
}
});
@@ -254,7 +256,8 @@ export const registerCertificateInventoryViewRouter = async (server: FastifyZodP
type: EventType.DELETE_CERTIFICATE_INVENTORY_VIEW,
metadata: {
viewId: req.params.viewId,
- name: view.name
+ name: view.name,
+ ...(view.applicationId && { applicationId: view.applicationId })
}
}
});
diff --git a/backend/src/server/routes/v1/certificate-router.ts b/backend/src/server/routes/v1/certificate-router.ts
index d8e8ba1a20..477725d062 100644
--- a/backend/src/server/routes/v1/certificate-router.ts
+++ b/backend/src/server/routes/v1/certificate-router.ts
@@ -258,7 +258,8 @@ export const registerCertificateRouter = async (server: FastifyZodProvider) => {
type: EventType.ORDER_CERTIFICATE_FROM_PROFILE,
metadata: {
certificateProfileId: requestBody.profileId,
- profileName: data.profileName
+ profileName: data.profileName,
+ ...(requestBody.applicationId && { applicationId: requestBody.applicationId })
}
}
});
@@ -300,7 +301,8 @@ export const registerCertificateRouter = async (server: FastifyZodProvider) => {
certificateProfileId: requestBody.profileId,
certificateId: data.certificateId || "",
profileName: data.profileName,
- commonName: extractedCsrData.commonName || ""
+ commonName: extractedCsrData.commonName || "",
+ ...(requestBody.applicationId && { applicationId: requestBody.applicationId })
}
}
});
@@ -364,7 +366,8 @@ export const registerCertificateRouter = async (server: FastifyZodProvider) => {
certificateProfileId: requestBody.profileId,
certificateId: data.certificateId || "",
commonName: attributes?.commonName || "",
- profileName: data.profileName
+ profileName: data.profileName,
+ ...(requestBody.applicationId && { applicationId: requestBody.applicationId })
}
}
});
diff --git a/backend/src/server/routes/v1/pki-alert-router.ts b/backend/src/server/routes/v1/pki-alert-router.ts
index 5cc97d03c3..e0013de836 100644
--- a/backend/src/server/routes/v1/pki-alert-router.ts
+++ b/backend/src/server/routes/v1/pki-alert-router.ts
@@ -82,7 +82,8 @@ export const registerPkiAlertRouter = async (server: FastifyZodProvider) => {
pkiAlertId: alert.id,
name: alert.name,
eventType: alert.eventType,
- alertBefore: alert.alertBefore
+ alertBefore: alert.alertBefore,
+ ...(alert.applicationId && { applicationId: alert.applicationId })
}
}
});
@@ -223,7 +224,8 @@ export const registerPkiAlertRouter = async (server: FastifyZodProvider) => {
event: {
type: EventType.GET_PKI_ALERT,
metadata: {
- pkiAlertId: alert.id
+ pkiAlertId: alert.id,
+ ...(alert.applicationId && { applicationId: alert.applicationId })
}
}
});
@@ -296,7 +298,8 @@ export const registerPkiAlertRouter = async (server: FastifyZodProvider) => {
pkiAlertId: alert.id,
name: alert.name,
eventType: alert.eventType,
- alertBefore: alert.alertBefore
+ alertBefore: alert.alertBefore,
+ ...(alert.applicationId && { applicationId: alert.applicationId })
}
}
});
@@ -364,7 +367,8 @@ export const registerPkiAlertRouter = async (server: FastifyZodProvider) => {
event: {
type: EventType.DELETE_PKI_ALERT,
metadata: {
- pkiAlertId: alert.id
+ pkiAlertId: alert.id,
+ ...(alert.applicationId && { applicationId: alert.applicationId })
}
}
});
diff --git a/backend/src/server/routes/v1/pki-application-alert-router.ts b/backend/src/server/routes/v1/pki-application-alert-router.ts
index 00a2f7c4ff..a2fddecc09 100644
--- a/backend/src/server/routes/v1/pki-application-alert-router.ts
+++ b/backend/src/server/routes/v1/pki-application-alert-router.ts
@@ -22,7 +22,7 @@ export const registerPkiApplicationAlertRoutes = async (server: FastifyZodProvid
schema: {
hide: false,
operationId: "listPkiApplicationAlerts",
- description: "List alerts for a application.",
+ description: "List alerts for an application.",
tags: [ApiDocsTags.PkiApplications],
params: ApplicationIdParamsSchema,
querystring: z.object({
@@ -66,7 +66,7 @@ export const registerPkiApplicationAlertRoutes = async (server: FastifyZodProvid
schema: {
hide: false,
operationId: "createPkiApplicationAlert",
- description: "Create an alert on a application.",
+ description: "Create an alert on an application.",
tags: [ApiDocsTags.PkiApplications],
params: ApplicationIdParamsSchema,
body: BasePkiAlertV2Schema,
@@ -110,7 +110,7 @@ export const registerPkiApplicationAlertRoutes = async (server: FastifyZodProvid
schema: {
hide: false,
operationId: "updatePkiApplicationAlert",
- description: "Update an alert on a application.",
+ description: "Update an alert on an application.",
tags: [ApiDocsTags.PkiApplications],
params: z.object({
applicationId: z.string().uuid(),
@@ -157,7 +157,7 @@ export const registerPkiApplicationAlertRoutes = async (server: FastifyZodProvid
schema: {
hide: false,
operationId: "deletePkiApplicationAlert",
- description: "Delete an alert from a application.",
+ description: "Delete an alert from an application.",
tags: [ApiDocsTags.PkiApplications],
params: z.object({
applicationId: z.string().uuid(),
diff --git a/backend/src/server/routes/v1/pki-application-enrollment-routers/acme-enrollment-router.ts b/backend/src/server/routes/v1/pki-application-enrollment-routers/acme-enrollment-router.ts
index 193579c254..412049d863 100644
--- a/backend/src/server/routes/v1/pki-application-enrollment-routers/acme-enrollment-router.ts
+++ b/backend/src/server/routes/v1/pki-application-enrollment-routers/acme-enrollment-router.ts
@@ -14,7 +14,7 @@ export const registerPkiApplicationAcmeEnrollmentRouter = async (server: Fastify
schema: {
hide: false,
operationId: "setPkiApplicationAcmeEnrollment",
- description: "Enable or update the ACME enrollment method for a profile on a application.",
+ description: "Enable or update the ACME enrollment method for a profile on an application.",
tags: [ApiDocsTags.PkiApplications],
params: z.object({ applicationId: z.string().uuid(), profileId: z.string().uuid() }),
body: z
@@ -77,7 +77,7 @@ export const registerPkiApplicationAcmeEnrollmentRouter = async (server: Fastify
schema: {
hide: false,
operationId: "clearPkiApplicationAcmeEnrollment",
- description: "Disable the ACME enrollment method for a profile on a application.",
+ description: "Disable the ACME enrollment method for a profile on an application.",
tags: [ApiDocsTags.PkiApplications],
params: z.object({ applicationId: z.string().uuid(), profileId: z.string().uuid() }),
response: { 200: z.object({ applicationId: z.string().uuid(), profileId: z.string().uuid() }) }
@@ -112,7 +112,7 @@ export const registerPkiApplicationAcmeEnrollmentRouter = async (server: Fastify
schema: {
hide: false,
operationId: "revealPkiApplicationAcmeEabSecret",
- description: "Reveal the ACME EAB secret for a profile on a application.",
+ description: "Reveal the ACME EAB secret for a profile on an application.",
tags: [ApiDocsTags.PkiApplications],
params: z.object({ applicationId: z.string().uuid(), profileId: z.string().uuid() }),
response: {
@@ -154,7 +154,7 @@ export const registerPkiApplicationAcmeEnrollmentRouter = async (server: Fastify
schema: {
hide: false,
operationId: "rotatePkiApplicationAcmeEabSecret",
- description: "Rotate the ACME EAB secret for a profile on a application.",
+ description: "Rotate the ACME EAB secret for a profile on an application.",
tags: [ApiDocsTags.PkiApplications],
params: z.object({ applicationId: z.string().uuid(), profileId: z.string().uuid() }),
response: { 200: z.object({ applicationId: z.string().uuid(), profileId: z.string().uuid() }) }
diff --git a/backend/src/server/routes/v1/pki-application-enrollment-routers/api-enrollment-router.ts b/backend/src/server/routes/v1/pki-application-enrollment-routers/api-enrollment-router.ts
index 11429509e5..bb2fdd6a24 100644
--- a/backend/src/server/routes/v1/pki-application-enrollment-routers/api-enrollment-router.ts
+++ b/backend/src/server/routes/v1/pki-application-enrollment-routers/api-enrollment-router.ts
@@ -20,7 +20,7 @@ export const registerPkiApplicationApiEnrollmentRouter = async (server: FastifyZ
schema: {
hide: false,
operationId: "setPkiApplicationApiEnrollment",
- description: "Enable or update the API enrollment method for a profile on a application.",
+ description: "Enable or update the API enrollment method for a profile on an application.",
tags: [ApiDocsTags.PkiApplications],
params: z.object({
applicationId: z.string().uuid(),
@@ -79,7 +79,7 @@ export const registerPkiApplicationApiEnrollmentRouter = async (server: FastifyZ
schema: {
hide: false,
operationId: "clearPkiApplicationApiEnrollment",
- description: "Disable the API enrollment method for a profile on a application.",
+ description: "Disable the API enrollment method for a profile on an application.",
tags: [ApiDocsTags.PkiApplications],
params: z.object({
applicationId: z.string().uuid(),
diff --git a/backend/src/server/routes/v1/pki-application-enrollment-routers/enrollment-state-router.ts b/backend/src/server/routes/v1/pki-application-enrollment-routers/enrollment-state-router.ts
index f19dfaf8e3..5076be249e 100644
--- a/backend/src/server/routes/v1/pki-application-enrollment-routers/enrollment-state-router.ts
+++ b/backend/src/server/routes/v1/pki-application-enrollment-routers/enrollment-state-router.ts
@@ -59,7 +59,7 @@ export const registerPkiApplicationEnrollmentStateRouter = async (server: Fastif
schema: {
hide: false,
operationId: "getPkiApplicationEnrollment",
- description: "Get the enrollment state for a profile on a application.",
+ description: "Get the enrollment state for a profile on an application.",
tags: [ApiDocsTags.PkiApplications],
params: z.object({
applicationId: z.string().uuid(),
diff --git a/backend/src/server/routes/v1/pki-application-enrollment-routers/est-enrollment-router.ts b/backend/src/server/routes/v1/pki-application-enrollment-routers/est-enrollment-router.ts
index 5b10d912fd..5022417092 100644
--- a/backend/src/server/routes/v1/pki-application-enrollment-routers/est-enrollment-router.ts
+++ b/backend/src/server/routes/v1/pki-application-enrollment-routers/est-enrollment-router.ts
@@ -14,7 +14,7 @@ export const registerPkiApplicationEstEnrollmentRouter = async (server: FastifyZ
schema: {
hide: false,
operationId: "setPkiApplicationEstEnrollment",
- description: "Enable or update the EST enrollment method for a profile on a application.",
+ description: "Enable or update the EST enrollment method for a profile on an application.",
tags: [ApiDocsTags.PkiApplications],
params: z.object({ applicationId: z.string().uuid(), profileId: z.string().uuid() }),
body: z.object({
@@ -69,7 +69,7 @@ export const registerPkiApplicationEstEnrollmentRouter = async (server: FastifyZ
schema: {
hide: false,
operationId: "clearPkiApplicationEstEnrollment",
- description: "Disable the EST enrollment method for a profile on a application.",
+ description: "Disable the EST enrollment method for a profile on an application.",
tags: [ApiDocsTags.PkiApplications],
params: z.object({ applicationId: z.string().uuid(), profileId: z.string().uuid() }),
response: {
diff --git a/backend/src/server/routes/v1/pki-application-enrollment-routers/scep-enrollment-router.ts b/backend/src/server/routes/v1/pki-application-enrollment-routers/scep-enrollment-router.ts
index 6475ae1ec6..80d7a56303 100644
--- a/backend/src/server/routes/v1/pki-application-enrollment-routers/scep-enrollment-router.ts
+++ b/backend/src/server/routes/v1/pki-application-enrollment-routers/scep-enrollment-router.ts
@@ -15,7 +15,7 @@ export const registerPkiApplicationScepEnrollmentRouter = async (server: Fastify
schema: {
hide: false,
operationId: "setPkiApplicationScepEnrollment",
- description: "Enable or update the SCEP enrollment method for a profile on a application.",
+ description: "Enable or update the SCEP enrollment method for a profile on an application.",
tags: [ApiDocsTags.PkiApplications],
params: z.object({ applicationId: z.string().uuid(), profileId: z.string().uuid() }),
body: z.object({
@@ -69,7 +69,7 @@ export const registerPkiApplicationScepEnrollmentRouter = async (server: Fastify
schema: {
hide: false,
operationId: "clearPkiApplicationScepEnrollment",
- description: "Disable the SCEP enrollment method for a profile on a application.",
+ description: "Disable the SCEP enrollment method for a profile on an application.",
tags: [ApiDocsTags.PkiApplications],
params: z.object({ applicationId: z.string().uuid(), profileId: z.string().uuid() }),
response: { 200: z.object({ applicationId: z.string().uuid(), profileId: z.string().uuid() }) }
diff --git a/backend/src/server/routes/v1/pki-application-membership-routers/groups-router.ts b/backend/src/server/routes/v1/pki-application-membership-routers/groups-router.ts
index 2872d32b97..44b866f97c 100644
--- a/backend/src/server/routes/v1/pki-application-membership-routers/groups-router.ts
+++ b/backend/src/server/routes/v1/pki-application-membership-routers/groups-router.ts
@@ -23,7 +23,7 @@ export const registerPkiApplicationGroupMembershipRouter = async (server: Fastif
schema: {
hide: false,
operationId: "listPkiApplicationGroupMembers",
- description: "List group members of a application.",
+ description: "List group members of an application.",
tags: [ApiDocsTags.PkiApplications],
params: ApplicationIdParamsSchema,
response: { 200: z.object({ memberships: z.array(ApplicationMemberSchema) }) }
@@ -60,7 +60,7 @@ export const registerPkiApplicationGroupMembershipRouter = async (server: Fastif
schema: {
hide: false,
operationId: "addPkiApplicationGroupMember",
- description: "Add a group as a member of a application.",
+ description: "Add a group as a member of an application.",
tags: [ApiDocsTags.PkiApplications],
params: GroupParamsSchema,
body: RoleBodySchema,
@@ -106,7 +106,7 @@ export const registerPkiApplicationGroupMembershipRouter = async (server: Fastif
schema: {
hide: false,
operationId: "updatePkiApplicationGroupMemberRole",
- description: "Update the role of a group member on a application.",
+ description: "Update the role of a group member on an application.",
tags: [ApiDocsTags.PkiApplications],
params: GroupParamsSchema,
body: RoleBodySchema,
@@ -153,7 +153,7 @@ export const registerPkiApplicationGroupMembershipRouter = async (server: Fastif
schema: {
hide: false,
operationId: "removePkiApplicationGroupMember",
- description: "Remove a group from a application.",
+ description: "Remove a group from an application.",
tags: [ApiDocsTags.PkiApplications],
params: GroupParamsSchema,
response: { 200: RemoveResponseSchema }
diff --git a/backend/src/server/routes/v1/pki-application-membership-routers/identities-router.ts b/backend/src/server/routes/v1/pki-application-membership-routers/identities-router.ts
index 4be69e7da0..107cd380b2 100644
--- a/backend/src/server/routes/v1/pki-application-membership-routers/identities-router.ts
+++ b/backend/src/server/routes/v1/pki-application-membership-routers/identities-router.ts
@@ -23,7 +23,7 @@ export const registerPkiApplicationIdentityMembershipRouter = async (server: Fas
schema: {
hide: false,
operationId: "listPkiApplicationIdentityMembers",
- description: "List identity members of a application.",
+ description: "List identity members of an application.",
tags: [ApiDocsTags.PkiApplications],
params: ApplicationIdParamsSchema,
response: { 200: z.object({ memberships: z.array(ApplicationMemberSchema) }) }
@@ -60,7 +60,7 @@ export const registerPkiApplicationIdentityMembershipRouter = async (server: Fas
schema: {
hide: false,
operationId: "addPkiApplicationIdentityMember",
- description: "Add an identity as a member of a application.",
+ description: "Add an identity as a member of an application.",
tags: [ApiDocsTags.PkiApplications],
params: IdentityParamsSchema,
body: RoleBodySchema,
@@ -106,7 +106,7 @@ export const registerPkiApplicationIdentityMembershipRouter = async (server: Fas
schema: {
hide: false,
operationId: "updatePkiApplicationIdentityMemberRole",
- description: "Update the role of an identity member on a application.",
+ description: "Update the role of an identity member on an application.",
tags: [ApiDocsTags.PkiApplications],
params: IdentityParamsSchema,
body: RoleBodySchema,
@@ -153,7 +153,7 @@ export const registerPkiApplicationIdentityMembershipRouter = async (server: Fas
schema: {
hide: false,
operationId: "removePkiApplicationIdentityMember",
- description: "Remove an identity from a application.",
+ description: "Remove an identity from an application.",
tags: [ApiDocsTags.PkiApplications],
params: IdentityParamsSchema,
response: { 200: RemoveResponseSchema }
diff --git a/backend/src/server/routes/v1/pki-application-membership-routers/users-router.ts b/backend/src/server/routes/v1/pki-application-membership-routers/users-router.ts
index de98738349..2fc04cc123 100644
--- a/backend/src/server/routes/v1/pki-application-membership-routers/users-router.ts
+++ b/backend/src/server/routes/v1/pki-application-membership-routers/users-router.ts
@@ -45,7 +45,7 @@ export const registerPkiApplicationUserMembershipRouter = async (server: Fastify
schema: {
hide: false,
operationId: "listPkiApplicationUserMembers",
- description: "List user members of a application.",
+ description: "List user members of an application.",
tags: [ApiDocsTags.PkiApplications],
params: ApplicationIdParamsSchema,
response: { 200: z.object({ memberships: z.array(ApplicationMemberSchema) }) }
@@ -83,7 +83,7 @@ export const registerPkiApplicationUserMembershipRouter = async (server: Fastify
hide: false,
operationId: "addPkiApplicationUserMembers",
description:
- "Add user members to a application by userId, email, or username. Bootstraps org and project membership for users not already present, then attaches them to the application.",
+ "Add user members to an application by userId, email, or username. Bootstraps org and project membership for users not already present, then attaches them to the application.",
tags: [ApiDocsTags.PkiApplications],
params: ApplicationIdParamsSchema,
body: AddUsersBodySchema,
@@ -153,7 +153,7 @@ export const registerPkiApplicationUserMembershipRouter = async (server: Fastify
schema: {
hide: false,
operationId: "updatePkiApplicationUserMemberRole",
- description: "Update the role of a user member on a application.",
+ description: "Update the role of a user member on an application.",
tags: [ApiDocsTags.PkiApplications],
params: UserParamsSchema,
body: RoleBodySchema,
@@ -201,7 +201,7 @@ export const registerPkiApplicationUserMembershipRouter = async (server: Fastify
schema: {
hide: false,
operationId: "removePkiApplicationUserMember",
- description: "Remove a user from a application.",
+ description: "Remove a user from an application.",
tags: [ApiDocsTags.PkiApplications],
params: UserParamsSchema,
response: { 200: RemoveResponseSchema }
diff --git a/backend/src/server/routes/v1/pki-application-profile-router.ts b/backend/src/server/routes/v1/pki-application-profile-router.ts
index 08bdaa5057..7ef48c6690 100644
--- a/backend/src/server/routes/v1/pki-application-profile-router.ts
+++ b/backend/src/server/routes/v1/pki-application-profile-router.ts
@@ -16,7 +16,7 @@ export const registerPkiApplicationProfileRoutes = async (server: FastifyZodProv
schema: {
hide: false,
operationId: "listPkiApplicationProfiles",
- description: "List profiles attached to a application.",
+ description: "List profiles attached to an application.",
tags: [ApiDocsTags.PkiApplications],
params: ApplicationIdParamsSchema,
response: {
@@ -45,7 +45,7 @@ export const registerPkiApplicationProfileRoutes = async (server: FastifyZodProv
schema: {
hide: false,
operationId: "attachPkiApplicationProfiles",
- description: "Attach one or more profiles to a application.",
+ description: "Attach one or more profiles to an application.",
tags: [ApiDocsTags.PkiApplications],
params: ApplicationIdParamsSchema,
body: z.object({
@@ -90,7 +90,7 @@ export const registerPkiApplicationProfileRoutes = async (server: FastifyZodProv
schema: {
hide: false,
operationId: "detachPkiApplicationProfile",
- description: "Detach a profile from a application.",
+ description: "Detach a profile from an application.",
tags: [ApiDocsTags.PkiApplications],
params: z.object({
applicationId: z.string().uuid(),
diff --git a/backend/src/server/routes/v1/pki-application-router.ts b/backend/src/server/routes/v1/pki-application-router.ts
index 1db5aefcc8..d393a1cc06 100644
--- a/backend/src/server/routes/v1/pki-application-router.ts
+++ b/backend/src/server/routes/v1/pki-application-router.ts
@@ -32,7 +32,7 @@ export const registerPkiApplicationRouter = async (server: FastifyZodProvider) =
schema: {
hide: false,
operationId: "createPkiApplication",
- description: "Create a application.",
+ description: "Create an application.",
tags: [ApiDocsTags.PkiApplications],
body: z.object({
name: ApplicationNameSchema,
@@ -127,7 +127,7 @@ export const registerPkiApplicationRouter = async (server: FastifyZodProvider) =
schema: {
hide: false,
operationId: "getPkiApplication",
- description: "Get a application by id.",
+ description: "Get an application by id.",
tags: [ApiDocsTags.PkiApplications],
params: ApplicationIdParamsSchema,
response: { 200: z.object({ application: PkiApplicationsSchema }) }
@@ -163,7 +163,7 @@ export const registerPkiApplicationRouter = async (server: FastifyZodProvider) =
schema: {
hide: false,
operationId: "getPkiApplicationByName",
- description: "Get a application by name.",
+ description: "Get an application by name.",
tags: [ApiDocsTags.PkiApplications],
params: z.object({ name: ApplicationNameSchema }),
response: { 200: z.object({ application: PkiApplicationsSchema }) }
@@ -199,7 +199,7 @@ export const registerPkiApplicationRouter = async (server: FastifyZodProvider) =
schema: {
hide: false,
operationId: "updatePkiApplication",
- description: "Update a application.",
+ description: "Update an application.",
tags: [ApiDocsTags.PkiApplications],
params: ApplicationIdParamsSchema,
body: z
@@ -245,7 +245,7 @@ export const registerPkiApplicationRouter = async (server: FastifyZodProvider) =
schema: {
hide: false,
operationId: "deletePkiApplication",
- description: "Delete a application.",
+ description: "Delete an application.",
tags: [ApiDocsTags.PkiApplications],
params: ApplicationIdParamsSchema,
response: { 200: z.object({ application: PkiApplicationsSchema }) }
diff --git a/backend/src/server/routes/v1/pki-application-schemas.ts b/backend/src/server/routes/v1/pki-application-schemas.ts
index c26fdc3636..787cf9122d 100644
--- a/backend/src/server/routes/v1/pki-application-schemas.ts
+++ b/backend/src/server/routes/v1/pki-application-schemas.ts
@@ -2,11 +2,6 @@ import { z } from "zod";
export const ApplicationIdParamsSchema = z.object({ applicationId: z.string().uuid() });
-export const ApplicationProfileParamsSchema = z.object({
- applicationId: z.string().uuid(),
- profileId: z.string().uuid()
-});
-
export const ApplicationProfileSchema = z.object({
applicationId: z.string().uuid(),
profileId: z.string().uuid(),
diff --git a/backend/src/server/routes/v1/pki-sync-routers/aws-elastic-load-balancer-pki-sync-router.ts b/backend/src/server/routes/v1/pki-sync-routers/aws-elastic-load-balancer-pki-sync-router.ts
index 12e2ea12c7..552801b5ba 100644
--- a/backend/src/server/routes/v1/pki-sync-routers/aws-elastic-load-balancer-pki-sync-router.ts
+++ b/backend/src/server/routes/v1/pki-sync-routers/aws-elastic-load-balancer-pki-sync-router.ts
@@ -167,7 +167,8 @@ export const registerAwsElasticLoadBalancerPkiSyncRouter = async (
metadata: {
pkiSyncId,
name: pkiSyncInfo.name,
- certificateId
+ certificateId,
+ ...(pkiSyncInfo.applicationId && { applicationId: pkiSyncInfo.applicationId })
}
}
});
@@ -212,7 +213,8 @@ export const registerAwsElasticLoadBalancerPkiSyncRouter = async (
type: EventType.PKI_SYNC_CLEAR_DEFAULT_CERTIFICATE,
metadata: {
pkiSyncId,
- name: pkiSyncInfo.name
+ name: pkiSyncInfo.name,
+ ...(pkiSyncInfo.applicationId && { applicationId: pkiSyncInfo.applicationId })
}
}
});
diff --git a/backend/src/server/routes/v1/pki-sync-routers/pki-sync-endpoints.ts b/backend/src/server/routes/v1/pki-sync-routers/pki-sync-endpoints.ts
index 82c93e2bf6..b8530d9b80 100644
--- a/backend/src/server/routes/v1/pki-sync-routers/pki-sync-endpoints.ts
+++ b/backend/src/server/routes/v1/pki-sync-routers/pki-sync-endpoints.ts
@@ -123,7 +123,8 @@ export const registerSyncPkiEndpoints = ({
type: EventType.GET_PKI_SYNC,
metadata: {
syncId: pkiSyncId,
- destination
+ destination,
+ ...(pkiSync.applicationId && { applicationId: pkiSync.applicationId })
}
}
});
@@ -163,7 +164,8 @@ export const registerSyncPkiEndpoints = ({
metadata: {
pkiSyncId: pkiSync.id,
name: pkiSync.name,
- destination
+ destination,
+ ...(pkiSync.applicationId && { applicationId: pkiSync.applicationId })
}
}
});
@@ -204,7 +206,8 @@ export const registerSyncPkiEndpoints = ({
type: EventType.UPDATE_PKI_SYNC,
metadata: {
pkiSyncId,
- name: pkiSync.name
+ name: pkiSync.name,
+ ...(pkiSync.applicationId && { applicationId: pkiSync.applicationId })
}
}
});
@@ -245,7 +248,8 @@ export const registerSyncPkiEndpoints = ({
metadata: {
pkiSyncId,
name: pkiSync.name,
- destination: pkiSync.destination
+ destination: pkiSync.destination,
+ ...(pkiSync.applicationId && { applicationId: pkiSync.applicationId })
}
}
});
diff --git a/backend/src/server/routes/v1/pki-sync-routers/pki-sync-router.ts b/backend/src/server/routes/v1/pki-sync-routers/pki-sync-router.ts
index ede40afdbc..b6100073db 100644
--- a/backend/src/server/routes/v1/pki-sync-routers/pki-sync-router.ts
+++ b/backend/src/server/routes/v1/pki-sync-routers/pki-sync-router.ts
@@ -207,7 +207,8 @@ export const registerPkiSyncRouter = async (server: FastifyZodProvider, enableOp
type: EventType.GET_PKI_SYNC,
metadata: {
syncId: pkiSyncId,
- destination: pkiSync.destination
+ destination: pkiSync.destination,
+ ...(pkiSync.applicationId && { applicationId: pkiSync.applicationId })
}
}
});
@@ -260,7 +261,8 @@ export const registerPkiSyncRouter = async (server: FastifyZodProvider, enableOp
syncId: pkiSyncId,
destination: pkiSyncInfo.destination,
count: certificates.length,
- certificateIds: certificates.map((c) => c.certificateId)
+ certificateIds: certificates.map((c) => c.certificateId),
+ ...(pkiSyncInfo.applicationId && { applicationId: pkiSyncInfo.applicationId })
}
}
});
@@ -320,7 +322,8 @@ export const registerPkiSyncRouter = async (server: FastifyZodProvider, enableOp
type: EventType.UPDATE_PKI_SYNC,
metadata: {
pkiSyncId,
- name: pkiSyncInfo.name
+ name: pkiSyncInfo.name,
+ ...(pkiSyncInfo.applicationId && { applicationId: pkiSyncInfo.applicationId })
}
}
});
@@ -369,7 +372,8 @@ export const registerPkiSyncRouter = async (server: FastifyZodProvider, enableOp
type: EventType.UPDATE_PKI_SYNC,
metadata: {
pkiSyncId,
- name: pkiSyncInfo.name
+ name: pkiSyncInfo.name,
+ ...(pkiSyncInfo.applicationId && { applicationId: pkiSyncInfo.applicationId })
}
}
});
diff --git a/backend/src/services/approval-policy/approval-policy-service.ts b/backend/src/services/approval-policy/approval-policy-service.ts
index 44460f1134..d16fe9963b 100644
--- a/backend/src/services/approval-policy/approval-policy-service.ts
+++ b/backend/src/services/approval-policy/approval-policy-service.ts
@@ -887,10 +887,11 @@ export const approvalPolicyServiceFactory = ({
ProjectPermissionSub.ApprovalRequests
);
- const requests = await approvalRequestDAL.findByProjectId(policyType, projectId, {
- scopeType: dbScopeType,
- scopeId: dbScopeId
- });
+ const requests = await approvalRequestDAL.findByProjectId(
+ policyType,
+ projectId,
+ scope === ApprovalPolicyScope.Project ? undefined : { scopeType: dbScopeType, scopeId: dbScopeId }
+ );
if (hasReadPermission) {
return { requests, projectId };
diff --git a/backend/src/services/certificate-request/certificate-request-service.test.ts b/backend/src/services/certificate-request/certificate-request-service.test.ts
index 96c19af49e..e82d4035f9 100644
--- a/backend/src/services/certificate-request/certificate-request-service.test.ts
+++ b/backend/src/services/certificate-request/certificate-request-service.test.ts
@@ -46,8 +46,9 @@ describe("CertificateRequestService", () => {
getCertPrivateKey: vi.fn() as any
};
- const mockPermissionService: Pick<TPermissionServiceFactory, "getProjectPermission"> = {
- getProjectPermission: vi.fn() as any
+ const mockPermissionService: Pick<TPermissionServiceFactory, "getProjectPermission" | "getResourcePermission"> = {
+ getProjectPermission: vi.fn() as any,
+ getResourcePermission: vi.fn() as any
};
beforeEach(() => {
diff --git a/backend/src/services/certificate-request/certificate-request-service.ts b/backend/src/services/certificate-request/certificate-request-service.ts
index 5a5111bfb0..6d2d7f439d 100644
--- a/backend/src/services/certificate-request/certificate-request-service.ts
+++ b/backend/src/services/certificate-request/certificate-request-service.ts
@@ -2,13 +2,17 @@ import { ForbiddenError, subject } from "@casl/ability";
import { Knex } from "knex";
import { z } from "zod";
-import { ActionProjectType } from "@app/db/schemas";
+import { ActionProjectType, ResourceType } from "@app/db/schemas";
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";
import {
ProjectPermissionCertificateActions,
ProjectPermissionCertificateProfileActions,
ProjectPermissionSub
} from "@app/ee/services/permission/project-permission";
+import {
+ ResourcePermissionCertificateActions,
+ ResourcePermissionSub
+} from "@app/ee/services/permission/resource-permission";
import { getProcessedPermissionRules } from "@app/lib/casl/permission-filter-utils";
import { BadRequestError, NotFoundError } from "@app/lib/errors";
import { TCertificateDALFactory } from "@app/services/certificate/certificate-dal";
@@ -31,7 +35,7 @@ type TCertificateRequestServiceFactoryDep = {
certificateRequestDAL: TCertificateRequestDALFactory;
certificateDAL: Pick<TCertificateDALFactory, "findById">;
certificateService: Pick<TCertificateServiceFactory, "getCertBody" | "getCertPrivateKey">;
- permissionService: Pick<TPermissionServiceFactory, "getProjectPermission">;
+ permissionService: Pick<TPermissionServiceFactory, "getProjectPermission" | "getResourcePermission">;
resourceMetadataDAL: Pick<TResourceMetadataDALFactory, "find" | "insertMany">;
};
@@ -399,25 +403,47 @@ export const certificateRequestServiceFactory = ({
sortOrder,
metadataFilter
}: TListCertificateRequestsDTO) => {
- const { permission } = await permissionService.getProjectPermission({
- actor,
- actorId,
- projectId,
- actorAuthMethod,
- actorOrgId,
- actionProjectType: ActionProjectType.CertificateManager
- });
+ let processedRules;
+ if (applicationId && (actor === ActorType.USER || actor === ActorType.IDENTITY)) {
+ const { permission } = await permissionService.getResourcePermission({
+ actor,
+ actorId,
+ projectId,
+ resourceType: ResourceType.CertificateApplication,
+ resourceId: applicationId,
+ actorAuthMethod,
+ actorOrgId
+ });
+ ForbiddenError.from(permission).throwUnlessCan(
+ ResourcePermissionCertificateActions.Read,
+ ResourcePermissionSub.Certificates
+ );
+ processedRules = getProcessedPermissionRules(
+ permission,
+ ResourcePermissionCertificateActions.Read,
+ ResourcePermissionSub.Certificates
+ );
+ } else {
+ const { permission } = await permissionService.getProjectPermission({
+ actor,
+ actorId,
+ projectId,
+ actorAuthMethod,
+ actorOrgId,
+ actionProjectType: ActionProjectType.CertificateManager
+ });
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionCertificateActions.Read,
- ProjectPermissionSub.Certificates
- );
+ ForbiddenError.from(permission).throwUnlessCan(
+ ProjectPermissionCertificateActions.Read,
+ ProjectPermissionSub.Certificates
+ );
- const processedRules = getProcessedPermissionRules(
- permission,
- ProjectPermissionCertificateActions.Read,
- ProjectPermissionSub.Certificates
- );
+ processedRules = getProcessedPermissionRules(
+ permission,
+ ProjectPermissionCertificateActions.Read,
+ ProjectPermissionSub.Certificates
+ );
+ }
const options: Parameters<typeof certificateRequestDAL.findByProjectIdWithCertificate>[1] = {
offset,
diff --git a/backend/src/services/certificate-v3/certificate-approval-fns.ts b/backend/src/services/certificate-v3/certificate-approval-fns.ts
index 6a356789de..cf2d641cc6 100644
--- a/backend/src/services/certificate-v3/certificate-approval-fns.ts
+++ b/backend/src/services/certificate-v3/certificate-approval-fns.ts
@@ -379,10 +379,13 @@ export const certificateApprovalServiceFactory = (
const finalRenewBeforeDays = calculateFinalRenewBeforeDays(profile, ttl, new Date(signedCertRecord.notAfter));
- const updateData: { profileId: string; renewBeforeDays?: number } = { profileId };
+ const updateData: { profileId: string; renewBeforeDays?: number; applicationId?: string } = { profileId };
if (finalRenewBeforeDays !== undefined) {
updateData.renewBeforeDays = finalRenewBeforeDays;
}
+ if (certRequest.applicationId) {
+ updateData.applicationId = certRequest.applicationId;
+ }
await certificateDAL.updateById(signedCertRecord.id, updateData, tx);
await certificateRequestDAL.updateById(
@@ -523,7 +526,8 @@ export const certificateApprovalServiceFactory = (
},
certificateRequestId: string,
profile: NonNullable<Awaited<ReturnType<TCertificateProfileDALFactory["findByIdWithConfigs"]>>>,
- certPolicy: NonNullable<Awaited<ReturnType<TCertificatePolicyServiceFactory["getPolicyById"]>>>
+ certPolicy: NonNullable<Awaited<ReturnType<TCertificatePolicyServiceFactory["getPolicyById"]>>>,
+ applicationId?: string | null
): Promise<TCertificateIssuanceResponse> => {
const effectiveSignatureAlgorithm = certificateRequestInput.signatureAlgorithm as
| CertSignatureAlgorithm
@@ -573,6 +577,10 @@ export const certificateApprovalServiceFactory = (
);
}
+ if (applicationId) {
+ await certificateDAL.updateById(processResult.certificateData.id, { applicationId }, tx);
+ }
+
return processResult;
});
@@ -618,7 +626,8 @@ export const certificateApprovalServiceFactory = (
},
certificateRequestId: string,
profile: NonNullable<Awaited<ReturnType<TCertificateProfileDALFactory["findByIdWithConfigs"]>>>,
- certPolicy: NonNullable<Awaited<ReturnType<TCertificatePolicyServiceFactory["getPolicyById"]>>>
+ certPolicy: NonNullable<Awaited<ReturnType<TCertificatePolicyServiceFactory["getPolicyById"]>>>,
+ applicationId?: string | null
): Promise<TCertificateIssuanceResponse> => {
if (!profile.caId) {
throw new NotFoundError({ message: "Certificate Authority ID not found" });
@@ -684,10 +693,15 @@ export const certificateApprovalServiceFactory = (
new Date(certificateRecord.notAfter)
);
- const updateData: { profileId: string; renewBeforeDays?: number } = { profileId: profile.id };
+ const updateData: { profileId: string; renewBeforeDays?: number; applicationId?: string } = {
+ profileId: profile.id
+ };
if (finalRenewBeforeDays !== undefined) {
updateData.renewBeforeDays = finalRenewBeforeDays;
}
+ if (applicationId) {
+ updateData.applicationId = applicationId;
+ }
await certificateDAL.updateById(certificateRecord.id, updateData, tx);
await certificateRequestDAL.updateById(
@@ -830,11 +844,18 @@ export const certificateApprovalServiceFactory = (
certificateRequestInput,
certificateRequestId,
targetProfile,
- certPolicy
+ certPolicy,
+ certRequest.applicationId
);
}
- return await $processCASignedRequest(certificateRequestInput, certificateRequestId, targetProfile, certPolicy);
+ return await $processCASignedRequest(
+ certificateRequestInput,
+ certificateRequestId,
+ targetProfile,
+ certPolicy,
+ certRequest.applicationId
+ );
} catch (error) {
await certificateRequestDAL.updateById(certificateRequestId, {
status: CertificateRequestStatus.FAILED,
diff --git a/backend/src/services/certificate-v3/certificate-v3-service.test.ts b/backend/src/services/certificate-v3/certificate-v3-service.test.ts
index dce28dadb9..65be520d86 100644
--- a/backend/src/services/certificate-v3/certificate-v3-service.test.ts
+++ b/backend/src/services/certificate-v3/certificate-v3-service.test.ts
@@ -274,7 +274,6 @@ describe("CertificateV3Service", () => {
find: vi.fn().mockResolvedValue([])
},
pkiApplicationProfileDAL: {
- findByProfileId: vi.fn().mockResolvedValue(null),
findAllByProfileId: vi.fn().mockResolvedValue([])
} as never
});
diff --git a/backend/src/services/certificate-v3/certificate-v3-service.ts b/backend/src/services/certificate-v3/certificate-v3-service.ts
index 8df4d7e8c9..b258ce27cf 100644
--- a/backend/src/services/certificate-v3/certificate-v3-service.ts
+++ b/backend/src/services/certificate-v3/certificate-v3-service.ts
@@ -160,7 +160,7 @@ type TCertificateV3ServiceFactoryDep = {
approvalPolicyService: Pick<TApprovalPolicyServiceFactory, "createRequestFromPolicy">;
resourceMetadataDAL: Pick<TResourceMetadataDALFactory, "insertMany" | "delete" | "find">;
pkiAlertV2Queue?: Pick<TPkiAlertV2QueueServiceFactory, "queueCertificateEvent">;
- pkiApplicationProfileDAL: Pick<TPkiApplicationProfileDALFactory, "findByProfileId" | "findAllByProfileId">;
+ pkiApplicationProfileDAL: Pick<TPkiApplicationProfileDALFactory, "findAllByProfileId">;
};
export type TCertificateV3ServiceFactory = ReturnType<typeof certificateV3ServiceFactory>;
@@ -767,7 +767,7 @@ export const certificateV3ServiceFactory = ({
);
if (!hasProfileLevelEnrollment) {
throw new BadRequestError({
- message: "This profile must be issued through a Application. Attach it to an Application and issue from there."
+ message: "This profile must be issued through an Application. Attach it to an Application and issue from there."
});
}
@@ -902,6 +902,7 @@ export const certificateV3ServiceFactory = ({
{
projectId: profile.projectId,
profileId: profile.id,
+ applicationId: applicationId ?? null,
commonName: certificateRequest.commonName || null,
altNames: certificateRequest.altNames ? JSON.stringify(certificateRequest.altNames) : null,
keyUsages: convertKeyUsageArrayToLegacy(certificateRequest.keyUsages) || null,
@@ -1183,6 +1184,17 @@ export const certificateV3ServiceFactory = ({
const privateKeyForResponse = canReadPrivateKey ? selfSignedResult.privateKey.toString("utf8") : undefined;
+ try {
+ await pkiAlertV2Queue?.queueCertificateEvent({
+ certificateId: certificateData.id,
+ projectId: profile.projectId,
+ eventType: PkiAlertEventType.ISSUANCE,
+ applicationId: applicationId ?? null
+ });
+ } catch {
+ logger.debug("Failed to queue PKI issuance alert event");
+ }
+
return {
status: CertificateRequestStatus.ISSUED,
certificate: selfSignedResult.certificate.toString("utf8"),
@@ -1522,6 +1534,7 @@ export const certificateV3ServiceFactory = ({
{
projectId: profile.projectId,
profileId: profile.id,
+ applicationId: applicationId ?? null,
csr,
commonName: mappedCertificateRequest.commonName || null,
altNames: mappedCertificateRequest.subjectAlternativeNames
@@ -1924,6 +1937,7 @@ export const certificateV3ServiceFactory = ({
{
projectId: profile.projectId,
profileId: profile.id,
+ applicationId: applicationId ?? null,
csr: certificateOrder.csr || null,
commonName: certificateOrder.commonName || null,
altNames: certificateOrder.altNames ? JSON.stringify(certificateOrder.altNames) : null,
diff --git a/backend/src/services/pki-application/pki-application-profile-dal.ts b/backend/src/services/pki-application/pki-application-profile-dal.ts
index 68849d79ff..44a72b45e8 100644
--- a/backend/src/services/pki-application/pki-application-profile-dal.ts
+++ b/backend/src/services/pki-application/pki-application-profile-dal.ts
@@ -63,15 +63,6 @@ export const pkiApplicationProfileDALFactory = (db: TDbClient) => {
}
};
- const findByProfileId = async (profileId: string, tx?: Knex) => {
- try {
- const row = await (tx || db.replicaNode())(TableName.PkiApplicationProfile).where({ profileId }).first();
- return row;
- } catch (error) {
- throw new DatabaseError({ error, name: "Find application junction by profile" });
- }
- };
-
const findAllByProfileId = async (profileId: string, tx?: Knex) => {
try {
const rows = await (tx || db.replicaNode())(TableName.PkiApplicationProfile).where({ profileId });
@@ -93,7 +84,6 @@ export const pkiApplicationProfileDALFactory = (db: TDbClient) => {
findAllByProfileId,
findByApplicationId,
findOne,
- findProfilesInProject,
- findByProfileId
+ findProfilesInProject
};
};
diff --git a/backend/src/services/pki-sync/pki-sync-service.ts b/backend/src/services/pki-sync/pki-sync-service.ts
index b96fe6a25e..5666f4fce4 100644
--- a/backend/src/services/pki-sync/pki-sync-service.ts
+++ b/backend/src/services/pki-sync/pki-sync-service.ts
@@ -205,7 +205,7 @@ export const pkiSyncServiceFactory = ({
if (!applicationId) {
throw new BadRequestError({
message:
- "Certificate Syncs must be created inside a Application. Open the Application's Certificate Syncs tab and click Add Sync."
+ "Certificate Syncs must be created inside an Application. Open the Application's Certificate Syncs tab and click Add Sync."
});
}
@@ -709,7 +709,7 @@ export const pkiSyncServiceFactory = ({
actor: OrgServiceActor
): Promise<{
addedCertificates: TCertificateSyncs[];
- pkiSyncInfo: { projectId: string; destination: string; name: string };
+ pkiSyncInfo: { projectId: string; destination: string; name: string; applicationId?: string | null };
}> => {
const pkiSync = await pkiSyncDAL.findById(pkiSyncId);
if (!pkiSync) throw new NotFoundError({ message: "PKI sync not found" });
@@ -743,7 +743,8 @@ export const pkiSyncServiceFactory = ({
pkiSyncInfo: {
projectId: pkiSync.projectId,
destination: pkiSync.destination,
- name: pkiSync.name
+ name: pkiSync.name,
+ applicationId: pkiSync.applicationId
}
};
};
@@ -751,7 +752,10 @@ export const pkiSyncServiceFactory = ({
const removeCertificatesFromPkiSync = async (
{ pkiSyncId, certificateIds }: Omit<TRemoveCertificatesFromPkiSyncDTO, "auditLogInfo" | "projectId">,
actor: OrgServiceActor
- ): Promise<{ removedCount: number; pkiSyncInfo: { projectId: string; destination: string; name: string } }> => {
+ ): Promise<{
+ removedCount: number;
+ pkiSyncInfo: { projectId: string; destination: string; name: string; applicationId?: string | null };
+ }> => {
const pkiSync = await pkiSyncDAL.findById(pkiSyncId);
if (!pkiSync) throw new NotFoundError({ message: "PKI sync not found" });
@@ -779,7 +783,8 @@ export const pkiSyncServiceFactory = ({
pkiSyncInfo: {
projectId: pkiSync.projectId,
destination: pkiSync.destination,
- name: pkiSync.name
+ name: pkiSync.name,
+ applicationId: pkiSync.applicationId
}
};
};
@@ -790,7 +795,7 @@ export const pkiSyncServiceFactory = ({
): Promise<{
certificates: TPkiSyncCertificate[];
totalCount: number;
- pkiSyncInfo: { projectId: string; destination: string; name: string };
+ pkiSyncInfo: { projectId: string; destination: string; name: string; applicationId?: string | null };
}> => {
const pkiSync = await pkiSyncDAL.findById(pkiSyncId);
if (!pkiSync) throw new NotFoundError({ message: "PKI sync not found" });
@@ -845,7 +850,8 @@ export const pkiSyncServiceFactory = ({
pkiSyncInfo: {
projectId: pkiSync.projectId,
destination: pkiSync.destination,
- name: pkiSync.name
+ name: pkiSync.name,
+ applicationId: pkiSync.applicationId
}
};
};
@@ -853,7 +859,7 @@ export const pkiSyncServiceFactory = ({
const setCertificateAsDefault = async (
{ pkiSyncId, certificateId }: Omit<TSetCertificateAsDefaultDTO, "auditLogInfo">,
actor: OrgServiceActor
- ): Promise<{ message: string; pkiSyncInfo: { projectId: string; name: string } }> => {
+ ): Promise<{ message: string; pkiSyncInfo: { projectId: string; name: string; applicationId?: string | null } }> => {
const pkiSync = await pkiSyncDAL.findById(pkiSyncId);
if (!pkiSync) throw new NotFoundError({ message: "PKI sync not found" });
@@ -891,14 +897,14 @@ export const pkiSyncServiceFactory = ({
return {
message: "Certificate set as default",
- pkiSyncInfo: { projectId: pkiSync.projectId, name: pkiSync.name }
+ pkiSyncInfo: { projectId: pkiSync.projectId, name: pkiSync.name, applicationId: pkiSync.applicationId }
};
};
const clearDefaultCertificate = async (
{ pkiSyncId }: Omit<TClearDefaultCertificateDTO, "auditLogInfo">,
actor: OrgServiceActor
- ): Promise<{ message: string; pkiSyncInfo: { projectId: string; name: string } }> => {
+ ): Promise<{ message: string; pkiSyncInfo: { projectId: string; name: string; applicationId?: string | null } }> => {
const pkiSync = await pkiSyncDAL.findById(pkiSyncId);
if (!pkiSync) throw new NotFoundError({ message: "PKI sync not found" });
@@ -923,7 +929,7 @@ export const pkiSyncServiceFactory = ({
return {
message: "Default certificate cleared",
- pkiSyncInfo: { projectId: pkiSync.projectId, name: pkiSync.name }
+ pkiSyncInfo: { projectId: pkiSync.projectId, name: pkiSync.name, applicationId: pkiSync.applicationId }
};
};
diff --git a/backend/src/services/pki-sync/pki-sync-types.ts b/backend/src/services/pki-sync/pki-sync-types.ts
index 71ca6b57ad..0abe21e7a9 100644
--- a/backend/src/services/pki-sync/pki-sync-types.ts
+++ b/backend/src/services/pki-sync/pki-sync-types.ts
@@ -18,6 +18,7 @@ export type TPkiSync = {
destinationConfig: Record<string, unknown>;
syncOptions: Record<string, unknown>;
projectId: string;
+ applicationId?: string | null;
subscriberId?: string;
connectionId: string;
createdAt: Date;
diff --git a/backend/src/services/role/org/org-role-factory.ts b/backend/src/services/role/org/org-role-factory.ts
index f91dabccbd..6af08ac969 100644
--- a/backend/src/services/role/org/org-role-factory.ts
+++ b/backend/src/services/role/org/org-role-factory.ts
@@ -3,6 +3,8 @@ import { ForbiddenError } from "@casl/ability";
import { AccessScope, OrganizationActionScope } from "@app/db/schemas";
import {
orgAdminPermissions,
+ orgCertManagerAdminPermissions,
+ orgCertManagerMemberPermissions,
orgMemberPermissions,
orgNoAccessPermissions,
OrgPermissionActions,
@@ -148,6 +150,26 @@ export const newOrgRoleFactory = ({
permissions: orgNoAccessPermissions,
createdAt: new Date(),
updatedAt: new Date()
+ },
+ {
+ id: "b10d49a9-09a9-4443-916a-4246f9ff2c73", // dummy user for zod validation in response
+ name: "Cert Manager Admin",
+ slug: "cert-manager-admin",
+ orgId: scopeField.value,
+ description: "Full administrative access over the Cert Manager product",
+ permissions: orgCertManagerAdminPermissions,
+ createdAt: new Date(),
+ updatedAt: new Date()
+ },
+ {
+ id: "b10d49a9-09a9-4443-916a-4246f9ff2c74", // dummy user for zod validation in response
+ name: "Cert Manager Member",
+ slug: "cert-manager-member",
+ orgId: scopeField.value,
+ description: "Read-only access to the Cert Manager product",
+ permissions: orgCertManagerMemberPermissions,
+ createdAt: new Date(),
+ updatedAt: new Date()
}
];
};
diff --git a/frontend/src/hooks/api/auditLogs/constants.tsx b/frontend/src/hooks/api/auditLogs/constants.tsx
index 2f18cfdb46..93ec142dff 100644
--- a/frontend/src/hooks/api/auditLogs/constants.tsx
+++ b/frontend/src/hooks/api/auditLogs/constants.tsx
@@ -78,6 +78,31 @@ export const eventToNameMap: { [K in EventType]: string } = {
[EventType.GET_CERT]: "Get certificate",
[EventType.DELETE_CERT]: "Delete certificate",
[EventType.REVOKE_CERT]: "Revoke certificate",
+ [EventType.ASSIGN_CERT_TO_APPLICATION]: "Assign certificate to Application",
+ [EventType.CREATE_PKI_APPLICATION]: "Create Application",
+ [EventType.UPDATE_PKI_APPLICATION]: "Update Application",
+ [EventType.DELETE_PKI_APPLICATION]: "Delete Application",
+ [EventType.GET_PKI_APPLICATION]: "Get Application",
+ [EventType.LIST_PKI_APPLICATIONS]: "List Applications",
+ [EventType.ATTACH_PKI_APPLICATION_PROFILES]: "Attach profiles to Application",
+ [EventType.DETACH_PKI_APPLICATION_PROFILE]: "Detach profile from Application",
+ [EventType.ADD_PKI_APPLICATION_MEMBER]: "Add Application member",
+ [EventType.UPDATE_PKI_APPLICATION_MEMBER_ROLE]: "Update Application member role",
+ [EventType.REMOVE_PKI_APPLICATION_MEMBER]: "Remove Application member",
+ [EventType.LIST_PKI_APPLICATION_MEMBERS]: "List Application members",
+ [EventType.GET_PKI_APPLICATION_ENROLLMENT]: "Get Application enrollment",
+ [EventType.SET_PKI_APPLICATION_API_ENROLLMENT]: "Set API enrollment on Application",
+ [EventType.CLEAR_PKI_APPLICATION_API_ENROLLMENT]: "Clear API enrollment on Application",
+ [EventType.SET_PKI_APPLICATION_EST_ENROLLMENT]: "Set EST enrollment on Application",
+ [EventType.CLEAR_PKI_APPLICATION_EST_ENROLLMENT]: "Clear EST enrollment on Application",
+ [EventType.SET_PKI_APPLICATION_ACME_ENROLLMENT]: "Set ACME enrollment on Application",
+ [EventType.CLEAR_PKI_APPLICATION_ACME_ENROLLMENT]: "Clear ACME enrollment on Application",
+ [EventType.REVEAL_PKI_APPLICATION_ACME_EAB_SECRET]: "Reveal ACME EAB secret on Application",
+ [EventType.ROTATE_PKI_APPLICATION_ACME_EAB_SECRET]: "Rotate ACME EAB secret on Application",
+ [EventType.SET_PKI_APPLICATION_SCEP_ENROLLMENT]: "Set SCEP enrollment on Application",
+ [EventType.CLEAR_PKI_APPLICATION_SCEP_ENROLLMENT]: "Clear SCEP enrollment on Application",
+ [EventType.GET_CERT_MANAGER_INSTANCE_STATE]: "Get Certificate Manager instance state",
+ [EventType.SET_CERT_MANAGER_ACTIVE_PROJECT]: "Set active Certificate Manager project",
[EventType.GET_CERT_BODY]: "Get certificate body",
[EventType.GET_CERT_PRIVATE_KEY]: "Get certificate private key",
[EventType.GET_CERT_BUNDLE]: "Get certificate bundle",
diff --git a/frontend/src/hooks/api/auditLogs/enums.tsx b/frontend/src/hooks/api/auditLogs/enums.tsx
index 1c74324712..b6f1c33183 100644
--- a/frontend/src/hooks/api/auditLogs/enums.tsx
+++ b/frontend/src/hooks/api/auditLogs/enums.tsx
@@ -93,6 +93,31 @@ export enum EventType {
GET_CERT = "get-cert",
DELETE_CERT = "delete-cert",
REVOKE_CERT = "revoke-cert",
+ ASSIGN_CERT_TO_APPLICATION = "assign-cert-to-application",
+ CREATE_PKI_APPLICATION = "create-pki-application",
+ UPDATE_PKI_APPLICATION = "update-pki-application",
+ DELETE_PKI_APPLICATION = "delete-pki-application",
+ GET_PKI_APPLICATION = "get-pki-application",
+ LIST_PKI_APPLICATIONS = "list-pki-applications",
+ ATTACH_PKI_APPLICATION_PROFILES = "attach-pki-application-profiles",
+ DETACH_PKI_APPLICATION_PROFILE = "detach-pki-application-profile",
+ ADD_PKI_APPLICATION_MEMBER = "add-pki-application-member",
+ UPDATE_PKI_APPLICATION_MEMBER_ROLE = "update-pki-application-member-role",
+ REMOVE_PKI_APPLICATION_MEMBER = "remove-pki-application-member",
+ LIST_PKI_APPLICATION_MEMBERS = "list-pki-application-members",
+ GET_PKI_APPLICATION_ENROLLMENT = "get-pki-application-enrollment",
+ SET_PKI_APPLICATION_API_ENROLLMENT = "set-pki-application-api-enrollment",
+ CLEAR_PKI_APPLICATION_API_ENROLLMENT = "clear-pki-application-api-enrollment",
+ SET_PKI_APPLICATION_EST_ENROLLMENT = "set-pki-application-est-enrollment",
+ CLEAR_PKI_APPLICATION_EST_ENROLLMENT = "clear-pki-application-est-enrollment",
+ SET_PKI_APPLICATION_ACME_ENROLLMENT = "set-pki-application-acme-enrollment",
+ CLEAR_PKI_APPLICATION_ACME_ENROLLMENT = "clear-pki-application-acme-enrollment",
+ REVEAL_PKI_APPLICATION_ACME_EAB_SECRET = "reveal-pki-application-acme-eab-secret",
+ ROTATE_PKI_APPLICATION_ACME_EAB_SECRET = "rotate-pki-application-acme-eab-secret",
+ SET_PKI_APPLICATION_SCEP_ENROLLMENT = "set-pki-application-scep-enrollment",
+ CLEAR_PKI_APPLICATION_SCEP_ENROLLMENT = "clear-pki-application-scep-enrollment",
+ GET_CERT_MANAGER_INSTANCE_STATE = "get-cert-manager-instance-state",
+ SET_CERT_MANAGER_ACTIVE_PROJECT = "set-cert-manager-active-project",
GET_CERT_BODY = "get-cert-body",
GET_CERT_PRIVATE_KEY = "get-cert-private-key",
GET_CERT_BUNDLE = "get-cert-bundle",