misc: updated proxy terminology to relay

This commit is contained in:
Sheen Capadngan
2025-09-09 01:30:45 +08:00
parent 09d179f30d
commit c9136a23bf
34 changed files with 1314 additions and 1314 deletions
@@ -4,68 +4,68 @@ import { TableName } from "../schemas";
import { createOnUpdateTrigger, dropOnUpdateTrigger } from "../utils";
export async function up(knex: Knex): Promise<void> {
if (!(await knex.schema.hasTable(TableName.InstanceProxyConfig))) {
await knex.schema.createTable(TableName.InstanceProxyConfig, (t) => {
if (!(await knex.schema.hasTable(TableName.InstanceRelayConfig))) {
await knex.schema.createTable(TableName.InstanceRelayConfig, (t) => {
t.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid());
t.timestamps(true, true, true);
// Root CA for proxy PKI
t.binary("encryptedRootProxyPkiCaPrivateKey").notNullable();
t.binary("encryptedRootProxyPkiCaCertificate").notNullable();
// Root CA for relay PKI
t.binary("encryptedRootRelayPkiCaPrivateKey").notNullable();
t.binary("encryptedRootRelayPkiCaCertificate").notNullable();
// Instance CA for proxy PKI
t.binary("encryptedInstanceProxyPkiCaPrivateKey").notNullable();
t.binary("encryptedInstanceProxyPkiCaCertificate").notNullable();
t.binary("encryptedInstanceProxyPkiCaCertificateChain").notNullable();
// Instance CA for relay PKI
t.binary("encryptedInstanceRelayPkiCaPrivateKey").notNullable();
t.binary("encryptedInstanceRelayPkiCaCertificate").notNullable();
t.binary("encryptedInstanceRelayPkiCaCertificateChain").notNullable();
// Instance client/server intermediates for proxy PKI
t.binary("encryptedInstanceProxyPkiClientCaPrivateKey").notNullable();
t.binary("encryptedInstanceProxyPkiClientCaCertificate").notNullable();
t.binary("encryptedInstanceProxyPkiClientCaCertificateChain").notNullable();
t.binary("encryptedInstanceProxyPkiServerCaPrivateKey").notNullable();
t.binary("encryptedInstanceProxyPkiServerCaCertificate").notNullable();
t.binary("encryptedInstanceProxyPkiServerCaCertificateChain").notNullable();
// Instance client/server intermediates for relay PKI
t.binary("encryptedInstanceRelayPkiClientCaPrivateKey").notNullable();
t.binary("encryptedInstanceRelayPkiClientCaCertificate").notNullable();
t.binary("encryptedInstanceRelayPkiClientCaCertificateChain").notNullable();
t.binary("encryptedInstanceRelayPkiServerCaPrivateKey").notNullable();
t.binary("encryptedInstanceRelayPkiServerCaCertificate").notNullable();
t.binary("encryptedInstanceRelayPkiServerCaCertificateChain").notNullable();
// Org Parent CAs for proxy
t.binary("encryptedOrgProxyPkiCaPrivateKey").notNullable();
t.binary("encryptedOrgProxyPkiCaCertificate").notNullable();
t.binary("encryptedOrgProxyPkiCaCertificateChain").notNullable();
// Org Parent CAs for relay
t.binary("encryptedOrgRelayPkiCaPrivateKey").notNullable();
t.binary("encryptedOrgRelayPkiCaCertificate").notNullable();
t.binary("encryptedOrgRelayPkiCaCertificateChain").notNullable();
// Instance SSH CAs for proxy
t.binary("encryptedInstanceProxySshClientCaPrivateKey").notNullable();
t.binary("encryptedInstanceProxySshClientCaPublicKey").notNullable();
t.binary("encryptedInstanceProxySshServerCaPrivateKey").notNullable();
t.binary("encryptedInstanceProxySshServerCaPublicKey").notNullable();
// Instance SSH CAs for relay
t.binary("encryptedInstanceRelaySshClientCaPrivateKey").notNullable();
t.binary("encryptedInstanceRelaySshClientCaPublicKey").notNullable();
t.binary("encryptedInstanceRelaySshServerCaPrivateKey").notNullable();
t.binary("encryptedInstanceRelaySshServerCaPublicKey").notNullable();
});
await createOnUpdateTrigger(knex, TableName.InstanceProxyConfig);
await createOnUpdateTrigger(knex, TableName.InstanceRelayConfig);
}
// Org-level proxy configuration (one-to-one with organization)
if (!(await knex.schema.hasTable(TableName.OrgProxyConfig))) {
await knex.schema.createTable(TableName.OrgProxyConfig, (t) => {
// Org-level relay configuration (one-to-one with organization)
if (!(await knex.schema.hasTable(TableName.OrgRelayConfig))) {
await knex.schema.createTable(TableName.OrgRelayConfig, (t) => {
t.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid());
t.timestamps(true, true, true);
t.uuid("orgId").notNullable().unique();
t.foreign("orgId").references("id").inTable(TableName.Organization).onDelete("CASCADE");
// Org-scoped proxy PKI (client + server)
t.binary("encryptedProxyPkiClientCaPrivateKey").notNullable();
t.binary("encryptedProxyPkiClientCaCertificate").notNullable();
t.binary("encryptedProxyPkiClientCaCertificateChain").notNullable();
t.binary("encryptedProxyPkiServerCaPrivateKey").notNullable();
t.binary("encryptedProxyPkiServerCaCertificate").notNullable();
t.binary("encryptedProxyPkiServerCaCertificateChain").notNullable();
// Org-scoped relay PKI (client + server)
t.binary("encryptedRelayPkiClientCaPrivateKey").notNullable();
t.binary("encryptedRelayPkiClientCaCertificate").notNullable();
t.binary("encryptedRelayPkiClientCaCertificateChain").notNullable();
t.binary("encryptedRelayPkiServerCaPrivateKey").notNullable();
t.binary("encryptedRelayPkiServerCaCertificate").notNullable();
t.binary("encryptedRelayPkiServerCaCertificateChain").notNullable();
// Org-scoped proxy SSH (client + server)
t.binary("encryptedProxySshClientCaPrivateKey").notNullable();
t.binary("encryptedProxySshClientCaPublicKey").notNullable();
t.binary("encryptedProxySshServerCaPrivateKey").notNullable();
t.binary("encryptedProxySshServerCaPublicKey").notNullable();
// Org-scoped relay SSH (client + server)
t.binary("encryptedRelaySshClientCaPrivateKey").notNullable();
t.binary("encryptedRelaySshClientCaPublicKey").notNullable();
t.binary("encryptedRelaySshServerCaPrivateKey").notNullable();
t.binary("encryptedRelaySshServerCaPublicKey").notNullable();
});
await createOnUpdateTrigger(knex, TableName.OrgProxyConfig);
await createOnUpdateTrigger(knex, TableName.OrgRelayConfig);
}
if (!(await knex.schema.hasTable(TableName.OrgGatewayConfigV2))) {
@@ -87,8 +87,8 @@ export async function up(knex: Knex): Promise<void> {
await createOnUpdateTrigger(knex, TableName.OrgGatewayConfigV2);
}
if (!(await knex.schema.hasTable(TableName.Proxy))) {
await knex.schema.createTable(TableName.Proxy, (t) => {
if (!(await knex.schema.hasTable(TableName.Relay))) {
await knex.schema.createTable(TableName.Relay, (t) => {
t.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid());
t.timestamps(true, true, true);
@@ -102,7 +102,7 @@ export async function up(knex: Knex): Promise<void> {
t.string("ip").notNullable();
});
await createOnUpdateTrigger(knex, TableName.Proxy);
await createOnUpdateTrigger(knex, TableName.Relay);
}
if (!(await knex.schema.hasTable(TableName.GatewayV2))) {
@@ -116,8 +116,8 @@ export async function up(knex: Knex): Promise<void> {
t.uuid("identityId").notNullable().unique();
t.foreign("identityId").references("id").inTable(TableName.Identity).onDelete("CASCADE");
t.uuid("proxyId");
t.foreign("proxyId").references("id").inTable(TableName.Proxy).onDelete("SET NULL");
t.uuid("relayId");
t.foreign("relayId").references("id").inTable(TableName.Relay).onDelete("SET NULL");
t.string("name").notNullable().unique();
@@ -129,11 +129,11 @@ export async function up(knex: Knex): Promise<void> {
}
export async function down(knex: Knex): Promise<void> {
await dropOnUpdateTrigger(knex, TableName.OrgProxyConfig);
await knex.schema.dropTableIfExists(TableName.OrgProxyConfig);
await dropOnUpdateTrigger(knex, TableName.OrgRelayConfig);
await knex.schema.dropTableIfExists(TableName.OrgRelayConfig);
await dropOnUpdateTrigger(knex, TableName.InstanceProxyConfig);
await knex.schema.dropTableIfExists(TableName.InstanceProxyConfig);
await dropOnUpdateTrigger(knex, TableName.InstanceRelayConfig);
await knex.schema.dropTableIfExists(TableName.InstanceRelayConfig);
await dropOnUpdateTrigger(knex, TableName.OrgGatewayConfigV2);
await knex.schema.dropTableIfExists(TableName.OrgGatewayConfigV2);
@@ -141,6 +141,6 @@ export async function down(knex: Knex): Promise<void> {
await dropOnUpdateTrigger(knex, TableName.GatewayV2);
await knex.schema.dropTableIfExists(TableName.GatewayV2);
await dropOnUpdateTrigger(knex, TableName.Proxy);
await knex.schema.dropTableIfExists(TableName.Proxy);
await dropOnUpdateTrigger(knex, TableName.Relay);
await knex.schema.dropTableIfExists(TableName.Relay);
}
+1 -1
View File
@@ -13,7 +13,7 @@ export const GatewaysV2Schema = z.object({
updatedAt: z.date(),
orgId: z.string().uuid(),
identityId: z.string().uuid(),
proxyId: z.string().uuid().nullable().optional(),
relayId: z.string().uuid().nullable().optional(),
name: z.string(),
heartbeat: z.date().nullable().optional()
});
+3 -3
View File
@@ -58,7 +58,7 @@ export * from "./identity-token-auths";
export * from "./identity-ua-client-secrets";
export * from "./identity-universal-auths";
export * from "./incident-contacts";
export * from "./instance-proxy-config";
export * from "./instance-relay-config";
export * from "./integration-auths";
export * from "./integrations";
export * from "./internal-certificate-authorities";
@@ -79,7 +79,7 @@ export * from "./org-bots";
export * from "./org-gateway-config";
export * from "./org-gateway-config-v2";
export * from "./org-memberships";
export * from "./org-proxy-config";
export * from "./org-relay-config";
export * from "./org-roles";
export * from "./organizations";
export * from "./pki-alerts";
@@ -99,8 +99,8 @@ export * from "./project-templates";
export * from "./project-user-additional-privilege";
export * from "./project-user-membership-roles";
export * from "./projects";
export * from "./proxies";
export * from "./rate-limit";
export * from "./relays";
export * from "./resource-metadata";
export * from "./saml-configs";
export * from "./scim-tokens";
@@ -1,38 +0,0 @@
// 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 InstanceProxyConfigSchema = z.object({
id: z.string().uuid(),
createdAt: z.date(),
updatedAt: z.date(),
encryptedRootProxyPkiCaPrivateKey: zodBuffer,
encryptedRootProxyPkiCaCertificate: zodBuffer,
encryptedInstanceProxyPkiCaPrivateKey: zodBuffer,
encryptedInstanceProxyPkiCaCertificate: zodBuffer,
encryptedInstanceProxyPkiCaCertificateChain: zodBuffer,
encryptedInstanceProxyPkiClientCaPrivateKey: zodBuffer,
encryptedInstanceProxyPkiClientCaCertificate: zodBuffer,
encryptedInstanceProxyPkiClientCaCertificateChain: zodBuffer,
encryptedInstanceProxyPkiServerCaPrivateKey: zodBuffer,
encryptedInstanceProxyPkiServerCaCertificate: zodBuffer,
encryptedInstanceProxyPkiServerCaCertificateChain: zodBuffer,
encryptedOrgProxyPkiCaPrivateKey: zodBuffer,
encryptedOrgProxyPkiCaCertificate: zodBuffer,
encryptedOrgProxyPkiCaCertificateChain: zodBuffer,
encryptedInstanceProxySshClientCaPrivateKey: zodBuffer,
encryptedInstanceProxySshClientCaPublicKey: zodBuffer,
encryptedInstanceProxySshServerCaPrivateKey: zodBuffer,
encryptedInstanceProxySshServerCaPublicKey: zodBuffer
});
export type TInstanceProxyConfig = z.infer<typeof InstanceProxyConfigSchema>;
export type TInstanceProxyConfigInsert = Omit<z.input<typeof InstanceProxyConfigSchema>, TImmutableDBKeys>;
export type TInstanceProxyConfigUpdate = Partial<Omit<z.input<typeof InstanceProxyConfigSchema>, TImmutableDBKeys>>;
@@ -0,0 +1,38 @@
// 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 InstanceRelayConfigSchema = z.object({
id: z.string().uuid(),
createdAt: z.date(),
updatedAt: z.date(),
encryptedRootRelayPkiCaPrivateKey: zodBuffer,
encryptedRootRelayPkiCaCertificate: zodBuffer,
encryptedInstanceRelayPkiCaPrivateKey: zodBuffer,
encryptedInstanceRelayPkiCaCertificate: zodBuffer,
encryptedInstanceRelayPkiCaCertificateChain: zodBuffer,
encryptedInstanceRelayPkiClientCaPrivateKey: zodBuffer,
encryptedInstanceRelayPkiClientCaCertificate: zodBuffer,
encryptedInstanceRelayPkiClientCaCertificateChain: zodBuffer,
encryptedInstanceRelayPkiServerCaPrivateKey: zodBuffer,
encryptedInstanceRelayPkiServerCaCertificate: zodBuffer,
encryptedInstanceRelayPkiServerCaCertificateChain: zodBuffer,
encryptedOrgRelayPkiCaPrivateKey: zodBuffer,
encryptedOrgRelayPkiCaCertificate: zodBuffer,
encryptedOrgRelayPkiCaCertificateChain: zodBuffer,
encryptedInstanceRelaySshClientCaPrivateKey: zodBuffer,
encryptedInstanceRelaySshClientCaPublicKey: zodBuffer,
encryptedInstanceRelaySshServerCaPrivateKey: zodBuffer,
encryptedInstanceRelaySshServerCaPublicKey: zodBuffer
});
export type TInstanceRelayConfig = z.infer<typeof InstanceRelayConfigSchema>;
export type TInstanceRelayConfigInsert = Omit<z.input<typeof InstanceRelayConfigSchema>, TImmutableDBKeys>;
export type TInstanceRelayConfigUpdate = Partial<Omit<z.input<typeof InstanceRelayConfigSchema>, TImmutableDBKeys>>;
+3 -3
View File
@@ -181,10 +181,10 @@ export enum TableName {
ReminderRecipient = "reminders_recipients",
// gateway v2
InstanceProxyConfig = "instance_proxy_config",
OrgProxyConfig = "org_proxy_config",
InstanceRelayConfig = "instance_relay_config",
OrgRelayConfig = "org_relay_config",
OrgGatewayConfigV2 = "org_gateway_config_v2",
Proxy = "proxies",
Relay = "relays",
GatewayV2 = "gateways_v2"
}
@@ -1,31 +0,0 @@
// 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 OrgProxyConfigSchema = z.object({
id: z.string().uuid(),
createdAt: z.date(),
updatedAt: z.date(),
orgId: z.string().uuid(),
encryptedProxyPkiClientCaPrivateKey: zodBuffer,
encryptedProxyPkiClientCaCertificate: zodBuffer,
encryptedProxyPkiClientCaCertificateChain: zodBuffer,
encryptedProxyPkiServerCaPrivateKey: zodBuffer,
encryptedProxyPkiServerCaCertificate: zodBuffer,
encryptedProxyPkiServerCaCertificateChain: zodBuffer,
encryptedProxySshClientCaPrivateKey: zodBuffer,
encryptedProxySshClientCaPublicKey: zodBuffer,
encryptedProxySshServerCaPrivateKey: zodBuffer,
encryptedProxySshServerCaPublicKey: zodBuffer
});
export type TOrgProxyConfig = z.infer<typeof OrgProxyConfigSchema>;
export type TOrgProxyConfigInsert = Omit<z.input<typeof OrgProxyConfigSchema>, TImmutableDBKeys>;
export type TOrgProxyConfigUpdate = Partial<Omit<z.input<typeof OrgProxyConfigSchema>, TImmutableDBKeys>>;
@@ -0,0 +1,31 @@
// 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 OrgRelayConfigSchema = z.object({
id: z.string().uuid(),
createdAt: z.date(),
updatedAt: z.date(),
orgId: z.string().uuid(),
encryptedRelayPkiClientCaPrivateKey: zodBuffer,
encryptedRelayPkiClientCaCertificate: zodBuffer,
encryptedRelayPkiClientCaCertificateChain: zodBuffer,
encryptedRelayPkiServerCaPrivateKey: zodBuffer,
encryptedRelayPkiServerCaCertificate: zodBuffer,
encryptedRelayPkiServerCaCertificateChain: zodBuffer,
encryptedRelaySshClientCaPrivateKey: zodBuffer,
encryptedRelaySshClientCaPublicKey: zodBuffer,
encryptedRelaySshServerCaPrivateKey: zodBuffer,
encryptedRelaySshServerCaPublicKey: zodBuffer
});
export type TOrgRelayConfig = z.infer<typeof OrgRelayConfigSchema>;
export type TOrgRelayConfigInsert = Omit<z.input<typeof OrgRelayConfigSchema>, TImmutableDBKeys>;
export type TOrgRelayConfigUpdate = Partial<Omit<z.input<typeof OrgRelayConfigSchema>, TImmutableDBKeys>>;
@@ -7,7 +7,7 @@ import { z } from "zod";
import { TImmutableDBKeys } from "./models";
export const ProxiesSchema = z.object({
export const RelaysSchema = z.object({
id: z.string().uuid(),
createdAt: z.date(),
updatedAt: z.date(),
@@ -17,6 +17,6 @@ export const ProxiesSchema = z.object({
ip: z.string()
});
export type TProxies = z.infer<typeof ProxiesSchema>;
export type TProxiesInsert = Omit<z.input<typeof ProxiesSchema>, TImmutableDBKeys>;
export type TProxiesUpdate = Partial<Omit<z.input<typeof ProxiesSchema>, TImmutableDBKeys>>;
export type TRelays = z.infer<typeof RelaysSchema>;
export type TRelaysInsert = Omit<z.input<typeof RelaysSchema>, TImmutableDBKeys>;
export type TRelaysUpdate = Partial<Omit<z.input<typeof RelaysSchema>, TImmutableDBKeys>>;