mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-15 04:14:38 +00:00
feat: added api for admin and org gateway management
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
import { Knex } from "knex";
|
||||
|
||||
import { TableName } from "../schemas";
|
||||
import { createOnUpdateTrigger, dropOnUpdateTrigger } from "../utils";
|
||||
|
||||
export async function up(knex: Knex): Promise<void> {
|
||||
if (!(await knex.schema.hasTable(TableName.GatewayInstanceConfig))) {
|
||||
await knex.schema.createTable(TableName.GatewayInstanceConfig, (t) => {
|
||||
t.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid());
|
||||
t.string("caKeyAlgorithm").notNullable();
|
||||
t.boolean("isDisabled").defaultTo(false);
|
||||
|
||||
t.string("infisicalClientCaSerialNumber").notNullable();
|
||||
t.datetime("infisicalClientCaIssuedAt").notNullable();
|
||||
t.datetime("infisicalClientCaExpiration").notNullable();
|
||||
t.binary("encryptedInfisicalClientCaCertificate").notNullable();
|
||||
t.binary("encryptedInfisicalClientCaPrivateKey").notNullable();
|
||||
|
||||
t.string("infisicalClientCertSerialNumber").notNullable();
|
||||
t.string("infisicalClientCertKeyAlgorithm").notNullable();
|
||||
t.datetime("infisicalClientCertIssuedAt").notNullable();
|
||||
t.datetime("infisicalClientCertExpiration").notNullable();
|
||||
t.binary("encryptedInfisicalClientCertificate").notNullable();
|
||||
t.binary("encryptedInfisicalClientPrivateKey").notNullable();
|
||||
t.timestamps(true, true, true);
|
||||
});
|
||||
|
||||
await createOnUpdateTrigger(knex, TableName.GatewayInstanceConfig);
|
||||
}
|
||||
|
||||
if (!(await knex.schema.hasTable(TableName.OrgGatewayRootCa))) {
|
||||
await knex.schema.createTable(TableName.OrgGatewayRootCa, (t) => {
|
||||
t.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid());
|
||||
t.string("caKeyAlgorithm").notNullable();
|
||||
t.string("caSerialNumber").notNullable();
|
||||
t.datetime("caIssuedAt").notNullable();
|
||||
t.datetime("caExpiration").notNullable();
|
||||
t.binary("encryptedCaCertificate").notNullable();
|
||||
t.binary("encryptedCaPrivateKey").notNullable();
|
||||
|
||||
t.uuid("orgId").notNullable();
|
||||
t.foreign("orgId").references("id").inTable(TableName.Organization).onDelete("CASCADE");
|
||||
|
||||
t.timestamps(true, true, true);
|
||||
});
|
||||
|
||||
await createOnUpdateTrigger(knex, TableName.OrgGatewayRootCa);
|
||||
}
|
||||
|
||||
if (!(await knex.schema.hasTable(TableName.Gateway))) {
|
||||
await knex.schema.createTable(TableName.Gateway, (t) => {
|
||||
t.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid());
|
||||
|
||||
t.string("name").notNullable();
|
||||
t.string("serialNumber").notNullable();
|
||||
t.string("keyAlgorithm").notNullable();
|
||||
t.datetime("issuedAt").notNullable();
|
||||
t.datetime("expiration").notNullable();
|
||||
|
||||
t.binary("relayAddress").notNullable();
|
||||
|
||||
t.uuid("orgGatewayRootCaId").notNullable();
|
||||
t.foreign("orgGatewayRootCaId").references("id").inTable(TableName.OrgGatewayRootCa).onDelete("CASCADE");
|
||||
|
||||
t.uuid("identityId").notNullable();
|
||||
t.foreign("identityId").references("id").inTable(TableName.Identity).onDelete("CASCADE");
|
||||
|
||||
t.timestamps(true, true, true);
|
||||
});
|
||||
|
||||
await createOnUpdateTrigger(knex, TableName.Gateway);
|
||||
}
|
||||
}
|
||||
|
||||
export async function down(knex: Knex): Promise<void> {
|
||||
await knex.schema.dropTableIfExists(TableName.GatewayInstanceConfig);
|
||||
await dropOnUpdateTrigger(knex, TableName.GatewayInstanceConfig);
|
||||
|
||||
await knex.schema.dropTableIfExists(TableName.Gateway);
|
||||
await dropOnUpdateTrigger(knex, TableName.Gateway);
|
||||
|
||||
await knex.schema.dropTableIfExists(TableName.OrgGatewayRootCa);
|
||||
await dropOnUpdateTrigger(knex, TableName.OrgGatewayRootCa);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code generated by automation script, DO NOT EDIT.
|
||||
// Automated by pulling database and generating zod schema
|
||||
// To update. Just run npm run generate:schema
|
||||
// Written by akhilmhdh.
|
||||
|
||||
import { z } from "zod";
|
||||
|
||||
import { zodBuffer } from "@app/lib/zod";
|
||||
|
||||
import { TImmutableDBKeys } from "./models";
|
||||
|
||||
export const GatewayInstanceConfigSchema = z.object({
|
||||
id: z.string().uuid(),
|
||||
caKeyAlgorithm: z.string(),
|
||||
isDisabled: z.boolean().default(false).nullable().optional(),
|
||||
infisicalClientCaSerialNumber: z.string(),
|
||||
infisicalClientCaIssuedAt: z.date(),
|
||||
infisicalClientCaExpiration: z.date(),
|
||||
encryptedInfisicalClientCaCertificate: zodBuffer,
|
||||
encryptedInfisicalClientCaPrivateKey: zodBuffer,
|
||||
infisicalClientCertSerialNumber: z.string(),
|
||||
infisicalClientCertKeyAlgorithm: z.string(),
|
||||
infisicalClientCertIssuedAt: z.date(),
|
||||
infisicalClientCertExpiration: z.date(),
|
||||
encryptedInfisicalClientCertificate: zodBuffer,
|
||||
encryptedInfisicalClientPrivateKey: zodBuffer,
|
||||
createdAt: z.date(),
|
||||
updatedAt: z.date()
|
||||
});
|
||||
|
||||
export type TGatewayInstanceConfig = z.infer<typeof GatewayInstanceConfigSchema>;
|
||||
export type TGatewayInstanceConfigInsert = Omit<z.input<typeof GatewayInstanceConfigSchema>, TImmutableDBKeys>;
|
||||
export type TGatewayInstanceConfigUpdate = Partial<Omit<z.input<typeof GatewayInstanceConfigSchema>, TImmutableDBKeys>>;
|
||||
@@ -0,0 +1,28 @@
|
||||
// Code generated by automation script, DO NOT EDIT.
|
||||
// Automated by pulling database and generating zod schema
|
||||
// To update. Just run npm run generate:schema
|
||||
// Written by akhilmhdh.
|
||||
|
||||
import { z } from "zod";
|
||||
|
||||
import { zodBuffer } from "@app/lib/zod";
|
||||
|
||||
import { TImmutableDBKeys } from "./models";
|
||||
|
||||
export const GatewaysSchema = z.object({
|
||||
id: z.string().uuid(),
|
||||
name: z.string(),
|
||||
serialNumber: z.string(),
|
||||
keyAlgorithm: z.string(),
|
||||
issuedAt: z.date(),
|
||||
expiration: z.date(),
|
||||
relayAddress: zodBuffer,
|
||||
orgGatewayRootCaId: z.string().uuid(),
|
||||
identityId: z.string().uuid(),
|
||||
createdAt: z.date(),
|
||||
updatedAt: z.date()
|
||||
});
|
||||
|
||||
export type TGateways = z.infer<typeof GatewaysSchema>;
|
||||
export type TGatewaysInsert = Omit<z.input<typeof GatewaysSchema>, TImmutableDBKeys>;
|
||||
export type TGatewaysUpdate = Partial<Omit<z.input<typeof GatewaysSchema>, TImmutableDBKeys>>;
|
||||
@@ -20,6 +20,8 @@ export * from "./certificates";
|
||||
export * from "./dynamic-secret-leases";
|
||||
export * from "./dynamic-secrets";
|
||||
export * from "./external-kms";
|
||||
export * from "./gateway-instance-config";
|
||||
export * from "./gateways";
|
||||
export * from "./git-app-install-sessions";
|
||||
export * from "./git-app-org";
|
||||
export * from "./group-project-membership-roles";
|
||||
@@ -57,6 +59,7 @@ export * from "./ldap-group-maps";
|
||||
export * from "./models";
|
||||
export * from "./oidc-configs";
|
||||
export * from "./org-bots";
|
||||
export * from "./org-gateway-root-ca";
|
||||
export * from "./org-memberships";
|
||||
export * from "./org-roles";
|
||||
export * from "./organizations";
|
||||
|
||||
@@ -113,6 +113,10 @@ export enum TableName {
|
||||
SecretApprovalRequestSecretTagV2 = "secret_approval_request_secret_tags_v2",
|
||||
SnapshotSecretV2 = "secret_snapshot_secrets_v2",
|
||||
ProjectSplitBackfillIds = "project_split_backfill_ids",
|
||||
// Gateway
|
||||
GatewayInstanceConfig = "gateway_instance_config",
|
||||
OrgGatewayRootCa = "org_gateway_root_ca",
|
||||
Gateway = "gateways",
|
||||
// junction tables with tags
|
||||
SecretV2JnTag = "secret_v2_tag_junction",
|
||||
JnSecretTag = "secret_tag_junction",
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
// Code generated by automation script, DO NOT EDIT.
|
||||
// Automated by pulling database and generating zod schema
|
||||
// To update. Just run npm run generate:schema
|
||||
// Written by akhilmhdh.
|
||||
|
||||
import { z } from "zod";
|
||||
|
||||
import { zodBuffer } from "@app/lib/zod";
|
||||
|
||||
import { TImmutableDBKeys } from "./models";
|
||||
|
||||
export const OrgGatewayRootCaSchema = z.object({
|
||||
id: z.string().uuid(),
|
||||
caKeyAlgorithm: z.string(),
|
||||
caSerialNumber: z.string(),
|
||||
caIssuedAt: z.date(),
|
||||
caExpiration: z.date(),
|
||||
encryptedCaCertificate: zodBuffer,
|
||||
encryptedCaPrivateKey: zodBuffer,
|
||||
orgId: z.string().uuid(),
|
||||
createdAt: z.date(),
|
||||
updatedAt: z.date()
|
||||
});
|
||||
|
||||
export type TOrgGatewayRootCa = z.infer<typeof OrgGatewayRootCaSchema>;
|
||||
export type TOrgGatewayRootCaInsert = Omit<z.input<typeof OrgGatewayRootCaSchema>, TImmutableDBKeys>;
|
||||
export type TOrgGatewayRootCaUpdate = Partial<Omit<z.input<typeof OrgGatewayRootCaSchema>, TImmutableDBKeys>>;
|
||||
Reference in New Issue
Block a user