Skip to content

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

Address PR comments

Carlos Monastyrski2eca4030e890
diff --git a/backend/src/db/migrations/20260413325231_add-scep-dynamic-challenges.ts b/backend/src/db/migrations/20260413325231_add-scep-dynamic-challenges.ts
index 744318b29b..64185f31ee 100644
--- a/backend/src/db/migrations/20260413325231_add-scep-dynamic-challenges.ts
+++ b/backend/src/db/migrations/20260413325231_add-scep-dynamic-challenges.ts
@@ -12,15 +12,12 @@ export async function up(knex: Knex): Promise<void> {
t.foreign("scepConfigId").references("id").inTable(TableName.PkiScepEnrollmentConfig).onDelete("CASCADE");
t.index("scepConfigId");
- t.text("hashedChallenge").notNullable();
+ t.string("hashedChallenge", 64).notNullable();
+ t.index("hashedChallenge");
t.timestamp("expiresAt").notNullable();
t.index("expiresAt");
- t.timestamp("usedAt").nullable();
-
- t.string("clientIp", 45).nullable();
-
t.timestamps(true, true, true);
});
@@ -30,8 +27,8 @@ export async function up(knex: Knex): Promise<void> {
if (!(await knex.schema.hasColumn(TableName.PkiScepEnrollmentConfig, "challengeType"))) {
await knex.schema.alterTable(TableName.PkiScepEnrollmentConfig, (t) => {
t.string("challengeType", 32).notNullable().defaultTo("static");
- t.integer("dynamicChallengeExpiryMinutes").notNullable().defaultTo(60);
- t.integer("dynamicChallengeMaxPending").notNullable().defaultTo(100);
+ t.integer("dynamicChallengeExpiryMinutes").nullable();
+ t.integer("dynamicChallengeMaxPending").nullable();
});
}
diff --git a/backend/src/db/schemas/pki-scep-dynamic-challenges.ts b/backend/src/db/schemas/pki-scep-dynamic-challenges.ts
index d990e0c07d..cbc005ab2a 100644
--- a/backend/src/db/schemas/pki-scep-dynamic-challenges.ts
+++ b/backend/src/db/schemas/pki-scep-dynamic-challenges.ts
@@ -12,8 +12,6 @@ export const PkiScepDynamicChallengesSchema = z.object({
scepConfigId: z.string().uuid(),
hashedChallenge: z.string(),
expiresAt: z.date(),
- usedAt: z.date().nullable().optional(),
- clientIp: z.string().nullable().optional(),
createdAt: z.date(),
updatedAt: z.date()
});
diff --git a/backend/src/db/schemas/pki-scep-enrollment-configs.ts b/backend/src/db/schemas/pki-scep-enrollment-configs.ts
index dced3b9388..616b4ee18b 100644
--- a/backend/src/db/schemas/pki-scep-enrollment-configs.ts
+++ b/backend/src/db/schemas/pki-scep-enrollment-configs.ts
@@ -20,8 +20,8 @@ export const PkiScepEnrollmentConfigsSchema = z.object({
createdAt: z.date(),
updatedAt: z.date(),
challengeType: z.string().default("static"),
- dynamicChallengeExpiryMinutes: z.number().default(60),
- dynamicChallengeMaxPending: z.number().default(100)
+ dynamicChallengeExpiryMinutes: z.number().nullable().optional(),
+ dynamicChallengeMaxPending: z.number().nullable().optional()
});
export type TPkiScepEnrollmentConfigs = z.infer<typeof PkiScepEnrollmentConfigsSchema>;
diff --git a/backend/src/ee/routes/scep/pki-scep-router.ts b/backend/src/ee/routes/scep/pki-scep-router.ts
index 5de4b84f26..f7f27e1f37 100644
--- a/backend/src/ee/routes/scep/pki-scep-router.ts
+++ b/backend/src/ee/routes/scep/pki-scep-router.ts
@@ -132,11 +132,9 @@ export const registerPkiScepRouter = async (server: FastifyZodProvider) => {
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
handler: async (req, res) => {
const { profileId } = req.params;
- const clientIp = req.ip || "unknown";
const result = await server.services.pkiScep.generateDynamicChallenge({
profileId,
- clientIp,
actor: req.permission.type,
actorId: req.permission.id,
actorAuthMethod: req.permission.authMethod,
@@ -151,8 +149,7 @@ export const registerPkiScepRouter = async (server: FastifyZodProvider) => {
metadata: {
profileId,
profileSlug: result.profileSlug,
- expiresAt: result.expiresAt,
- clientIp: clientIp || "unknown"
+ expiresAt: result.expiresAt
}
}
});
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 c81eb54800..670b1a3f21 100644
--- a/backend/src/ee/services/audit-log/audit-log-types.ts
+++ b/backend/src/ee/services/audit-log/audit-log-types.ts
@@ -5838,7 +5838,6 @@ interface ScepDynamicChallengeGeneratedEvent {
profileId: string;
profileSlug: string;
expiresAt: string;
- clientIp: string;
};
}
diff --git a/backend/src/ee/services/pki-scep/challenge/index.ts b/backend/src/ee/services/pki-scep/challenge/index.ts
index 62e862b0a1..a327cc0ddb 100644
--- a/backend/src/ee/services/pki-scep/challenge/index.ts
+++ b/backend/src/ee/services/pki-scep/challenge/index.ts
@@ -11,7 +11,7 @@ export { ScepChallengeType } from "./scep-challenge-types";
type TScepChallengeValidatorFactoryDep = {
scepEnrollmentConfigDAL: Pick<TScepEnrollmentConfigDALFactory, "findById">;
- scepDynamicChallengeDAL: Pick<TScepDynamicChallengeDALFactory, "findUnusedByConfigId" | "markUsed">;
+ scepDynamicChallengeDAL: Pick<TScepDynamicChallengeDALFactory, "consumeByHash">;
};
export const getScepChallengeValidator = (
diff --git a/backend/src/ee/services/pki-scep/challenge/scep-challenge-dynamic.ts b/backend/src/ee/services/pki-scep/challenge/scep-challenge-dynamic.ts
index 33c11a7e25..c7c636adf7 100644
--- a/backend/src/ee/services/pki-scep/challenge/scep-challenge-dynamic.ts
+++ b/backend/src/ee/services/pki-scep/challenge/scep-challenge-dynamic.ts
@@ -4,7 +4,7 @@ import { TScepDynamicChallengeDALFactory } from "../pki-scep-dynamic-challenge-d
import { IScepChallengeValidator } from "./scep-challenge-types";
type TDynamicChallengeValidatorDep = {
- scepDynamicChallengeDAL: Pick<TScepDynamicChallengeDALFactory, "findUnusedByConfigId" | "markUsed">;
+ scepDynamicChallengeDAL: Pick<TScepDynamicChallengeDALFactory, "consumeByHash">;
};
export const dynamicChallengeValidator = ({
@@ -13,18 +13,9 @@ export const dynamicChallengeValidator = ({
validate: async (challengePassword: string, scepConfigId: string): Promise<boolean> => {
if (!challengePassword) return false;
- const pendingChallenges = await scepDynamicChallengeDAL.findUnusedByConfigId(scepConfigId);
+ const hashedChallenge = crypto.nativeCrypto.createHash("sha256").update(challengePassword).digest("hex");
+ const claimed = await scepDynamicChallengeDAL.consumeByHash(hashedChallenge, scepConfigId);
- for (const challenge of pendingChallenges) {
- // eslint-disable-next-line no-await-in-loop
- const matches = await crypto.hashing().compareHash(challengePassword, challenge.hashedChallenge);
- if (matches) {
- // eslint-disable-next-line no-await-in-loop
- const claimed = await scepDynamicChallengeDAL.markUsed(challenge.id);
- if (claimed) return true;
- }
- }
-
- return false;
+ return !!claimed;
}
});
diff --git a/backend/src/ee/services/pki-scep/pki-scep-dynamic-challenge-dal.ts b/backend/src/ee/services/pki-scep/pki-scep-dynamic-challenge-dal.ts
index 6862627c6d..5207645dd0 100644
--- a/backend/src/ee/services/pki-scep/pki-scep-dynamic-challenge-dal.ts
+++ b/backend/src/ee/services/pki-scep/pki-scep-dynamic-challenge-dal.ts
@@ -10,16 +10,17 @@ export type TScepDynamicChallengeDALFactory = ReturnType<typeof scepDynamicChall
export const scepDynamicChallengeDALFactory = (db: TDbClient) => {
const orm = ormify(db, TableName.PkiScepDynamicChallenge);
- const findUnusedByConfigId = async (scepConfigId: string, tx?: Knex) => {
+ const consumeByHash = async (hashedChallenge: string, scepConfigId: string, tx?: Knex) => {
try {
- const results = await (tx || db)(TableName.PkiScepDynamicChallenge)
- .where({ scepConfigId })
- .whereNull("usedAt")
- .where("expiresAt", ">", new Date());
+ const [result] = await (tx || db)(TableName.PkiScepDynamicChallenge)
+ .where({ hashedChallenge, scepConfigId })
+ .where("expiresAt", ">", new Date())
+ .delete()
+ .returning("*");
- return results;
+ return result;
} catch (error) {
- throw new DatabaseError({ error, name: "Find unused SCEP dynamic challenges" });
+ throw new DatabaseError({ error, name: "Consume SCEP dynamic challenge by hash" });
}
};
@@ -27,7 +28,6 @@ export const scepDynamicChallengeDALFactory = (db: TDbClient) => {
try {
const result = await (tx || db)(TableName.PkiScepDynamicChallenge)
.where({ scepConfigId })
- .whereNull("usedAt")
.where("expiresAt", ">", new Date())
.count("id as count")
.first();
@@ -38,20 +38,6 @@ export const scepDynamicChallengeDALFactory = (db: TDbClient) => {
}
};
- const markUsed = async (id: string, tx?: Knex) => {
- try {
- const [result] = await (tx || db)(TableName.PkiScepDynamicChallenge)
- .where({ id })
- .whereNull("usedAt")
- .update({ usedAt: new Date() })
- .returning("*");
-
- return result;
- } catch (error) {
- throw new DatabaseError({ error, name: "Mark SCEP dynamic challenge as used" });
- }
- };
-
const pruneExpired = async (scepConfigId: string, tx?: Knex) => {
try {
const deletedCount = await (tx || db)(TableName.PkiScepDynamicChallenge)
@@ -65,11 +51,21 @@ export const scepDynamicChallengeDALFactory = (db: TDbClient) => {
}
};
+ const deleteByConfigId = async (scepConfigId: string, tx?: Knex) => {
+ try {
+ const deletedCount = await (tx || db)(TableName.PkiScepDynamicChallenge).where({ scepConfigId }).delete();
+
+ return deletedCount;
+ } catch (error) {
+ throw new DatabaseError({ error, name: "Delete SCEP dynamic challenges by config" });
+ }
+ };
+
return {
...orm,
- findUnusedByConfigId,
+ consumeByHash,
countPending,
- markUsed,
- pruneExpired
+ pruneExpired,
+ deleteByConfigId
};
};
diff --git a/backend/src/ee/services/pki-scep/pki-scep-service.ts b/backend/src/ee/services/pki-scep/pki-scep-service.ts
index 07a62e19d3..5e0d63b9ed 100644
--- a/backend/src/ee/services/pki-scep/pki-scep-service.ts
+++ b/backend/src/ee/services/pki-scep/pki-scep-service.ts
@@ -9,7 +9,6 @@ import {
ProjectPermissionSub
} from "@app/ee/services/permission/project-permission";
import { extractX509CertFromChain } from "@app/lib/certificates/extract-certificate";
-import { getConfig } from "@app/lib/config/env";
import { crypto } from "@app/lib/crypto/cryptography";
import { BadRequestError, NotFoundError } from "@app/lib/errors";
import { ActorType } from "@app/services/auth/auth-type";
@@ -858,7 +857,6 @@ export const pkiScepServiceFactory = ({
const generateDynamicChallenge = async ({
profileId,
- clientIp,
actor,
actorId,
actorAuthMethod,
@@ -909,17 +907,19 @@ export const pkiScepServiceFactory = ({
const challengePlaintext = randomBytes(32).toString("hex");
- const appCfg = getConfig();
- const hashedChallenge = await crypto.hashing().createHash(challengePlaintext, appCfg.SALT_ROUNDS);
+ const hashedChallenge = crypto.nativeCrypto.createHash("sha256").update(challengePlaintext).digest("hex");
+
+ const expiryMinutes = scepConfig.dynamicChallengeExpiryMinutes ?? 60;
+ const maxPending = scepConfig.dynamicChallengeMaxPending ?? 100;
const expiresAt = new Date();
- expiresAt.setMinutes(expiresAt.getMinutes() + scepConfig.dynamicChallengeExpiryMinutes);
+ expiresAt.setMinutes(expiresAt.getMinutes() + expiryMinutes);
await scepDynamicChallengeDAL.transaction(async (tx) => {
const pendingCount = await scepDynamicChallengeDAL.countPending(scepConfig.id, tx);
- if (pendingCount >= scepConfig.dynamicChallengeMaxPending) {
+ if (pendingCount >= maxPending) {
throw new BadRequestError({
- message: `Maximum number of pending challenges (${scepConfig.dynamicChallengeMaxPending}) reached. Wait for existing challenges to expire or be used.`
+ message: `Maximum number of pending challenges (${maxPending}) reached. Wait for existing challenges to expire or be used.`
});
}
@@ -927,8 +927,7 @@ export const pkiScepServiceFactory = ({
{
scepConfigId: scepConfig.id,
hashedChallenge,
- expiresAt,
- clientIp: clientIp || null
+ expiresAt
},
tx
);
diff --git a/backend/src/ee/services/pki-scep/pki-scep-types.ts b/backend/src/ee/services/pki-scep/pki-scep-types.ts
index f343c81506..321940dab6 100644
--- a/backend/src/ee/services/pki-scep/pki-scep-types.ts
+++ b/backend/src/ee/services/pki-scep/pki-scep-types.ts
@@ -68,7 +68,6 @@ export type THandlePkiOperationDTO = {
export type TGenerateDynamicChallengeDTO = {
profileId: string;
- clientIp: string;
actor: ActorType;
actorId: string;
actorAuthMethod: ActorAuthMethod;
diff --git a/backend/src/server/plugins/auth/inject-identity.ts b/backend/src/server/plugins/auth/inject-identity.ts
index 2974e784bc..0cff32d81a 100644
--- a/backend/src/server/plugins/auth/inject-identity.ts
+++ b/backend/src/server/plugins/auth/inject-identity.ts
@@ -166,7 +166,7 @@ export const injectIdentity = fp(
return;
}
- if (req.url.includes("/scep/") && !req.url.includes("/challenge")) {
+ if (req.url.includes("/scep/") && req.url.includes("pkiclient.exe")) {
return;
}
diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.ts
index 54f121785d..eb8fdffb18 100644
--- a/backend/src/server/routes/index.ts
+++ b/backend/src/server/routes/index.ts
@@ -1376,6 +1376,7 @@ export const registerRoutes = async (
estEnrollmentConfigDAL,
acmeEnrollmentConfigDAL,
scepEnrollmentConfigDAL,
+ scepDynamicChallengeDAL,
certificateBodyDAL,
certificateSecretDAL,
certificateAuthorityDAL,
diff --git a/backend/src/server/routes/v1/certificate-profiles-router.ts b/backend/src/server/routes/v1/certificate-profiles-router.ts
index f78a6099c8..2e3f354ebf 100644
--- a/backend/src/server/routes/v1/certificate-profiles-router.ts
+++ b/backend/src/server/routes/v1/certificate-profiles-router.ts
@@ -367,8 +367,8 @@ export const registerCertificateProfilesRouter = async (
allowCertBasedRenewal: z.boolean(),
challengeType: z.string(),
challengeEndpointUrl: z.string().optional(),
- dynamicChallengeExpiryMinutes: z.number(),
- dynamicChallengeMaxPending: z.number()
+ dynamicChallengeExpiryMinutes: z.number().optional(),
+ dynamicChallengeMaxPending: z.number().optional()
})
.optional(),
externalConfigs: ExternalConfigUnionSchema,
@@ -473,8 +473,8 @@ export const registerCertificateProfilesRouter = async (
allowCertBasedRenewal: z.boolean(),
challengeType: z.string(),
challengeEndpointUrl: z.string().optional(),
- dynamicChallengeExpiryMinutes: z.number(),
- dynamicChallengeMaxPending: z.number()
+ dynamicChallengeExpiryMinutes: z.number().optional(),
+ dynamicChallengeMaxPending: z.number().optional()
})
.optional(),
externalConfigs: ExternalConfigUnionSchema
@@ -664,17 +664,6 @@ export const registerCertificateProfilesRouter = async (
{
message: "SCEP static challenge requires a challenge password with at least 8 characters"
}
- )
- .refine(
- (data) => {
- if (data.scepConfig?.challengeType === ScepChallengeType.STATIC) {
- return !!data.scepConfig.challengePassword;
- }
- return true;
- },
- {
- message: "Switching to static challenge type requires providing a challenge password"
- }
),
response: {
200: z.object({
diff --git a/backend/src/services/certificate-profile/certificate-profile-service.test.ts b/backend/src/services/certificate-profile/certificate-profile-service.test.ts
index d7739441a1..b9bdd39d65 100644
--- a/backend/src/services/certificate-profile/certificate-profile-service.test.ts
+++ b/backend/src/services/certificate-profile/certificate-profile-service.test.ts
@@ -271,6 +271,7 @@ describe("CertificateProfileService", () => {
estEnrollmentConfigDAL: mockEstEnrollmentConfigDAL,
acmeEnrollmentConfigDAL: mockAcmeEnrollmentConfigDAL,
scepEnrollmentConfigDAL: mockScepEnrollmentConfigDAL,
+ scepDynamicChallengeDAL: { deleteByConfigId: vi.fn() },
certificateBodyDAL: mockCertificateBodyDAL,
certificateSecretDAL: mockCertificateSecretDAL,
certificateAuthorityDAL: mockCertificateAuthorityDAL,
diff --git a/backend/src/services/certificate-profile/certificate-profile-service.ts b/backend/src/services/certificate-profile/certificate-profile-service.ts
index b52cb862bb..784d1f2f44 100644
--- a/backend/src/services/certificate-profile/certificate-profile-service.ts
+++ b/backend/src/services/certificate-profile/certificate-profile-service.ts
@@ -10,6 +10,7 @@ import {
} from "@app/ee/services/permission/project-permission";
import { buildUrl } from "@app/ee/services/pki-acme/pki-acme-fns";
import { ScepChallengeType } from "@app/ee/services/pki-scep/challenge";
+import { TScepDynamicChallengeDALFactory } from "@app/ee/services/pki-scep/pki-scep-dynamic-challenge-dal";
import { generateRaCertificate } from "@app/ee/services/pki-scep/pki-scep-fns";
import { getProcessedPermissionRules } from "@app/lib/casl/permission-filter-utils";
import { extractX509CertFromChain } from "@app/lib/certificates/extract-certificate";
@@ -242,6 +243,7 @@ type TCertificateProfileServiceFactoryDep = {
estEnrollmentConfigDAL: TEstEnrollmentConfigDALFactory;
acmeEnrollmentConfigDAL: TAcmeEnrollmentConfigDALFactory;
scepEnrollmentConfigDAL: TScepEnrollmentConfigDALFactory;
+ scepDynamicChallengeDAL: Pick<TScepDynamicChallengeDALFactory, "deleteByConfigId">;
certificateBodyDAL: Pick<TCertificateBodyDALFactory, "findOne">;
certificateSecretDAL: Pick<TCertificateSecretDALFactory, "findOne">;
certificateAuthorityDAL: Pick<TCertificateAuthorityDALFactory, "findById">;
@@ -285,6 +287,7 @@ export const certificateProfileServiceFactory = ({
estEnrollmentConfigDAL,
acmeEnrollmentConfigDAL,
scepEnrollmentConfigDAL,
+ scepDynamicChallengeDAL,
certificateBodyDAL,
certificateSecretDAL,
certificateAuthorityDAL,
@@ -419,8 +422,8 @@ export const certificateProfileServiceFactory = ({
challengeType: string;
includeCaCertInResponse: boolean;
allowCertBasedRenewal: boolean;
- dynamicChallengeExpiryMinutes: number;
- dynamicChallengeMaxPending: number;
+ dynamicChallengeExpiryMinutes: number | null;
+ dynamicChallengeMaxPending: number | null;
}
| undefined;
@@ -455,8 +458,10 @@ export const certificateProfileServiceFactory = ({
challengeType,
includeCaCertInResponse: data.scepConfig.includeCaCertInResponse ?? true,
allowCertBasedRenewal: data.scepConfig.allowCertBasedRenewal ?? true,
- dynamicChallengeExpiryMinutes: data.scepConfig.dynamicChallengeExpiryMinutes ?? 60,
- dynamicChallengeMaxPending: data.scepConfig.dynamicChallengeMaxPending ?? 100
+ dynamicChallengeExpiryMinutes:
+ challengeType === ScepChallengeType.DYNAMIC ? (data.scepConfig.dynamicChallengeExpiryMinutes ?? 60) : null,
+ dynamicChallengeMaxPending:
+ challengeType === ScepChallengeType.DYNAMIC ? (data.scepConfig.dynamicChallengeMaxPending ?? 100) : null
};
}
@@ -725,19 +730,35 @@ export const certificateProfileServiceFactory = ({
}
if (scepConfig && existingProfile.scepConfigId) {
+ const existingScepConfig = await scepEnrollmentConfigDAL.findById(existingProfile.scepConfigId, tx);
+
const scepUpdateData: {
hashedChallengePassword?: string | null;
challengeType?: string;
includeCaCertInResponse?: boolean;
allowCertBasedRenewal?: boolean;
- dynamicChallengeExpiryMinutes?: number;
- dynamicChallengeMaxPending?: number;
+ dynamicChallengeExpiryMinutes?: number | null;
+ dynamicChallengeMaxPending?: number | null;
} = {};
if (scepConfig.challengeType !== undefined) {
scepUpdateData.challengeType = scepConfig.challengeType;
if (scepConfig.challengeType === ScepChallengeType.DYNAMIC) {
scepUpdateData.hashedChallengePassword = null;
+ scepUpdateData.dynamicChallengeExpiryMinutes = scepConfig.dynamicChallengeExpiryMinutes ?? 60;
+ scepUpdateData.dynamicChallengeMaxPending = scepConfig.dynamicChallengeMaxPending ?? 100;
+ }
+ if (scepConfig.challengeType === ScepChallengeType.STATIC) {
+ // Require password when switching from dynamic to static
+ const isSwitchingFromDynamic = existingScepConfig?.challengeType === ScepChallengeType.DYNAMIC;
+ if (isSwitchingFromDynamic && !scepConfig.challengePassword) {
+ throw new BadRequestError({
+ message: "Switching to static challenge type requires providing a challenge password"
+ });
+ }
+ await scepDynamicChallengeDAL.deleteByConfigId(existingProfile.scepConfigId, tx);
+ scepUpdateData.dynamicChallengeExpiryMinutes = null;
+ scepUpdateData.dynamicChallengeMaxPending = null;
}
}
if (scepConfig.challengePassword && scepUpdateData.challengeType !== ScepChallengeType.DYNAMIC) {
@@ -751,10 +772,10 @@ export const certificateProfileServiceFactory = ({
if (scepConfig.allowCertBasedRenewal !== undefined) {
scepUpdateData.allowCertBasedRenewal = scepConfig.allowCertBasedRenewal;
}
- if (scepConfig.dynamicChallengeExpiryMinutes !== undefined) {
+ if (scepUpdateData.challengeType === undefined && scepConfig.dynamicChallengeExpiryMinutes !== undefined) {
scepUpdateData.dynamicChallengeExpiryMinutes = scepConfig.dynamicChallengeExpiryMinutes;
}
- if (scepConfig.dynamicChallengeMaxPending !== undefined) {
+ if (scepUpdateData.challengeType === undefined && scepConfig.dynamicChallengeMaxPending !== undefined) {
scepUpdateData.dynamicChallengeMaxPending = scepConfig.dynamicChallengeMaxPending;
}
if (Object.keys(scepUpdateData).length > 0) {
@@ -871,6 +892,9 @@ export const certificateProfileServiceFactory = ({
profile.scepConfig.scepEndpointUrl = `${siteUrl}/scep/${profile.id}/pkiclient.exe`;
if (profile.scepConfig.challengeType === ScepChallengeType.DYNAMIC) {
profile.scepConfig.challengeEndpointUrl = `${siteUrl}/scep/${profile.id}/challenge`;
+ } else {
+ delete profile.scepConfig.dynamicChallengeExpiryMinutes;
+ delete profile.scepConfig.dynamicChallengeMaxPending;
}
}
@@ -1055,7 +1079,10 @@ export const certificateProfileServiceFactory = ({
scepEndpointUrl: `${siteUrl}/scep/${profile.id}/pkiclient.exe`,
...(profileWithConfigs.scepConfig.challengeType === ScepChallengeType.DYNAMIC
? { challengeEndpointUrl: `${siteUrl}/scep/${profile.id}/challenge` }
- : {})
+ : {
+ dynamicChallengeExpiryMinutes: undefined,
+ dynamicChallengeMaxPending: undefined
+ })
}
: undefined
};
diff --git a/backend/src/services/certificate-profile/certificate-profile-types.ts b/backend/src/services/certificate-profile/certificate-profile-types.ts
index b8bf90f4cc..213750fc0f 100644
--- a/backend/src/services/certificate-profile/certificate-profile-types.ts
+++ b/backend/src/services/certificate-profile/certificate-profile-types.ts
@@ -135,8 +135,8 @@ export type TCertificateProfileWithConfigs = TCertificateProfile & {
allowCertBasedRenewal: boolean;
challengeType: string;
challengeEndpointUrl?: string;
- dynamicChallengeExpiryMinutes: number;
- dynamicChallengeMaxPending: number;
+ dynamicChallengeExpiryMinutes?: number;
+ dynamicChallengeMaxPending?: number;
};
};
diff --git a/docs/documentation/platform/pki/enrollment-methods/scep.mdx b/docs/documentation/platform/pki/enrollment-methods/scep.mdx
index ba6ec25ebd..662c08b6c0 100644
--- a/docs/documentation/platform/pki/enrollment-methods/scep.mdx
+++ b/docs/documentation/platform/pki/enrollment-methods/scep.mdx
@@ -53,7 +53,7 @@ Infisical supports two challenge authentication modes for SCEP enrollment:
The endpoint accepts authenticated `POST` requests and returns a plain-text one-time challenge password. The caller must authenticate using a [Machine Identity](/documentation/platform/identities/machine-identities) access token.
- Configuration options for dynamic challenges:
+ The following settings are part of the certificate profile configuration and apply to all challenges generated for this profile:
- **Challenge Expiry (minutes)**: How long each generated challenge remains valid before expiring. Default: 60 minutes. Maximum: 1440 minutes (24 hours).
- **Max Pending Challenges**: Maximum number of unused challenges that can exist at once. Default: 100. Maximum: 1000.
diff --git a/docs/documentation/platform/pki/integration-guides/jamf-pro-scep.mdx b/docs/documentation/platform/pki/integration-guides/jamf-pro-scep.mdx
index 2a47e759c3..8d4b6723ae 100644
--- a/docs/documentation/platform/pki/integration-guides/jamf-pro-scep.mdx
+++ b/docs/documentation/platform/pki/integration-guides/jamf-pro-scep.mdx
@@ -93,14 +93,14 @@ Before you begin, make sure you have:
Next, configure the challenge authentication:
<Tabs>
- <Tab title="Static">
+ <Tab title="Static Challenge">
- **Challenge Type**: Select **Static** from the dropdown.
- **Challenge**: Enter the **Challenge Password** from your Infisical certificate profile.
- **Verify Challenge**: Re-enter the challenge password to confirm.
![SCEP configuration — Challenge and certificate options](/images/platform/pki/integrations/jamf-pro/scep-config-challenge.png)
</Tab>
- <Tab title="Dynamic">
+ <Tab title="Dynamic Challenge">
- **Challenge Type**: Select **Dynamic** from the dropdown.
No manual challenge password entry is needed, Jamf Pro automatically calls the webhook configured in step 1 to fetch a one-time challenge for each device enrollment.
diff --git a/frontend/src/hooks/api/auditLogs/constants.tsx b/frontend/src/hooks/api/auditLogs/constants.tsx
index ca3efb411d..9274f57e70 100644
--- a/frontend/src/hooks/api/auditLogs/constants.tsx
+++ b/frontend/src/hooks/api/auditLogs/constants.tsx
@@ -319,6 +319,10 @@ export const eventToNameMap: { [K in EventType]: string } = {
[EventType.GET_CERTIFICATE_PROFILE_LATEST_ACTIVE_BUNDLE]:
"Get Certificate Profile Latest Active Bundle",
+ [EventType.SCEP_ENROLLMENT]: "SCEP Certificate Enrollment",
+ [EventType.SCEP_RENEWAL]: "SCEP Certificate Renewal",
+ [EventType.SCEP_DYNAMIC_CHALLENGE_GENERATED]: "SCEP Dynamic Challenge Generated",
+
[EventType.APPROVAL_POLICY_CREATE]: "Create Approval Policy",
[EventType.APPROVAL_POLICY_UPDATE]: "Update Approval Policy",
[EventType.APPROVAL_POLICY_DELETE]: "Delete Approval Policy",
diff --git a/frontend/src/hooks/api/auditLogs/enums.tsx b/frontend/src/hooks/api/auditLogs/enums.tsx
index 5c12c354ef..a74bb03096 100644
--- a/frontend/src/hooks/api/auditLogs/enums.tsx
+++ b/frontend/src/hooks/api/auditLogs/enums.tsx
@@ -313,6 +313,10 @@ export enum EventType {
ORDER_CERTIFICATE_FROM_PROFILE = "order-certificate-from-profile",
GET_CERTIFICATE_PROFILE_LATEST_ACTIVE_BUNDLE = "get-certificate-profile-latest-active-bundle",
+ SCEP_ENROLLMENT = "scep-enrollment",
+ SCEP_RENEWAL = "scep-renewal",
+ SCEP_DYNAMIC_CHALLENGE_GENERATED = "scep-dynamic-challenge-generated",
+
APPROVAL_POLICY_CREATE = "approval-policy-create",
APPROVAL_POLICY_UPDATE = "approval-policy-update",
APPROVAL_POLICY_DELETE = "approval-policy-delete",
diff --git a/frontend/src/hooks/api/certificateProfiles/types.ts b/frontend/src/hooks/api/certificateProfiles/types.ts
index 40ddde6952..6443f99783 100644
--- a/frontend/src/hooks/api/certificateProfiles/types.ts
+++ b/frontend/src/hooks/api/certificateProfiles/types.ts
@@ -96,8 +96,8 @@ export type TCertificateProfileWithDetails = TCertificateProfile & {
allowCertBasedRenewal: boolean;
challengeType: ScepChallengeType;
challengeEndpointUrl?: string;
- dynamicChallengeExpiryMinutes: number;
- dynamicChallengeMaxPending: number;
+ dynamicChallengeExpiryMinutes?: number;
+ dynamicChallengeMaxPending?: number;
};
};
diff --git a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/CreateProfileModal.tsx b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/CreateProfileModal.tsx
index efb21cebe7..441b077620 100644
--- a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/CreateProfileModal.tsx
+++ b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/CreateProfileModal.tsx
@@ -361,9 +361,12 @@ const editSchema = z.preprocess(
.optional(),
scepConfig: z
.object({
- challengePassword: z.string().min(8, "Challenge password must be at least 8 characters"),
+ challengeType: z.nativeEnum(ScepChallengeType).optional(),
+ challengePassword: z.string().optional(),
includeCaCertInResponse: z.boolean().optional(),
- allowCertBasedRenewal: z.boolean().optional()
+ allowCertBasedRenewal: z.boolean().optional(),
+ dynamicChallengeExpiryMinutes: z.number().min(1).max(1440).optional(),
+ dynamicChallengeMaxPending: z.number().min(1).max(1000).optional()
})
.optional(),
externalConfigs: z
@@ -421,6 +424,22 @@ const editSchema = z.preprocess(
path: ["enrollmentType"]
}
)
+ .refine(
+ (data) => {
+ if (
+ data.enrollmentType === EnrollmentType.SCEP &&
+ data.scepConfig?.challengePassword &&
+ data.scepConfig.challengeType !== ScepChallengeType.DYNAMIC
+ ) {
+ return data.scepConfig.challengePassword.length >= 8;
+ }
+ return true;
+ },
+ {
+ message: "Challenge password must be at least 8 characters",
+ path: ["scepConfig", "challengePassword"]
+ }
+ )
);
export type FormData = z.infer<typeof createSchema>;
@@ -1573,26 +1592,32 @@ export const CreateProfileModal = ({ isOpen, onClose, profile, mode = "create" }
<Controller
control={control}
name="scepConfig.challengePassword"
- render={({ field, fieldState: { error } }) => (
- <FormControl
- label="Challenge Password"
- isRequired={!isEdit}
- isError={Boolean(error)}
- errorText={error?.message}
- helperText="The challenge password cannot be viewed after creation. Make sure to save it somewhere safe."
- >
- <Input
- {...field}
- type="password"
- placeholder={
- isEdit
- ? "Leave empty to keep current password"
- : "Enter SCEP challenge password"
- }
- className="w-full"
- />
- </FormControl>
- )}
+ render={({ field, fieldState: { error } }) => {
+ const hadStaticPassword =
+ isEdit &&
+ profile?.scepConfig?.challengeType === ScepChallengeType.STATIC;
+
+ return (
+ <FormControl
+ label="Challenge Password"
+ isRequired={!hadStaticPassword}
+ isError={Boolean(error)}
+ errorText={error?.message}
+ helperText="The challenge password cannot be viewed after saving. Make sure to save it somewhere safe."
+ >
+ <Input
+ {...field}
+ type="password"
+ placeholder={
+ hadStaticPassword
+ ? "Leave empty to keep current password"
+ : "Enter SCEP challenge password"
+ }
+ className="w-full"
+ />
+ </FormControl>
+ );
+ }}
/>
)}