mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-18 17:41:16 +00:00
PKI: add support for auto-renewal option on API enrollment type
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
import { Knex } from "knex";
|
||||
|
||||
import { TableName } from "../schemas";
|
||||
|
||||
export async function up(knex: Knex): Promise<void> {
|
||||
if (await knex.schema.hasColumn(TableName.PkiApiEnrollmentConfig, "autoRenewDays")) {
|
||||
await knex.schema.alterTable(TableName.PkiApiEnrollmentConfig, (t) => {
|
||||
t.dropColumn("autoRenewDays");
|
||||
t.integer("renewBeforeDays");
|
||||
});
|
||||
}
|
||||
|
||||
if (!(await knex.schema.hasColumn(TableName.Certificate, "renewBeforeDays"))) {
|
||||
await knex.schema.alterTable(TableName.Certificate, (t) => {
|
||||
t.integer("renewBeforeDays").nullable();
|
||||
t.uuid("renewedFromId").nullable();
|
||||
t.uuid("renewedById").nullable();
|
||||
t.text("renewalError").nullable();
|
||||
t.string("keyAlgorithm").nullable();
|
||||
t.string("signatureAlgorithm").nullable();
|
||||
t.foreign("renewedFromId").references("id").inTable(TableName.Certificate).onDelete("SET NULL");
|
||||
t.foreign("renewedById").references("id").inTable(TableName.Certificate).onDelete("SET NULL");
|
||||
t.index("renewedFromId");
|
||||
t.index("renewedById");
|
||||
t.index("renewBeforeDays");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export async function down(knex: Knex): Promise<void> {
|
||||
if (await knex.schema.hasColumn(TableName.Certificate, "renewBeforeDays")) {
|
||||
await knex.schema.alterTable(TableName.Certificate, (t) => {
|
||||
t.dropForeign(["renewedFromId"]);
|
||||
t.dropForeign(["renewedById"]);
|
||||
t.dropIndex("renewedFromId");
|
||||
t.dropIndex("renewedById");
|
||||
t.dropIndex("renewBeforeDays");
|
||||
t.dropColumn("renewBeforeDays");
|
||||
t.dropColumn("renewedFromId");
|
||||
t.dropColumn("renewedById");
|
||||
t.dropColumn("renewalError");
|
||||
t.dropColumn("keyAlgorithm");
|
||||
t.dropColumn("signatureAlgorithm");
|
||||
});
|
||||
}
|
||||
|
||||
if (await knex.schema.hasColumn(TableName.PkiApiEnrollmentConfig, "renewBeforeDays")) {
|
||||
await knex.schema.alterTable(TableName.PkiApiEnrollmentConfig, (t) => {
|
||||
t.dropColumn("renewBeforeDays");
|
||||
t.integer("autoRenewDays");
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,13 @@ export const CertificatesSchema = z.object({
|
||||
extendedKeyUsages: z.string().array().nullable().optional(),
|
||||
projectId: z.string(),
|
||||
pkiSubscriberId: z.string().uuid().nullable().optional(),
|
||||
profileId: z.string().uuid().nullable().optional()
|
||||
profileId: z.string().uuid().nullable().optional(),
|
||||
renewBeforeDays: z.number().nullable().optional(),
|
||||
renewedFromId: z.string().uuid().nullable().optional(),
|
||||
renewedById: z.string().uuid().nullable().optional(),
|
||||
renewalError: z.string().nullable().optional(),
|
||||
keyAlgorithm: z.string().nullable().optional(),
|
||||
signatureAlgorithm: z.string().nullable().optional()
|
||||
});
|
||||
|
||||
export type TCertificates = z.infer<typeof CertificatesSchema>;
|
||||
|
||||
@@ -10,7 +10,7 @@ import { TImmutableDBKeys } from "./models";
|
||||
export const PkiApiEnrollmentConfigsSchema = z.object({
|
||||
id: z.string().uuid(),
|
||||
autoRenew: z.boolean().default(false).nullable().optional(),
|
||||
autoRenewDays: z.number().nullable().optional(),
|
||||
renewBeforeDays: z.number().nullable().optional(),
|
||||
createdAt: z.date(),
|
||||
updatedAt: z.date()
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user