Merge pull request #3680 from Infisical/misc/pki-improvements

misc: general improvements
This commit is contained in:
Sheen
2025-05-30 01:48:36 +08:00
committed by GitHub
5 changed files with 27 additions and 12 deletions

View File

@@ -311,7 +311,6 @@ export const certificateAuthorityServiceFactory = ({
}
const updatedCa = await internalCertificateAuthorityService.updateCaById({
...configuration,
isInternal: true,
enableDirectIssuance,
caId: certificateAuthority.id,

View File

@@ -55,8 +55,4 @@ export const CreateInternalCertificateAuthoritySchema = GenericCreateCertificate
configuration: InternalCertificateAuthorityConfigurationSchema
});
export const UpdateInternalCertificateAuthoritySchema = GenericUpdateCertificateAuthorityFieldsSchema(
CaType.INTERNAL
).extend({
configuration: InternalCertificateAuthorityConfigurationSchema.optional()
});
export const UpdateInternalCertificateAuthoritySchema = GenericUpdateCertificateAuthorityFieldsSchema(CaType.INTERNAL);

View File

@@ -137,6 +137,15 @@ export const pkiSubscriberServiceFactory = ({
}
}
const ca = await certificateAuthorityDAL.findById(caId);
if (!ca) {
throw new NotFoundError({ message: `CA with ID '${caId}' not found` });
}
if (ca.projectId !== projectId) {
throw new BadRequestError({ message: "CA does not belong to the project" });
}
const newSubscriber = await pkiSubscriberDAL.create({
caId,
projectId,
@@ -245,6 +254,17 @@ export const pkiSubscriberServiceFactory = ({
}
}
if (caId) {
const ca = await certificateAuthorityDAL.findById(caId);
if (!ca) {
throw new NotFoundError({ message: `CA with ID '${caId}' not found` });
}
if (ca.projectId !== projectId) {
throw new BadRequestError({ message: "CA does not belong to the project" });
}
}
const updatedSubscriber = await pkiSubscriberDAL.updateById(subscriber.id, {
caId,
name,