Skip to content

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

Merge remote-tracking branch 'origin/main' into feat/SEC-1

Carlos Monastyrskif39b958f1305
diff --cc backend/src/ee/routes/est/certificate-est-router.ts
index a868aafa2f,aa67edf39c..de39b4c8a0
--- a/backend/src/ee/routes/est/certificate-est-router.ts
+++ b/backend/src/ee/routes/est/certificate-est-router.ts
@@@ -90,27 -105,41 +101,43 @@@ export const registerCertificateEstRout
return;
}
- const { identifier } = (req.params as { identifier?: string }) ?? {};
- if (!identifier) {
- throw new NotFoundError({ message: "Certificate template or profile not found" });
- }
-
- const identifierType = await getIdentifierType(identifier);
- if (!identifierType) {
- throw new NotFoundError({ message: "Certificate template or profile not found" });
- }
- const appPathIdx = urlFragments.indexOf("applications");
- const isAppScoped =
- appPathIdx !== -1 && urlFragments[appPathIdx + 2] === "profiles" && urlFragments[appPathIdx + 4];
++ const params =
++ (req.params as { identifier?: string; applicationId?: string; profileId?: string }) ?? {};
++ const isAppScoped = matchedRoute.startsWith("/applications/");
let estConfig;
- if (identifierType === "profile") {
+ if (isAppScoped) {
- const applicationId = urlFragments[appPathIdx + 1];
- const profileId = urlFragments[appPathIdx + 3];
++ const { applicationId, profileId } = params;
++ if (!applicationId || !profileId) {
++ throw new NotFoundError({ message: "Certificate profile not found" });
++ }
estConfig = await server.services.certificateProfile.getEstConfigurationByProfile({
- profileId: identifier,
+ profileId,
+ applicationId,
isInternal: true
});
} else {
- estConfig = await server.services.certificateTemplate.getEstConfiguration({
- isInternal: true,
- certificateTemplateId: identifier
- });
- const identifier = urlFragments.slice(-2)[0];
++ const { identifier } = params;
++ if (!identifier) {
++ throw new NotFoundError({ message: "Certificate template or profile not found" });
++ }
++
+ const identifierType = await getIdentifierType(identifier);
+ if (!identifierType) {
- res.raw.statusCode = 404;
- res.raw.setHeader("Content-Type", "text/plain");
- res.raw.write("Certificate template or profile not found");
- res.raw.flushHeaders();
- return;
++ throw new NotFoundError({ message: "Certificate template or profile not found" });
+ }
+
+ if (identifierType === "profile") {
+ estConfig = await server.services.certificateProfile.getEstConfigurationByProfile({
+ profileId: identifier,
+ isInternal: true
+ });
+ } else {
+ estConfig = await server.services.certificateTemplate.getEstConfiguration({
+ isInternal: true,
+ certificateTemplateId: identifier
+ });
+ }
}
if (!estConfig.isEnabled) {