mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 15:27:46 +00:00
misc: add tracking of certificate template ID
This commit is contained in:
@@ -21,6 +21,18 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
|
|
||||||
await createOnUpdateTrigger(knex, TableName.CertificateTemplate);
|
await createOnUpdateTrigger(knex, TableName.CertificateTemplate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const doesCertificateTableHaveTemplateId = await knex.schema.hasColumn(
|
||||||
|
TableName.Certificate,
|
||||||
|
"certificateTemplateId"
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!doesCertificateTableHaveTemplateId) {
|
||||||
|
await knex.schema.alterTable(TableName.Certificate, (tb) => {
|
||||||
|
tb.uuid("certificateTemplateId");
|
||||||
|
tb.foreign("certificateTemplateId").references("id").inTable(TableName.CertificateTemplate).onDelete("SET NULL");
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex: Knex): Promise<void> {
|
||||||
@@ -29,4 +41,15 @@ export async function down(knex: Knex): Promise<void> {
|
|||||||
await knex.schema.dropTable(TableName.CertificateTemplate);
|
await knex.schema.dropTable(TableName.CertificateTemplate);
|
||||||
await dropOnUpdateTrigger(knex, TableName.CertificateTemplate);
|
await dropOnUpdateTrigger(knex, TableName.CertificateTemplate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const doesCertificateTableHaveTemplateId = await knex.schema.hasColumn(
|
||||||
|
TableName.Certificate,
|
||||||
|
"certificateTemplateId"
|
||||||
|
);
|
||||||
|
|
||||||
|
if (doesCertificateTableHaveTemplateId) {
|
||||||
|
await knex.schema.alterTable(TableName.Certificate, (t) => {
|
||||||
|
t.dropColumn("certificateTemplateId");
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ export const CertificatesSchema = z.object({
|
|||||||
revokedAt: z.date().nullable().optional(),
|
revokedAt: z.date().nullable().optional(),
|
||||||
revocationReason: z.number().nullable().optional(),
|
revocationReason: z.number().nullable().optional(),
|
||||||
altNames: z.string().default("").nullable().optional(),
|
altNames: z.string().default("").nullable().optional(),
|
||||||
caCertId: z.string().uuid()
|
caCertId: z.string().uuid(),
|
||||||
|
certificateTemplateId: z.string().uuid().nullable().optional()
|
||||||
});
|
});
|
||||||
|
|
||||||
export type TCertificates = z.infer<typeof CertificatesSchema>;
|
export type TCertificates = z.infer<typeof CertificatesSchema>;
|
||||||
|
|||||||
@@ -1220,6 +1220,7 @@ export const certificateAuthorityServiceFactory = ({
|
|||||||
{
|
{
|
||||||
caId: ca.id,
|
caId: ca.id,
|
||||||
caCertId: caCert.id,
|
caCertId: caCert.id,
|
||||||
|
certificateTemplateId: certificateTemplate?.id,
|
||||||
status: CertStatus.ACTIVE,
|
status: CertStatus.ACTIVE,
|
||||||
friendlyName: friendlyName || commonName,
|
friendlyName: friendlyName || commonName,
|
||||||
commonName,
|
commonName,
|
||||||
@@ -1475,6 +1476,7 @@ export const certificateAuthorityServiceFactory = ({
|
|||||||
{
|
{
|
||||||
caId: ca.id,
|
caId: ca.id,
|
||||||
caCertId: caCert.id,
|
caCertId: caCert.id,
|
||||||
|
certificateTemplateId: certificateTemplate?.id,
|
||||||
status: CertStatus.ACTIVE,
|
status: CertStatus.ACTIVE,
|
||||||
friendlyName: friendlyName || csrObj.subject,
|
friendlyName: friendlyName || csrObj.subject,
|
||||||
commonName: cn,
|
commonName: cn,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { CertStatus } from "./enums";
|
|||||||
export type TCertificate = {
|
export type TCertificate = {
|
||||||
id: string;
|
id: string;
|
||||||
caId: string;
|
caId: string;
|
||||||
|
certificateTemplateId?: string;
|
||||||
status: CertStatus;
|
status: CertStatus;
|
||||||
friendlyName: string;
|
friendlyName: string;
|
||||||
commonName: string;
|
commonName: string;
|
||||||
|
|||||||
+7
-3
@@ -102,6 +102,7 @@ export const CertificateModal = ({ popUp, handlePopUpToggle }: Props) => {
|
|||||||
friendlyName: cert.friendlyName,
|
friendlyName: cert.friendlyName,
|
||||||
commonName: cert.commonName,
|
commonName: cert.commonName,
|
||||||
altNames: cert.altNames,
|
altNames: cert.altNames,
|
||||||
|
certificateTemplateId: cert.certificateTemplateId ?? CERT_TEMPLATE_NONE_VALUE,
|
||||||
ttl: ""
|
ttl: ""
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -215,7 +216,10 @@ export const CertificateModal = ({ popUp, handlePopUpToggle }: Props) => {
|
|||||||
</FormControl>
|
</FormControl>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
{(!selectedCertTemplateId || selectedCertTemplateId === CERT_TEMPLATE_NONE_VALUE) && (
|
{(!selectedCertTemplateId ||
|
||||||
|
selectedCertTemplateId === CERT_TEMPLATE_NONE_VALUE ||
|
||||||
|
cert) && (
|
||||||
|
<>
|
||||||
<Controller
|
<Controller
|
||||||
control={control}
|
control={control}
|
||||||
name="caId"
|
name="caId"
|
||||||
@@ -243,7 +247,6 @@ export const CertificateModal = ({ popUp, handlePopUpToggle }: Props) => {
|
|||||||
</FormControl>
|
</FormControl>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
) && (
|
|
||||||
<Controller
|
<Controller
|
||||||
control={control}
|
control={control}
|
||||||
name="collectionId"
|
name="collectionId"
|
||||||
@@ -270,7 +273,8 @@ export const CertificateModal = ({ popUp, handlePopUpToggle }: Props) => {
|
|||||||
</FormControl>
|
</FormControl>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
)}
|
</>
|
||||||
|
)}
|
||||||
<Controller
|
<Controller
|
||||||
control={control}
|
control={control}
|
||||||
defaultValue=""
|
defaultValue=""
|
||||||
|
|||||||
Reference in New Issue
Block a user