feat(pam): account credential rotation

This commit is contained in:
x032205
2025-10-16 18:12:03 -04:00
parent 4092325a02
commit f0edcd1f0f
25 changed files with 588 additions and 36 deletions
@@ -0,0 +1,43 @@
import { Knex } from "knex";
import { TableName } from "../schemas";
export async function up(knex: Knex): Promise<void> {
if (
!(await knex.schema.hasColumn(TableName.PamAccount, "rotationEnabled")) &&
!(await knex.schema.hasColumn(TableName.PamAccount, "rotationIntervalSeconds")) &&
!(await knex.schema.hasColumn(TableName.PamAccount, "lastRotatedAt"))
) {
await knex.schema.alterTable(TableName.PamAccount, (t) => {
t.boolean("rotationEnabled").notNullable().defaultTo(false);
t.integer("rotationIntervalSeconds").notNullable().defaultTo(2592000);
t.timestamp("lastRotatedAt").nullable();
});
}
if (!(await knex.schema.hasColumn(TableName.PamResource, "encryptedRotationAccountCredentials"))) {
await knex.schema.alterTable(TableName.PamResource, (t) => {
t.binary("encryptedRotationAccountCredentials").nullable();
});
}
}
export async function down(knex: Knex): Promise<void> {
if (await knex.schema.hasColumn(TableName.PamResource, "encryptedRotationAccountCredentials")) {
await knex.schema.alterTable(TableName.PamResource, (t) => {
t.dropColumn("encryptedRotationAccountCredentials");
});
}
if (
(await knex.schema.hasColumn(TableName.PamAccount, "rotationEnabled")) &&
(await knex.schema.hasColumn(TableName.PamAccount, "rotationIntervalSeconds")) &&
(await knex.schema.hasColumn(TableName.PamAccount, "lastRotatedAt"))
) {
await knex.schema.alterTable(TableName.PamAccount, (t) => {
t.dropColumn("lastRotatedAt");
t.dropColumn("rotationIntervalSeconds");
t.dropColumn("rotationEnabled");
});
}
}