diff --git a/backend/src/db/migrations/20250205045509_increase-gcp-auth-limit.ts b/backend/src/db/migrations/20250205045509_increase-gcp-auth-limit.ts new file mode 100644 index 000000000..02f3904d5 --- /dev/null +++ b/backend/src/db/migrations/20250205045509_increase-gcp-auth-limit.ts @@ -0,0 +1,36 @@ +import { Knex } from "knex"; +import { TableName } from "../schemas"; + +export async function up(knex: Knex): Promise { + const hasTable = await knex.schema.hasTable(TableName.IdentityGcpAuth); + const hasAllowedProjectsColumn = await knex.schema.hasColumn(TableName.IdentityGcpAuth, "allowedProjects"); + const hasAllowedServiceAccountsColumn = await knex.schema.hasColumn( + TableName.IdentityGcpAuth, + "allowedServiceAccounts" + ); + const hasAllowedZones = await knex.schema.hasColumn(TableName.IdentityGcpAuth, "allowedZones"); + if (hasTable) { + await knex.schema.alterTable(TableName.IdentityGcpAuth, (t) => { + if (hasAllowedProjectsColumn) t.string("allowedProjects", 2500).alter(); + if (hasAllowedServiceAccountsColumn) t.string("allowedServiceAccounts", 5000).alter(); + if (hasAllowedZones) t.string("allowedZones", 2500).alter(); + }); + } +} + +export async function down(knex: Knex): Promise { + const hasTable = await knex.schema.hasTable(TableName.IdentityGcpAuth); + const hasAllowedProjectsColumn = await knex.schema.hasColumn(TableName.IdentityGcpAuth, "allowedProjects"); + const hasAllowedServiceAccountsColumn = await knex.schema.hasColumn( + TableName.IdentityGcpAuth, + "allowedServiceAccounts" + ); + const hasAllowedZones = await knex.schema.hasColumn(TableName.IdentityGcpAuth, "allowedZones"); + if (hasTable) { + await knex.schema.alterTable(TableName.IdentityGcpAuth, (t) => { + if (hasAllowedProjectsColumn) t.string("allowedProjects").alter(); + if (hasAllowedServiceAccountsColumn) t.string("allowedServiceAccounts").alter(); + if (hasAllowedZones) t.string("allowedZones").alter(); + }); + } +} diff --git a/backend/src/db/schemas/identity-gcp-auths.ts b/backend/src/db/schemas/identity-gcp-auths.ts index 65c7db837..208058f60 100644 --- a/backend/src/db/schemas/identity-gcp-auths.ts +++ b/backend/src/db/schemas/identity-gcp-auths.ts @@ -17,9 +17,9 @@ export const IdentityGcpAuthsSchema = z.object({ updatedAt: z.date(), identityId: z.string().uuid(), type: z.string(), - allowedServiceAccounts: z.string(), - allowedProjects: z.string(), - allowedZones: z.string() + allowedServiceAccounts: z.string().nullable().optional(), + allowedProjects: z.string().nullable().optional(), + allowedZones: z.string().nullable().optional() }); export type TIdentityGcpAuths = z.infer; 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 ffabb3cc4..daff35dad 100644 --- a/backend/src/ee/services/audit-log/audit-log-types.ts +++ b/backend/src/ee/services/audit-log/audit-log-types.ts @@ -762,9 +762,9 @@ interface AddIdentityGcpAuthEvent { metadata: { identityId: string; type: string; - allowedServiceAccounts: string; - allowedProjects: string; - allowedZones: string; + allowedServiceAccounts?: string | null; + allowedProjects?: string | null; + allowedZones?: string | null; accessTokenTTL: number; accessTokenMaxTTL: number; accessTokenNumUsesLimit: number; @@ -784,9 +784,9 @@ interface UpdateIdentityGcpAuthEvent { metadata: { identityId: string; type?: string; - allowedServiceAccounts?: string; - allowedProjects?: string; - allowedZones?: string; + allowedServiceAccounts?: string | null; + allowedProjects?: string | null; + allowedZones?: string | null; accessTokenTTL?: number; accessTokenMaxTTL?: number; accessTokenNumUsesLimit?: number;