diff --git a/backend/src/@types/fastify.d.ts b/backend/src/@types/fastify.d.ts index 1cb11545c..85a19b676 100644 --- a/backend/src/@types/fastify.d.ts +++ b/backend/src/@types/fastify.d.ts @@ -13,6 +13,7 @@ import { TCertificateEstServiceFactory } from "@app/ee/services/certificate-est/ import { TDynamicSecretServiceFactory } from "@app/ee/services/dynamic-secret/dynamic-secret-service"; import { TDynamicSecretLeaseServiceFactory } from "@app/ee/services/dynamic-secret-lease/dynamic-secret-lease-service"; import { TExternalKmsServiceFactory } from "@app/ee/services/external-kms/external-kms-service"; +import { TGatewayServiceFactory } from "@app/ee/services/gateway/gateway-service"; import { TGroupServiceFactory } from "@app/ee/services/group/group-service"; import { TIdentityProjectAdditionalPrivilegeServiceFactory } from "@app/ee/services/identity-project-additional-privilege/identity-project-additional-privilege-service"; import { TIdentityProjectAdditionalPrivilegeV2ServiceFactory } from "@app/ee/services/identity-project-additional-privilege-v2/identity-project-additional-privilege-v2-service"; @@ -228,6 +229,7 @@ declare module "fastify" { secretSync: TSecretSyncServiceFactory; kmip: TKmipServiceFactory; kmipOperation: TKmipOperationServiceFactory; + gateway: TGatewayServiceFactory; }; // this is exclusive use for middlewares in which we need to inject data // everywhere else access using service layer diff --git a/backend/src/@types/knex.d.ts b/backend/src/@types/knex.d.ts index 27f6b894c..346b08e4c 100644 --- a/backend/src/@types/knex.d.ts +++ b/backend/src/@types/knex.d.ts @@ -68,6 +68,9 @@ import { TExternalKms, TExternalKmsInsert, TExternalKmsUpdate, + TGateways, + TGatewaysInsert, + TGatewaysUpdate, TGitAppInstallSessions, TGitAppInstallSessionsInsert, TGitAppInstallSessionsUpdate, @@ -179,6 +182,9 @@ import { TOrgBots, TOrgBotsInsert, TOrgBotsUpdate, + TOrgGatewayConfig, + TOrgGatewayConfigInsert, + TOrgGatewayConfigUpdate, TOrgMemberships, TOrgMembershipsInsert, TOrgMembershipsUpdate, @@ -200,6 +206,9 @@ import { TProjectEnvironments, TProjectEnvironmentsInsert, TProjectEnvironmentsUpdate, + TProjectGateways, + TProjectGatewaysInsert, + TProjectGatewaysUpdate, TProjectKeys, TProjectKeysInsert, TProjectKeysUpdate, @@ -930,5 +939,16 @@ declare module "knex/types/tables" { TKmipClientCertificatesInsert, TKmipClientCertificatesUpdate >; + [TableName.Gateway]: KnexOriginal.CompositeTableType; + [TableName.ProjectGateway]: KnexOriginal.CompositeTableType< + TProjectGateways, + TProjectGatewaysInsert, + TProjectGatewaysUpdate + >; + [TableName.OrgGatewayConfig]: KnexOriginal.CompositeTableType< + TOrgGatewayConfig, + TOrgGatewayConfigInsert, + TOrgGatewayConfigUpdate + >; } } diff --git a/backend/src/db/migrations/20250212191958_create-gateway.ts b/backend/src/db/migrations/20250212191958_create-gateway.ts new file mode 100644 index 000000000..7738da5cc --- /dev/null +++ b/backend/src/db/migrations/20250212191958_create-gateway.ts @@ -0,0 +1,115 @@ +import { Knex } from "knex"; + +import { TableName } from "../schemas"; +import { createOnUpdateTrigger, dropOnUpdateTrigger } from "../utils"; + +export async function up(knex: Knex): Promise { + if (!(await knex.schema.hasTable(TableName.OrgGatewayConfig))) { + await knex.schema.createTable(TableName.OrgGatewayConfig, (t) => { + t.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid()); + t.string("rootCaKeyAlgorithm").notNullable(); + + t.datetime("rootCaIssuedAt").notNullable(); + t.datetime("rootCaExpiration").notNullable(); + t.string("rootCaSerialNumber").notNullable(); + t.binary("encryptedRootCaCertificate").notNullable(); + t.binary("encryptedRootCaPrivateKey").notNullable(); + + t.datetime("clientCaIssuedAt").notNullable(); + t.datetime("clientCaExpiration").notNullable(); + t.string("clientCaSerialNumber"); + t.binary("encryptedClientCaCertificate").notNullable(); + t.binary("encryptedClientCaPrivateKey").notNullable(); + + t.string("clientCertSerialNumber").notNullable(); + t.string("clientCertKeyAlgorithm").notNullable(); + t.datetime("clientCertIssuedAt").notNullable(); + t.datetime("clientCertExpiration").notNullable(); + t.binary("encryptedClientCertificate").notNullable(); + t.binary("encryptedClientPrivateKey").notNullable(); + + t.datetime("gatewayCaIssuedAt").notNullable(); + t.datetime("gatewayCaExpiration").notNullable(); + t.string("gatewayCaSerialNumber").notNullable(); + t.binary("encryptedGatewayCaCertificate").notNullable(); + t.binary("encryptedGatewayCaPrivateKey").notNullable(); + + t.uuid("orgId").notNullable(); + t.foreign("orgId").references("id").inTable(TableName.Organization).onDelete("CASCADE"); + t.unique("orgId"); + t.timestamps(true, true, true); + }); + + await createOnUpdateTrigger(knex, TableName.OrgGatewayConfig); + } + + 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.datetime("heartbeat"); + + t.binary("relayAddress").notNullable(); + + t.uuid("orgGatewayRootCaId").notNullable(); + t.foreign("orgGatewayRootCaId").references("id").inTable(TableName.OrgGatewayConfig).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); + } + + if (!(await knex.schema.hasTable(TableName.ProjectGateway))) { + await knex.schema.createTable(TableName.ProjectGateway, (t) => { + t.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid()); + + t.string("projectId").notNullable(); + t.foreign("projectId").references("id").inTable(TableName.Project).onDelete("CASCADE"); + + t.uuid("gatewayId").notNullable(); + t.foreign("gatewayId").references("id").inTable(TableName.Gateway).onDelete("CASCADE"); + + t.timestamps(true, true, true); + }); + + await createOnUpdateTrigger(knex, TableName.ProjectGateway); + } + + if (await knex.schema.hasTable(TableName.DynamicSecret)) { + const doesGatewayColExist = await knex.schema.hasColumn(TableName.DynamicSecret, "gatewayId"); + await knex.schema.alterTable(TableName.DynamicSecret, (t) => { + // not setting a foreign constraint so that cascade effects are not triggered + if (!doesGatewayColExist) { + t.uuid("projectGatewayId"); + t.foreign("projectGatewayId").references("id").inTable(TableName.ProjectGateway); + } + }); + } +} + +export async function down(knex: Knex): Promise { + if (await knex.schema.hasTable(TableName.DynamicSecret)) { + const doesGatewayColExist = await knex.schema.hasColumn(TableName.DynamicSecret, "projectGatewayId"); + await knex.schema.alterTable(TableName.DynamicSecret, (t) => { + if (doesGatewayColExist) t.dropColumn("projectGatewayId"); + }); + } + + await knex.schema.dropTableIfExists(TableName.ProjectGateway); + await dropOnUpdateTrigger(knex, TableName.ProjectGateway); + + await knex.schema.dropTableIfExists(TableName.Gateway); + await dropOnUpdateTrigger(knex, TableName.Gateway); + + await knex.schema.dropTableIfExists(TableName.OrgGatewayConfig); + await dropOnUpdateTrigger(knex, TableName.OrgGatewayConfig); +} diff --git a/backend/src/db/schemas/dynamic-secrets.ts b/backend/src/db/schemas/dynamic-secrets.ts index eaddea8fe..913a6d475 100644 --- a/backend/src/db/schemas/dynamic-secrets.ts +++ b/backend/src/db/schemas/dynamic-secrets.ts @@ -26,7 +26,8 @@ export const DynamicSecretsSchema = z.object({ statusDetails: z.string().nullable().optional(), createdAt: z.date(), updatedAt: z.date(), - encryptedInput: zodBuffer + encryptedInput: zodBuffer, + projectGatewayId: z.string().uuid().nullable().optional() }); export type TDynamicSecrets = z.infer; diff --git a/backend/src/db/schemas/gateways.ts b/backend/src/db/schemas/gateways.ts new file mode 100644 index 000000000..30f5f25e0 --- /dev/null +++ b/backend/src/db/schemas/gateways.ts @@ -0,0 +1,29 @@ +// 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(), + heartbeat: z.date().nullable().optional(), + relayAddress: zodBuffer, + orgGatewayRootCaId: z.string().uuid(), + identityId: z.string().uuid(), + createdAt: z.date(), + updatedAt: z.date() +}); + +export type TGateways = z.infer; +export type TGatewaysInsert = Omit, TImmutableDBKeys>; +export type TGatewaysUpdate = Partial, TImmutableDBKeys>>; diff --git a/backend/src/db/schemas/index.ts b/backend/src/db/schemas/index.ts index 737193836..92fc47c23 100644 --- a/backend/src/db/schemas/index.ts +++ b/backend/src/db/schemas/index.ts @@ -20,6 +20,7 @@ export * from "./certificates"; export * from "./dynamic-secret-leases"; export * from "./dynamic-secrets"; export * from "./external-kms"; +export * from "./gateways"; export * from "./git-app-install-sessions"; export * from "./git-app-org"; export * from "./group-project-membership-roles"; @@ -57,6 +58,7 @@ export * from "./ldap-group-maps"; export * from "./models"; export * from "./oidc-configs"; export * from "./org-bots"; +export * from "./org-gateway-config"; export * from "./org-memberships"; export * from "./org-roles"; export * from "./organizations"; @@ -65,6 +67,7 @@ export * from "./pki-collection-items"; export * from "./pki-collections"; export * from "./project-bots"; export * from "./project-environments"; +export * from "./project-gateways"; export * from "./project-keys"; export * from "./project-memberships"; export * from "./project-roles"; diff --git a/backend/src/db/schemas/models.ts b/backend/src/db/schemas/models.ts index 3c5d1cad8..e626443c3 100644 --- a/backend/src/db/schemas/models.ts +++ b/backend/src/db/schemas/models.ts @@ -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 + OrgGatewayConfig = "org_gateway_config", + Gateway = "gateways", + ProjectGateway = "project_gateways", // junction tables with tags SecretV2JnTag = "secret_v2_tag_junction", JnSecretTag = "secret_tag_junction", diff --git a/backend/src/db/schemas/org-gateway-config.ts b/backend/src/db/schemas/org-gateway-config.ts new file mode 100644 index 000000000..ddf18c3fc --- /dev/null +++ b/backend/src/db/schemas/org-gateway-config.ts @@ -0,0 +1,43 @@ +// 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 OrgGatewayConfigSchema = z.object({ + id: z.string().uuid(), + rootCaKeyAlgorithm: z.string(), + rootCaIssuedAt: z.date(), + rootCaExpiration: z.date(), + rootCaSerialNumber: z.string(), + encryptedRootCaCertificate: zodBuffer, + encryptedRootCaPrivateKey: zodBuffer, + clientCaIssuedAt: z.date(), + clientCaExpiration: z.date(), + clientCaSerialNumber: z.string().nullable().optional(), + encryptedClientCaCertificate: zodBuffer, + encryptedClientCaPrivateKey: zodBuffer, + clientCertSerialNumber: z.string(), + clientCertKeyAlgorithm: z.string(), + clientCertIssuedAt: z.date(), + clientCertExpiration: z.date(), + encryptedClientCertificate: zodBuffer, + encryptedClientPrivateKey: zodBuffer, + gatewayCaIssuedAt: z.date(), + gatewayCaExpiration: z.date(), + gatewayCaSerialNumber: z.string(), + encryptedGatewayCaCertificate: zodBuffer, + encryptedGatewayCaPrivateKey: zodBuffer, + orgId: z.string().uuid(), + createdAt: z.date(), + updatedAt: z.date() +}); + +export type TOrgGatewayConfig = z.infer; +export type TOrgGatewayConfigInsert = Omit, TImmutableDBKeys>; +export type TOrgGatewayConfigUpdate = Partial, TImmutableDBKeys>>; diff --git a/backend/src/db/schemas/project-gateways.ts b/backend/src/db/schemas/project-gateways.ts new file mode 100644 index 000000000..f4b572661 --- /dev/null +++ b/backend/src/db/schemas/project-gateways.ts @@ -0,0 +1,20 @@ +// 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 { TImmutableDBKeys } from "./models"; + +export const ProjectGatewaysSchema = z.object({ + id: z.string().uuid(), + projectId: z.string(), + gatewayId: z.string().uuid(), + createdAt: z.date(), + updatedAt: z.date() +}); + +export type TProjectGateways = z.infer; +export type TProjectGatewaysInsert = Omit, TImmutableDBKeys>; +export type TProjectGatewaysUpdate = Partial, TImmutableDBKeys>>; diff --git a/backend/src/ee/routes/v1/gateway-router.ts b/backend/src/ee/routes/v1/gateway-router.ts new file mode 100644 index 000000000..c916e229e --- /dev/null +++ b/backend/src/ee/routes/v1/gateway-router.ts @@ -0,0 +1,265 @@ +import { z } from "zod"; + +import { GatewaysSchema } from "@app/db/schemas"; +import { isValidIp } from "@app/lib/ip"; +import { readLimit, writeLimit } from "@app/server/config/rateLimiter"; +import { slugSchema } from "@app/server/lib/schemas"; +import { verifyAuth } from "@app/server/plugins/auth/verify-auth"; +import { AuthMode } from "@app/services/auth/auth-type"; + +const SanitizedGatewaySchema = GatewaysSchema.pick({ + id: true, + identityId: true, + name: true, + createdAt: true, + updatedAt: true, + issuedAt: true, + serialNumber: true, + heartbeat: true +}); + +const isValidRelayAddress = (relayAddress: string) => { + const [ip, port] = relayAddress.split(":"); + return isValidIp(ip) && Number(port) <= 65535 && Number(port) >= 40000; +}; + +export const registerGatewayRouter = async (server: FastifyZodProvider) => { + server.route({ + method: "POST", + url: "/register-identity", + config: { + rateLimit: writeLimit + }, + schema: { + response: { + 200: z.object({ + turnServerUsername: z.string(), + turnServerPassword: z.string(), + turnServerRealm: z.string(), + turnServerAddress: z.string(), + infisicalStaticIp: z.string().optional() + }) + } + }, + onRequest: verifyAuth([AuthMode.IDENTITY_ACCESS_TOKEN]), + handler: async (req) => { + const relayDetails = await server.services.gateway.getGatewayRelayDetails( + req.permission.id, + req.permission.orgId, + req.permission.authMethod + ); + return relayDetails; + } + }); + + server.route({ + method: "POST", + url: "/exchange-cert", + config: { + rateLimit: writeLimit + }, + schema: { + body: z.object({ + relayAddress: z.string().refine(isValidRelayAddress, { message: "Invalid relay address" }) + }), + response: { + 200: z.object({ + serialNumber: z.string(), + privateKey: z.string(), + certificate: z.string(), + certificateChain: z.string() + }) + } + }, + onRequest: verifyAuth([AuthMode.IDENTITY_ACCESS_TOKEN]), + handler: async (req) => { + const gatewayCertificates = await server.services.gateway.exchangeAllocatedRelayAddress({ + identityOrg: req.permission.orgId, + identityId: req.permission.id, + relayAddress: req.body.relayAddress, + identityOrgAuthMethod: req.permission.authMethod + }); + return gatewayCertificates; + } + }); + + server.route({ + method: "POST", + url: "/heartbeat", + config: { + rateLimit: writeLimit + }, + schema: { + response: { + 200: z.object({ + message: z.string() + }) + } + }, + onRequest: verifyAuth([AuthMode.IDENTITY_ACCESS_TOKEN]), + handler: async (req) => { + await server.services.gateway.heartbeat({ + orgPermission: req.permission + }); + return { message: "Successfully registered heartbeat" }; + } + }); + + server.route({ + method: "GET", + url: "/", + config: { + rateLimit: readLimit + }, + schema: { + querystring: z.object({ + projectId: z.string().optional() + }), + response: { + 200: z.object({ + gateways: SanitizedGatewaySchema.extend({ + identity: z.object({ + name: z.string(), + id: z.string() + }), + projects: z + .object({ + name: z.string(), + id: z.string(), + slug: z.string() + }) + .array() + }).array() + }) + } + }, + onRequest: verifyAuth([AuthMode.IDENTITY_ACCESS_TOKEN, AuthMode.JWT]), + handler: async (req) => { + const gateways = await server.services.gateway.listGateways({ + orgPermission: req.permission + }); + return { gateways }; + } + }); + + server.route({ + method: "GET", + url: "/projects/:projectId", + config: { + rateLimit: readLimit + }, + schema: { + params: z.object({ + projectId: z.string() + }), + response: { + 200: z.object({ + gateways: SanitizedGatewaySchema.extend({ + identity: z.object({ + name: z.string(), + id: z.string() + }), + projectGatewayId: z.string() + }).array() + }) + } + }, + onRequest: verifyAuth([AuthMode.IDENTITY_ACCESS_TOKEN, AuthMode.JWT]), + handler: async (req) => { + const gateways = await server.services.gateway.getProjectGateways({ + projectId: req.params.projectId, + projectPermission: req.permission + }); + return { gateways }; + } + }); + + server.route({ + method: "GET", + url: "/:id", + config: { + rateLimit: readLimit + }, + schema: { + params: z.object({ + id: z.string() + }), + response: { + 200: z.object({ + gateway: SanitizedGatewaySchema.extend({ + identity: z.object({ + name: z.string(), + id: z.string() + }) + }) + }) + } + }, + onRequest: verifyAuth([AuthMode.IDENTITY_ACCESS_TOKEN, AuthMode.JWT]), + handler: async (req) => { + const gateway = await server.services.gateway.getGatewayById({ + orgPermission: req.permission, + id: req.params.id + }); + return { gateway }; + } + }); + + server.route({ + method: "PATCH", + url: "/:id", + config: { + rateLimit: writeLimit + }, + schema: { + params: z.object({ + id: z.string() + }), + body: z.object({ + name: slugSchema({ field: "name" }).optional(), + projectIds: z.string().array().optional() + }), + response: { + 200: z.object({ + gateway: SanitizedGatewaySchema + }) + } + }, + onRequest: verifyAuth([AuthMode.IDENTITY_ACCESS_TOKEN, AuthMode.JWT]), + handler: async (req) => { + const gateway = await server.services.gateway.updateGatewayById({ + orgPermission: req.permission, + id: req.params.id, + name: req.body.name, + projectIds: req.body.projectIds + }); + return { gateway }; + } + }); + + server.route({ + method: "DELETE", + url: "/:id", + config: { + rateLimit: writeLimit + }, + schema: { + params: z.object({ + id: z.string() + }), + response: { + 200: z.object({ + gateway: SanitizedGatewaySchema + }) + } + }, + onRequest: verifyAuth([AuthMode.IDENTITY_ACCESS_TOKEN, AuthMode.JWT]), + handler: async (req) => { + const gateway = await server.services.gateway.deleteGatewayById({ + orgPermission: req.permission, + id: req.params.id + }); + return { gateway }; + } + }); +}; diff --git a/backend/src/ee/routes/v1/index.ts b/backend/src/ee/routes/v1/index.ts index 0567c76ef..e793c687d 100644 --- a/backend/src/ee/routes/v1/index.ts +++ b/backend/src/ee/routes/v1/index.ts @@ -7,6 +7,7 @@ import { registerCaCrlRouter } from "./certificate-authority-crl-router"; import { registerDynamicSecretLeaseRouter } from "./dynamic-secret-lease-router"; import { registerDynamicSecretRouter } from "./dynamic-secret-router"; import { registerExternalKmsRouter } from "./external-kms-router"; +import { registerGatewayRouter } from "./gateway-router"; import { registerGroupRouter } from "./group-router"; import { registerIdentityProjectAdditionalPrivilegeRouter } from "./identity-project-additional-privilege-router"; import { registerKmipRouter } from "./kmip-router"; @@ -67,6 +68,8 @@ export const registerV1EERoutes = async (server: FastifyZodProvider) => { { prefix: "/dynamic-secrets" } ); + await server.register(registerGatewayRouter, { prefix: "/gateways" }); + await server.register( async (pkiRouter) => { await pkiRouter.register(registerCaCrlRouter, { prefix: "/crl" }); diff --git a/backend/src/ee/services/dynamic-secret/dynamic-secret-fns.ts b/backend/src/ee/services/dynamic-secret/dynamic-secret-fns.ts index 04aeb3950..ac6a66d3b 100644 --- a/backend/src/ee/services/dynamic-secret/dynamic-secret-fns.ts +++ b/backend/src/ee/services/dynamic-secret/dynamic-secret-fns.ts @@ -1,20 +1,31 @@ +import crypto from "node:crypto"; + import { getConfig } from "@app/lib/config/env"; import { BadRequestError } from "@app/lib/errors"; import { getDbConnectionHost } from "@app/lib/knex"; -export const verifyHostInputValidity = (host: string) => { +export const verifyHostInputValidity = (host: string, isGateway = false) => { const appCfg = getConfig(); const dbHost = appCfg.DB_HOST || getDbConnectionHost(appCfg.DB_CONNECTION_URI); + // no need for validation when it's dev + if (appCfg.NODE_ENV === "development") return; + + if (host === "host.docker.internal") throw new BadRequestError({ message: "Invalid db host" }); if ( appCfg.isCloud && + !isGateway && // localhost // internal ips - (host === "host.docker.internal" || host.match(/^10\.\d+\.\d+\.\d+/) || host.match(/^192\.168\.\d+\.\d+/)) + (host.match(/^10\.\d+\.\d+\.\d+/) || host.match(/^192\.168\.\d+\.\d+/)) ) throw new BadRequestError({ message: "Invalid db host" }); - if (host === "localhost" || host === "127.0.0.1" || dbHost === host) { + if ( + host === "localhost" || + host === "127.0.0.1" || + crypto.timingSafeEqual(Buffer.from(dbHost || ""), Buffer.from(host)) + ) { throw new BadRequestError({ message: "Invalid db host" }); } }; diff --git a/backend/src/ee/services/dynamic-secret/dynamic-secret-service.ts b/backend/src/ee/services/dynamic-secret/dynamic-secret-service.ts index eac5e2ecf..25ea21024 100644 --- a/backend/src/ee/services/dynamic-secret/dynamic-secret-service.ts +++ b/backend/src/ee/services/dynamic-secret/dynamic-secret-service.ts @@ -16,6 +16,7 @@ import { TSecretFolderDALFactory } from "@app/services/secret-folder/secret-fold import { TDynamicSecretLeaseDALFactory } from "../dynamic-secret-lease/dynamic-secret-lease-dal"; import { TDynamicSecretLeaseQueueServiceFactory } from "../dynamic-secret-lease/dynamic-secret-lease-queue"; +import { TProjectGatewayDALFactory } from "../gateway/project-gateway-dal"; import { TDynamicSecretDALFactory } from "./dynamic-secret-dal"; import { DynamicSecretStatus, @@ -44,6 +45,7 @@ type TDynamicSecretServiceFactoryDep = { projectDAL: Pick; permissionService: Pick; kmsService: Pick; + projectGatewayDAL: Pick; }; export type TDynamicSecretServiceFactory = ReturnType; @@ -57,7 +59,8 @@ export const dynamicSecretServiceFactory = ({ permissionService, dynamicSecretQueueService, projectDAL, - kmsService + kmsService, + projectGatewayDAL }: TDynamicSecretServiceFactoryDep) => { const create = async ({ path, @@ -108,6 +111,18 @@ export const dynamicSecretServiceFactory = ({ const selectedProvider = dynamicSecretProviders[provider.type]; const inputs = await selectedProvider.validateProviderInputs(provider.inputs); + let selectedGatewayId: string | null = null; + if (inputs && typeof inputs === "object" && "projectGatewayId" in inputs && inputs.projectGatewayId) { + const projectGatewayId = inputs.projectGatewayId as string; + + const projectGateway = await projectGatewayDAL.findOne({ id: projectGatewayId, projectId }); + if (!projectGateway) + throw new NotFoundError({ + message: `Project gateway with ${projectGatewayId} not found` + }); + selectedGatewayId = projectGateway.id; + } + const isConnected = await selectedProvider.validateConnection(provider.inputs); if (!isConnected) throw new BadRequestError({ message: "Provider connection failed" }); @@ -123,7 +138,8 @@ export const dynamicSecretServiceFactory = ({ maxTTL, defaultTTL, folderId: folder.id, - name + name, + projectGatewayId: selectedGatewayId }); return dynamicSecretCfg; }; @@ -195,6 +211,23 @@ export const dynamicSecretServiceFactory = ({ const newInput = { ...decryptedStoredInput, ...(inputs || {}) }; const updatedInput = await selectedProvider.validateProviderInputs(newInput); + let selectedGatewayId: string | null = null; + if ( + updatedInput && + typeof updatedInput === "object" && + "projectGatewayId" in updatedInput && + updatedInput?.projectGatewayId + ) { + const projectGatewayId = updatedInput.projectGatewayId as string; + + const projectGateway = await projectGatewayDAL.findOne({ id: projectGatewayId, projectId }); + if (!projectGateway) + throw new NotFoundError({ + message: `Project gateway with ${projectGatewayId} not found` + }); + selectedGatewayId = projectGateway.id; + } + const isConnected = await selectedProvider.validateConnection(newInput); if (!isConnected) throw new BadRequestError({ message: "Provider connection failed" }); @@ -204,7 +237,8 @@ export const dynamicSecretServiceFactory = ({ defaultTTL, name: newName ?? name, status: null, - statusDetails: null + statusDetails: null, + projectGatewayId: selectedGatewayId }); return updatedDynamicCfg; diff --git a/backend/src/ee/services/dynamic-secret/providers/index.ts b/backend/src/ee/services/dynamic-secret/providers/index.ts index 9ed757a37..faa671980 100644 --- a/backend/src/ee/services/dynamic-secret/providers/index.ts +++ b/backend/src/ee/services/dynamic-secret/providers/index.ts @@ -1,5 +1,6 @@ import { SnowflakeProvider } from "@app/ee/services/dynamic-secret/providers/snowflake"; +import { TGatewayServiceFactory } from "../../gateway/gateway-service"; import { AwsElastiCacheDatabaseProvider } from "./aws-elasticache"; import { AwsIamProvider } from "./aws-iam"; import { AzureEntraIDProvider } from "./azure-entra-id"; @@ -16,8 +17,14 @@ import { SapHanaProvider } from "./sap-hana"; import { SqlDatabaseProvider } from "./sql-database"; import { TotpProvider } from "./totp"; -export const buildDynamicSecretProviders = (): Record => ({ - [DynamicSecretProviders.SqlDatabase]: SqlDatabaseProvider(), +type TBuildDynamicSecretProviderDTO = { + gatewayService: Pick; +}; + +export const buildDynamicSecretProviders = ({ + gatewayService +}: TBuildDynamicSecretProviderDTO): Record => ({ + [DynamicSecretProviders.SqlDatabase]: SqlDatabaseProvider({ gatewayService }), [DynamicSecretProviders.Cassandra]: CassandraProvider(), [DynamicSecretProviders.AwsIam]: AwsIamProvider(), [DynamicSecretProviders.Redis]: RedisDatabaseProvider(), diff --git a/backend/src/ee/services/dynamic-secret/providers/models.ts b/backend/src/ee/services/dynamic-secret/providers/models.ts index e8b9e6548..621c3c631 100644 --- a/backend/src/ee/services/dynamic-secret/providers/models.ts +++ b/backend/src/ee/services/dynamic-secret/providers/models.ts @@ -103,7 +103,8 @@ export const DynamicSecretSqlDBSchema = z.object({ creationStatement: z.string().trim(), revocationStatement: z.string().trim(), renewStatement: z.string().trim().optional(), - ca: z.string().optional() + ca: z.string().optional(), + projectGatewayId: z.string().nullable().optional() }); export const DynamicSecretCassandraSchema = z.object({ diff --git a/backend/src/ee/services/dynamic-secret/providers/sql-database.ts b/backend/src/ee/services/dynamic-secret/providers/sql-database.ts index a9bfad525..32bac4e6a 100644 --- a/backend/src/ee/services/dynamic-secret/providers/sql-database.ts +++ b/backend/src/ee/services/dynamic-secret/providers/sql-database.ts @@ -3,8 +3,10 @@ import knex from "knex"; import { customAlphabet } from "nanoid"; import { z } from "zod"; +import { withGatewayProxy } from "@app/lib/gateway"; import { alphaNumericNanoId } from "@app/lib/nanoid"; +import { TGatewayServiceFactory } from "../../gateway/gateway-service"; import { verifyHostInputValidity } from "../dynamic-secret-fns"; import { DynamicSecretSqlDBSchema, SqlProviders, TDynamicProviderFns } from "./models"; @@ -25,10 +27,14 @@ const generateUsername = (provider: SqlProviders) => { return alphaNumericNanoId(32); }; -export const SqlDatabaseProvider = (): TDynamicProviderFns => { +type TSqlDatabaseProviderDTO = { + gatewayService: Pick; +}; + +export const SqlDatabaseProvider = ({ gatewayService }: TSqlDatabaseProviderDTO): TDynamicProviderFns => { const validateProviderInputs = async (inputs: unknown) => { const providerInputs = await DynamicSecretSqlDBSchema.parseAsync(inputs); - verifyHostInputValidity(providerInputs.host); + verifyHostInputValidity(providerInputs.host, Boolean(providerInputs.projectGatewayId)); return providerInputs; }; @@ -61,61 +67,109 @@ export const SqlDatabaseProvider = (): TDynamicProviderFns => { return db; }; + const gatewayProxyWrapper = async ( + providerInputs: z.infer, + gatewayCallback: (host: string, port: number) => Promise + ) => { + const relayDetails = await gatewayService.fnGetGatewayClientTls(providerInputs.projectGatewayId as string); + const [relayHost, relayPort] = relayDetails.relayAddress.split(":"); + await withGatewayProxy( + async (port) => { + await gatewayCallback("localhost", port); + }, + { + targetHost: providerInputs.host, + targetPort: providerInputs.port, + relayHost, + relayPort: Number(relayPort), + identityId: relayDetails.identityId, + orgId: relayDetails.orgId, + tlsOptions: { + ca: relayDetails.certChain, + cert: relayDetails.certificate, + key: relayDetails.privateKey + } + } + ); + }; + const validateConnection = async (inputs: unknown) => { const providerInputs = await validateProviderInputs(inputs); - const db = await $getClient(providerInputs); - // oracle needs from keyword - const testStatement = providerInputs.client === SqlProviders.Oracle ? "SELECT 1 FROM DUAL" : "SELECT 1"; + let isConnected = false; + const gatewayCallback = async (host = providerInputs.host, port = providerInputs.port) => { + const db = await $getClient({ ...providerInputs, port, host }); + // oracle needs from keyword + const testStatement = providerInputs.client === SqlProviders.Oracle ? "SELECT 1 FROM DUAL" : "SELECT 1"; - const isConnected = await db.raw(testStatement).then(() => true); - await db.destroy(); + isConnected = await db.raw(testStatement).then(() => true); + await db.destroy(); + }; + + if (providerInputs.projectGatewayId) { + console.log(">>>>>> inside gateway"); + await gatewayProxyWrapper(providerInputs, gatewayCallback); + } else { + console.log(">>>>>> outside gateway"); + await gatewayCallback(); + } return isConnected; }; const create = async (inputs: unknown, expireAt: number) => { const providerInputs = await validateProviderInputs(inputs); - const db = await $getClient(providerInputs); - const username = generateUsername(providerInputs.client); const password = generatePassword(providerInputs.client); - const { database } = providerInputs; - const expiration = new Date(expireAt).toISOString(); + const gatewayCallback = async (host = providerInputs.host, port = providerInputs.port) => { + const db = await $getClient({ ...providerInputs, port, host }); + const { database } = providerInputs; + const expiration = new Date(expireAt).toISOString(); - const creationStatement = handlebars.compile(providerInputs.creationStatement, { noEscape: true })({ - username, - password, - expiration, - database - }); + const creationStatement = handlebars.compile(providerInputs.creationStatement, { noEscape: true })({ + username, + password, + expiration, + database + }); - const queries = creationStatement.toString().split(";").filter(Boolean); - await db.transaction(async (tx) => { - for (const query of queries) { - // eslint-disable-next-line - await tx.raw(query); - } - }); - await db.destroy(); + const queries = creationStatement.toString().split(";").filter(Boolean); + await db.transaction(async (tx) => { + for (const query of queries) { + // eslint-disable-next-line + await tx.raw(query); + } + }); + await db.destroy(); + }; + if (providerInputs.projectGatewayId) { + await gatewayProxyWrapper(providerInputs, gatewayCallback); + } else { + await gatewayCallback(); + } return { entityId: username, data: { DB_USERNAME: username, DB_PASSWORD: password } }; }; const revoke = async (inputs: unknown, entityId: string) => { const providerInputs = await validateProviderInputs(inputs); - const db = await $getClient(providerInputs); - const username = entityId; const { database } = providerInputs; + const gatewayCallback = async (host = providerInputs.host, port = providerInputs.port) => { + const db = await $getClient({ ...providerInputs, port, host }); + const revokeStatement = handlebars.compile(providerInputs.revocationStatement)({ username, database }); + const queries = revokeStatement.toString().split(";").filter(Boolean); + await db.transaction(async (tx) => { + for (const query of queries) { + // eslint-disable-next-line + await tx.raw(query); + } + }); - const revokeStatement = handlebars.compile(providerInputs.revocationStatement)({ username, database }); - const queries = revokeStatement.toString().split(";").filter(Boolean); - await db.transaction(async (tx) => { - for (const query of queries) { - // eslint-disable-next-line - await tx.raw(query); - } - }); - - await db.destroy(); + await db.destroy(); + }; + if (providerInputs.projectGatewayId) { + await gatewayProxyWrapper(providerInputs, gatewayCallback); + } else { + await gatewayCallback(); + } return { entityId: username }; }; @@ -123,28 +177,34 @@ export const SqlDatabaseProvider = (): TDynamicProviderFns => { const providerInputs = await validateProviderInputs(inputs); if (!providerInputs.renewStatement) return { entityId }; - const db = await $getClient(providerInputs); + const gatewayCallback = async (host = providerInputs.host, port = providerInputs.port) => { + const db = await $getClient({ ...providerInputs, port, host }); + const expiration = new Date(expireAt).toISOString(); + const { database } = providerInputs; - const expiration = new Date(expireAt).toISOString(); - const { database } = providerInputs; - - const renewStatement = handlebars.compile(providerInputs.renewStatement)({ - username: entityId, - expiration, - database - }); - - if (renewStatement) { - const queries = renewStatement.toString().split(";").filter(Boolean); - await db.transaction(async (tx) => { - for (const query of queries) { - // eslint-disable-next-line - await tx.raw(query); - } + const renewStatement = handlebars.compile(providerInputs.renewStatement)({ + username: entityId, + expiration, + database }); - } - await db.destroy(); + if (renewStatement) { + const queries = renewStatement.toString().split(";").filter(Boolean); + await db.transaction(async (tx) => { + for (const query of queries) { + // eslint-disable-next-line + await tx.raw(query); + } + }); + } + + await db.destroy(); + }; + if (providerInputs.projectGatewayId) { + await gatewayProxyWrapper(providerInputs, gatewayCallback); + } else { + await gatewayCallback(); + } return { entityId }; }; diff --git a/backend/src/ee/services/gateway/gateway-dal.ts b/backend/src/ee/services/gateway/gateway-dal.ts new file mode 100644 index 000000000..fbf5558e4 --- /dev/null +++ b/backend/src/ee/services/gateway/gateway-dal.ts @@ -0,0 +1,86 @@ +import { Knex } from "knex"; + +import { TDbClient } from "@app/db"; +import { GatewaysSchema, TableName, TGateways } from "@app/db/schemas"; +import { DatabaseError } from "@app/lib/errors"; +import { + buildFindFilter, + ormify, + selectAllTableCols, + sqlNestRelationships, + TFindFilter, + TFindOpt +} from "@app/lib/knex"; + +export type TGatewayDALFactory = ReturnType; + +export const gatewayDALFactory = (db: TDbClient) => { + const orm = ormify(db, TableName.Gateway); + + const find = async (filter: TFindFilter, { offset, limit, sort, tx }: TFindOpt = {}) => { + try { + const query = (tx || db)(TableName.Gateway) + // eslint-disable-next-line @typescript-eslint/no-misused-promises + .where(buildFindFilter(filter)) + .join(TableName.Identity, `${TableName.Identity}.id`, `${TableName.Gateway}.identityId`) + .leftJoin(TableName.ProjectGateway, `${TableName.ProjectGateway}.gatewayId`, `${TableName.Gateway}.id`) + .leftJoin(TableName.Project, `${TableName.Project}.id`, `${TableName.ProjectGateway}.projectId`) + .select(selectAllTableCols(TableName.Gateway)) + .select( + db.ref("name").withSchema(TableName.Identity).as("identityName"), + db.ref("name").withSchema(TableName.Project).as("projectName"), + db.ref("slug").withSchema(TableName.Project).as("projectSlug"), + db.ref("id").withSchema(TableName.Project).as("projectId") + ); + if (limit) void query.limit(limit); + if (offset) void query.offset(offset); + if (sort) { + void query.orderBy(sort.map(([column, order, nulls]) => ({ column: column as string, order, nulls }))); + } + + const docs = await query; + return sqlNestRelationships({ + data: docs, + key: "id", + parentMapper: (data) => ({ + ...GatewaysSchema.parse(data), + identity: { id: data.identityId, name: data.identityName } + }), + childrenMapper: [ + { + key: "projectId", + label: "projects" as const, + mapper: ({ projectId, projectName, projectSlug }) => ({ + id: projectId, + name: projectName, + slug: projectSlug + }) + } + ] + }); + } catch (error) { + throw new DatabaseError({ error, name: `${TableName.Gateway}: Find` }); + } + }; + + const findByProjectId = async (projectId: string, tx?: Knex) => { + try { + const query = (tx || db)(TableName.Gateway) + .join(TableName.Identity, `${TableName.Identity}.id`, `${TableName.Gateway}.identityId`) + .join(TableName.ProjectGateway, `${TableName.ProjectGateway}.gatewayId`, `${TableName.Gateway}.id`) + .select(selectAllTableCols(TableName.Gateway)) + .select( + db.ref("name").withSchema(TableName.Identity).as("identityName"), + db.ref("id").withSchema(TableName.ProjectGateway).as("projectGatewayId") + ) + .where({ [`${TableName.ProjectGateway}.projectId` as "projectId"]: projectId }); + + const docs = await query; + return docs.map((el) => ({ ...el, identity: { id: el.identityId, name: el.identityName } })); + } catch (error) { + throw new DatabaseError({ error, name: `${TableName.Gateway}: Find by project id` }); + } + }; + + return { ...orm, find, findByProjectId }; +}; diff --git a/backend/src/ee/services/gateway/gateway-service.ts b/backend/src/ee/services/gateway/gateway-service.ts new file mode 100644 index 000000000..fdfaa8ab1 --- /dev/null +++ b/backend/src/ee/services/gateway/gateway-service.ts @@ -0,0 +1,652 @@ +import crypto from "node:crypto"; + +import { ForbiddenError } from "@casl/ability"; +import * as x509 from "@peculiar/x509"; +import { z } from "zod"; + +import { ActionProjectType } from "@app/db/schemas"; +import { KeyStorePrefixes, PgSqlLock, TKeyStoreFactory } from "@app/keystore/keystore"; +import { getConfig } from "@app/lib/config/env"; +import { BadRequestError, NotFoundError } from "@app/lib/errors"; +import { pingGatewayAndVerify } from "@app/lib/gateway"; +import { alphaNumericNanoId } from "@app/lib/nanoid"; +import { getTurnCredentials } from "@app/lib/turn/credentials"; +import { ActorAuthMethod, ActorType } from "@app/services/auth/auth-type"; +import { CertExtendedKeyUsage, CertKeyAlgorithm, CertKeyUsage } from "@app/services/certificate/certificate-types"; +import { + createSerialNumber, + keyAlgorithmToAlgCfg +} from "@app/services/certificate-authority/certificate-authority-fns"; +import { TKmsServiceFactory } from "@app/services/kms/kms-service"; +import { KmsDataKey } from "@app/services/kms/kms-types"; + +import { TLicenseServiceFactory } from "../license/license-service"; +import { OrgPermissionGatewayActions, OrgPermissionSubjects } from "../permission/org-permission"; +import { TPermissionServiceFactory } from "../permission/permission-service"; +import { TGatewayDALFactory } from "./gateway-dal"; +import { + TExchangeAllocatedRelayAddressDTO, + TGetGatewayByIdDTO, + TGetProjectGatewayByIdDTO, + THeartBeatDTO, + TListGatewaysDTO, + TUpdateGatewayByIdDTO +} from "./gateway-types"; +import { TOrgGatewayConfigDALFactory } from "./org-gateway-config-dal"; +import { TProjectGatewayDALFactory } from "./project-gateway-dal"; + +type TGatewayServiceFactoryDep = { + gatewayDAL: TGatewayDALFactory; + projectGatewayDAL: TProjectGatewayDALFactory; + orgGatewayConfigDAL: Pick; + licenseService: Pick; + kmsService: Pick; + permissionService: Pick; + keyStore: Pick; +}; + +export type TGatewayServiceFactory = ReturnType; +const TURN_SERVER_CREDENTIALS_SCHEMA = z.object({ + username: z.string(), + password: z.string() +}); + +export const gatewayServiceFactory = ({ + gatewayDAL, + licenseService, + kmsService, + permissionService, + orgGatewayConfigDAL, + keyStore, + projectGatewayDAL +}: TGatewayServiceFactoryDep) => { + const $validateOrgAccessToGateway = async (orgId: string, actorId: string, actorAuthMethod: ActorAuthMethod) => { + if (!licenseService.onPremFeatures.gateway) { + throw new BadRequestError({ + message: + "Gateway handshake failed due to instance plan restrictions. Please upgrade your instance to Infisical's Enterprise plan." + }); + } + const orgLicensePlan = await licenseService.getPlan(orgId); + if (!orgLicensePlan.gateway) { + throw new BadRequestError({ + message: + "Gateway handshake failed due to organization plan restrictions. Please upgrade your instance to Infisical's Enterprise plan." + }); + } + const { permission } = await permissionService.getOrgPermission( + ActorType.IDENTITY, + actorId, + orgId, + actorAuthMethod, + orgId + ); + ForbiddenError.from(permission).throwUnlessCan( + OrgPermissionGatewayActions.CreateGateways, + OrgPermissionSubjects.Gateway + ); + }; + + const getGatewayRelayDetails = async (actorId: string, actorOrgId: string, actorAuthMethod: ActorAuthMethod) => { + const TURN_CRED_EXPIRY = 10 * 60; // 10 minutes + + const envCfg = getConfig(); + await $validateOrgAccessToGateway(actorOrgId, actorId, actorAuthMethod); + const { encryptor, decryptor } = await kmsService.createCipherPairWithDataKey({ + type: KmsDataKey.Organization, + orgId: actorOrgId + }); + + if (!envCfg.GATEWAY_RELAY_AUTH_SECRET || !envCfg.GATEWAY_RELAY_ADDRESS || !envCfg.GATEWAY_RELAY_REALM) { + throw new BadRequestError({ + message: "Gateway handshake failed due to missing instance configuration." + }); + } + + let turnServerUsername = ""; + let turnServerPassword = ""; + // keep it in redis for 5mins to avoid generating so many credentials + const previousCredential = await keyStore.getItem(KeyStorePrefixes.GatewayIdentityCredential(actorId)); + if (previousCredential) { + const el = await TURN_SERVER_CREDENTIALS_SCHEMA.parseAsync( + JSON.parse(decryptor({ cipherTextBlob: Buffer.from(previousCredential, "hex") }).toString()) + ); + turnServerUsername = el.username; + turnServerPassword = el.password; + } else { + const el = getTurnCredentials(actorId, envCfg.GATEWAY_RELAY_AUTH_SECRET); + await keyStore.setItemWithExpiry( + KeyStorePrefixes.GatewayIdentityCredential(actorId), + TURN_CRED_EXPIRY, + encryptor({ + plainText: Buffer.from(JSON.stringify({ username: el.username, password: el.password })) + }).cipherTextBlob.toString("hex") + ); + turnServerUsername = el.username; + turnServerPassword = el.password; + } + + return { + turnServerUsername, + turnServerPassword, + turnServerRealm: envCfg.GATEWAY_RELAY_REALM, + turnServerAddress: envCfg.GATEWAY_RELAY_ADDRESS, + infisicalStaticIp: envCfg.GATEWAY_INFISICAL_STATIC_IP_ADDRESS + }; + }; + + const exchangeAllocatedRelayAddress = async ({ + identityId, + identityOrg, + relayAddress, + identityOrgAuthMethod + }: TExchangeAllocatedRelayAddressDTO) => { + await $validateOrgAccessToGateway(identityOrg, identityId, identityOrgAuthMethod); + const { encryptor: orgKmsEncryptor, decryptor: orgKmsDecryptor } = await kmsService.createCipherPairWithDataKey({ + type: KmsDataKey.Organization, + orgId: identityOrg + }); + + const orgGatewayConfig = await orgGatewayConfigDAL.transaction(async (tx) => { + await tx.raw("SELECT pg_advisory_xact_lock(?)", [PgSqlLock.OrgGatewayRootCaInit(identityOrg)]); + const existingGatewayConfig = await orgGatewayConfigDAL.findOne({ orgId: identityOrg }); + if (existingGatewayConfig) return existingGatewayConfig; + + const alg = keyAlgorithmToAlgCfg(CertKeyAlgorithm.RSA_2048); + // generate root CA + const rootCaKeys = await crypto.subtle.generateKey(alg, true, ["sign", "verify"]); + const rootCaSerialNumber = createSerialNumber(); + const rootCaSkObj = crypto.KeyObject.from(rootCaKeys.privateKey); + const rootCaIssuedAt = new Date(); + const rootCaKeyAlgorithm = CertKeyAlgorithm.RSA_2048; + const rootCaExpiration = new Date(new Date().setFullYear(2045)); + const rootCaCert = await x509.X509CertificateGenerator.createSelfSigned({ + name: `O=${identityOrg},CN=Infisical Gateway Root CA`, + serialNumber: rootCaSerialNumber, + notBefore: rootCaIssuedAt, + notAfter: rootCaExpiration, + signingAlgorithm: alg, + keys: rootCaKeys, + extensions: [ + // eslint-disable-next-line no-bitwise + new x509.KeyUsagesExtension(x509.KeyUsageFlags.keyCertSign | x509.KeyUsageFlags.cRLSign, true), + await x509.SubjectKeyIdentifierExtension.create(rootCaKeys.publicKey) + ] + }); + + // generate client ca + const clientCaSerialNumber = createSerialNumber(); + const clientCaIssuedAt = new Date(); + const clientCaExpiration = new Date(new Date().setFullYear(2045)); + const clientCaKeys = await crypto.subtle.generateKey(alg, true, ["sign", "verify"]); + const clientCaSkObj = crypto.KeyObject.from(clientCaKeys.privateKey); + + const clientCaCert = await x509.X509CertificateGenerator.create({ + serialNumber: clientCaSerialNumber, + subject: `O=${identityOrg},CN=Client Intermediate CA`, + issuer: rootCaCert.subject, + notBefore: clientCaIssuedAt, + notAfter: clientCaExpiration, + signingKey: rootCaKeys.privateKey, + publicKey: clientCaKeys.publicKey, + signingAlgorithm: alg, + extensions: [ + new x509.KeyUsagesExtension( + // eslint-disable-next-line no-bitwise + x509.KeyUsageFlags.keyCertSign | + x509.KeyUsageFlags.cRLSign | + x509.KeyUsageFlags.digitalSignature | + x509.KeyUsageFlags.keyEncipherment, + true + ), + new x509.BasicConstraintsExtension(true, 0, true), + await x509.AuthorityKeyIdentifierExtension.create(rootCaCert, false), + await x509.SubjectKeyIdentifierExtension.create(clientCaKeys.publicKey) + ] + }); + + const clientKeys = await crypto.subtle.generateKey(alg, true, ["sign", "verify"]); + const clientCertSerialNumber = createSerialNumber(); + const clientCert = await x509.X509CertificateGenerator.create({ + serialNumber: clientCertSerialNumber, + subject: `O=${identityOrg},OU=gateway-client,CN=cloud`, + issuer: clientCaCert.subject, + notAfter: clientCaExpiration, + notBefore: clientCaIssuedAt, + signingKey: clientCaKeys.privateKey, + publicKey: clientKeys.publicKey, + signingAlgorithm: alg, + extensions: [ + new x509.BasicConstraintsExtension(false), + await x509.AuthorityKeyIdentifierExtension.create(clientCaCert, false), + await x509.SubjectKeyIdentifierExtension.create(clientKeys.publicKey), + new x509.CertificatePolicyExtension(["2.5.29.32.0"]), // anyPolicy + new x509.KeyUsagesExtension( + // eslint-disable-next-line no-bitwise + x509.KeyUsageFlags[CertKeyUsage.DIGITAL_SIGNATURE] | + x509.KeyUsageFlags[CertKeyUsage.KEY_ENCIPHERMENT] | + x509.KeyUsageFlags[CertKeyUsage.KEY_AGREEMENT], + true + ), + new x509.ExtendedKeyUsageExtension([x509.ExtendedKeyUsage[CertExtendedKeyUsage.CLIENT_AUTH]], true) + ] + }); + const clientSkObj = crypto.KeyObject.from(clientKeys.privateKey); + + // generate gateway ca + const gatewayCaSerialNumber = createSerialNumber(); + const gatewayCaIssuedAt = new Date(); + const gatewayCaExpiration = new Date(new Date().setFullYear(2045)); + const gatewayCaKeys = await crypto.subtle.generateKey(alg, true, ["sign", "verify"]); + const gatewayCaSkObj = crypto.KeyObject.from(gatewayCaKeys.privateKey); + const gatewayCaCert = await x509.X509CertificateGenerator.create({ + serialNumber: gatewayCaSerialNumber, + subject: `O=${identityOrg},CN=Gateway CA`, + issuer: rootCaCert.subject, + notBefore: gatewayCaIssuedAt, + notAfter: gatewayCaExpiration, + signingKey: rootCaKeys.privateKey, + publicKey: gatewayCaKeys.publicKey, + signingAlgorithm: alg, + extensions: [ + new x509.KeyUsagesExtension( + // eslint-disable-next-line no-bitwise + x509.KeyUsageFlags.keyCertSign | + x509.KeyUsageFlags.cRLSign | + x509.KeyUsageFlags.digitalSignature | + x509.KeyUsageFlags.keyEncipherment, + true + ), + new x509.BasicConstraintsExtension(true, 0, true), + await x509.AuthorityKeyIdentifierExtension.create(rootCaCert, false), + await x509.SubjectKeyIdentifierExtension.create(gatewayCaKeys.publicKey) + ] + }); + + return orgGatewayConfigDAL.create({ + orgId: identityOrg, + rootCaIssuedAt, + rootCaExpiration, + rootCaSerialNumber, + rootCaKeyAlgorithm, + encryptedRootCaPrivateKey: orgKmsEncryptor({ + plainText: rootCaSkObj.export({ + type: "pkcs8", + format: "der" + }) + }).cipherTextBlob, + encryptedRootCaCertificate: orgKmsEncryptor({ plainText: Buffer.from(rootCaCert.rawData) }).cipherTextBlob, + + clientCaIssuedAt, + clientCaExpiration, + clientCaSerialNumber, + encryptedClientCaPrivateKey: orgKmsEncryptor({ + plainText: clientCaSkObj.export({ + type: "pkcs8", + format: "der" + }) + }).cipherTextBlob, + encryptedClientCaCertificate: orgKmsEncryptor({ + plainText: Buffer.from(clientCaCert.rawData) + }).cipherTextBlob, + + clientCertIssuedAt: clientCaIssuedAt, + clientCertExpiration: clientCaExpiration, + clientCertKeyAlgorithm: CertKeyAlgorithm.RSA_2048, + clientCertSerialNumber, + encryptedClientPrivateKey: orgKmsEncryptor({ + plainText: clientSkObj.export({ + type: "pkcs8", + format: "der" + }) + }).cipherTextBlob, + encryptedClientCertificate: orgKmsEncryptor({ + plainText: Buffer.from(clientCert.rawData) + }).cipherTextBlob, + + gatewayCaIssuedAt, + gatewayCaExpiration, + gatewayCaSerialNumber, + encryptedGatewayCaPrivateKey: orgKmsEncryptor({ + plainText: gatewayCaSkObj.export({ + type: "pkcs8", + format: "der" + }) + }).cipherTextBlob, + encryptedGatewayCaCertificate: orgKmsEncryptor({ + plainText: Buffer.from(gatewayCaCert.rawData) + }).cipherTextBlob + }); + }); + + const rootCaCert = new x509.X509Certificate( + orgKmsDecryptor({ + cipherTextBlob: orgGatewayConfig.encryptedRootCaCertificate + }) + ); + const clientCaCert = new x509.X509Certificate( + orgKmsDecryptor({ + cipherTextBlob: orgGatewayConfig.encryptedClientCaCertificate + }) + ); + + const gatewayCaAlg = keyAlgorithmToAlgCfg(orgGatewayConfig.rootCaKeyAlgorithm as CertKeyAlgorithm); + const gatewayCaSkObj = crypto.createPrivateKey({ + key: orgKmsDecryptor({ cipherTextBlob: orgGatewayConfig.encryptedGatewayCaPrivateKey }), + format: "der", + type: "pkcs8" + }); + const gatewayCaCert = new x509.X509Certificate( + orgKmsDecryptor({ + cipherTextBlob: orgGatewayConfig.encryptedGatewayCaCertificate + }) + ); + + const gatewayCaPrivateKey = await crypto.subtle.importKey( + "pkcs8", + gatewayCaSkObj.export({ format: "der", type: "pkcs8" }), + gatewayCaAlg, + true, + ["sign"] + ); + + const alg = keyAlgorithmToAlgCfg(CertKeyAlgorithm.RSA_2048); + const gatewayKeys = await crypto.subtle.generateKey(alg, true, ["sign", "verify"]); + const certIssuedAt = new Date(); + // then need to periodically init + const certExpireAt = new Date(new Date().setMonth(new Date().getMonth() + 1)); + + const extensions: x509.Extension[] = [ + new x509.BasicConstraintsExtension(false), + await x509.AuthorityKeyIdentifierExtension.create(gatewayCaCert, false), + await x509.SubjectKeyIdentifierExtension.create(gatewayKeys.publicKey), + new x509.CertificatePolicyExtension(["2.5.29.32.0"]), // anyPolicy + new x509.KeyUsagesExtension( + // eslint-disable-next-line no-bitwise + x509.KeyUsageFlags[CertKeyUsage.DIGITAL_SIGNATURE] | x509.KeyUsageFlags[CertKeyUsage.KEY_ENCIPHERMENT], + true + ), + new x509.ExtendedKeyUsageExtension([x509.ExtendedKeyUsage[CertExtendedKeyUsage.SERVER_AUTH]], true), + // san + new x509.SubjectAlternativeNameExtension([{ type: "ip", value: relayAddress.split(":")[0] }], false) + ]; + + const serialNumber = createSerialNumber(); + const privateKey = crypto.KeyObject.from(gatewayKeys.privateKey); + const gatewayCertificate = await x509.X509CertificateGenerator.create({ + serialNumber, + subject: `CN=${identityId},O=${identityOrg},OU=Gateway`, + issuer: gatewayCaCert.subject, + notBefore: certIssuedAt, + notAfter: certExpireAt, + signingKey: gatewayCaPrivateKey, + publicKey: gatewayKeys.publicKey, + signingAlgorithm: alg, + extensions + }); + + const appCfg = getConfig(); + // just for local development + const formatedRelayAddress = + appCfg.NODE_ENV === "development" ? relayAddress.replace("127.0.0.1", "host.docker.internal") : relayAddress; + + await gatewayDAL.transaction(async (tx) => { + await tx.raw("SELECT pg_advisory_xact_lock(?)", [PgSqlLock.OrgGatewayCertExchange(identityOrg)]); + const existingGateway = await gatewayDAL.findOne({ identityId, orgGatewayRootCaId: orgGatewayConfig.id }); + + if (existingGateway) { + return gatewayDAL.updateById(existingGateway.id, { + keyAlgorithm: CertKeyAlgorithm.RSA_2048, + issuedAt: certIssuedAt, + expiration: certExpireAt, + serialNumber, + relayAddress: orgKmsEncryptor({ + plainText: Buffer.from(formatedRelayAddress) + }).cipherTextBlob + }); + } + + return gatewayDAL.create({ + keyAlgorithm: CertKeyAlgorithm.RSA_2048, + issuedAt: certIssuedAt, + expiration: certExpireAt, + serialNumber, + relayAddress: orgKmsEncryptor({ + plainText: Buffer.from(formatedRelayAddress) + }).cipherTextBlob, + identityId, + orgGatewayRootCaId: orgGatewayConfig.id, + name: `gateway-${alphaNumericNanoId(6).toLowerCase()}` + }); + }); + + const gatewayCertificateChain = `${clientCaCert.toString("pem")}\n${rootCaCert.toString("pem")}`.trim(); + + return { + serialNumber, + privateKey: privateKey.export({ format: "pem", type: "pkcs8" }) as string, + certificate: gatewayCertificate.toString("pem"), + certificateChain: gatewayCertificateChain + }; + }; + + const heartbeat = async ({ orgPermission }: THeartBeatDTO) => { + await $validateOrgAccessToGateway(orgPermission.orgId, orgPermission.id, orgPermission.authMethod); + const orgGatewayConfig = await orgGatewayConfigDAL.findOne({ orgId: orgPermission.orgId }); + if (!orgGatewayConfig) throw new NotFoundError({ message: `Identity with ID ${orgPermission.id} not found.` }); + + const [gateway] = await gatewayDAL.find({ identityId: orgPermission.id, orgGatewayRootCaId: orgGatewayConfig.id }); + if (!gateway) throw new NotFoundError({ message: `Gateway with ID ${orgPermission.id} not found.` }); + + const { decryptor: orgKmsDecryptor } = await kmsService.createCipherPairWithDataKey({ + type: KmsDataKey.Organization, + orgId: orgGatewayConfig.orgId + }); + + const rootCaCert = new x509.X509Certificate( + orgKmsDecryptor({ + cipherTextBlob: orgGatewayConfig.encryptedRootCaCertificate + }) + ); + const gatewayCaCert = new x509.X509Certificate( + orgKmsDecryptor({ + cipherTextBlob: orgGatewayConfig.encryptedGatewayCaCertificate + }) + ); + const clientCert = new x509.X509Certificate( + orgKmsDecryptor({ + cipherTextBlob: orgGatewayConfig.encryptedClientCertificate + }) + ); + + const privateKey = crypto + .createPrivateKey({ + key: orgKmsDecryptor({ cipherTextBlob: orgGatewayConfig.encryptedClientPrivateKey }), + format: "der", + type: "pkcs8" + }) + .export({ type: "pkcs8", format: "pem" }); + + const relayAddress = orgKmsDecryptor({ cipherTextBlob: gateway.relayAddress }).toString(); + const [relayHost, relayPort] = relayAddress.split(":"); + + await pingGatewayAndVerify({ + relayHost, + relayPort: Number(relayPort), + tlsOptions: { + key: privateKey, + ca: `${gatewayCaCert.toString("pem")}\n${rootCaCert.toString("pem")}`.trim(), + cert: clientCert.toString("pem") + }, + identityId: orgPermission.id, + orgId: orgPermission.orgId + }); + + await gatewayDAL.updateById(gateway.id, { heartbeat: new Date() }); + }; + + const listGateways = async ({ orgPermission }: TListGatewaysDTO) => { + const { permission } = await permissionService.getOrgPermission( + orgPermission.type, + orgPermission.id, + orgPermission.orgId, + orgPermission.authMethod, + orgPermission.orgId + ); + ForbiddenError.from(permission).throwUnlessCan( + OrgPermissionGatewayActions.ListGateways, + OrgPermissionSubjects.Gateway + ); + const orgGatewayConfig = await orgGatewayConfigDAL.findOne({ orgId: orgPermission.orgId }); + if (!orgGatewayConfig) return []; + + const gateways = await gatewayDAL.find({ + orgGatewayRootCaId: orgGatewayConfig.id + }); + return gateways; + }; + + const getGatewayById = async ({ orgPermission, id }: TGetGatewayByIdDTO) => { + const { permission } = await permissionService.getOrgPermission( + orgPermission.type, + orgPermission.id, + orgPermission.orgId, + orgPermission.authMethod, + orgPermission.orgId + ); + ForbiddenError.from(permission).throwUnlessCan( + OrgPermissionGatewayActions.ListGateways, + OrgPermissionSubjects.Gateway + ); + const orgGatewayConfig = await orgGatewayConfigDAL.findOne({ orgId: orgPermission.orgId }); + if (!orgGatewayConfig) throw new NotFoundError({ message: `Gateway with ID ${id} not found.` }); + + const [gateway] = await gatewayDAL.find({ id, orgGatewayRootCaId: orgGatewayConfig.id }); + if (!gateway) throw new NotFoundError({ message: `Gateway with ID ${id} not found.` }); + return gateway; + }; + + const updateGatewayById = async ({ orgPermission, id, name, projectIds }: TUpdateGatewayByIdDTO) => { + const { permission } = await permissionService.getOrgPermission( + orgPermission.type, + orgPermission.id, + orgPermission.orgId, + orgPermission.authMethod, + orgPermission.orgId + ); + ForbiddenError.from(permission).throwUnlessCan( + OrgPermissionGatewayActions.EditGateways, + OrgPermissionSubjects.Gateway + ); + const orgGatewayConfig = await orgGatewayConfigDAL.findOne({ orgId: orgPermission.orgId }); + if (!orgGatewayConfig) throw new NotFoundError({ message: `Gateway with ID ${id} not found.` }); + + const [gateway] = await gatewayDAL.update({ id, orgGatewayRootCaId: orgGatewayConfig.id }, { name }); + if (!gateway) throw new NotFoundError({ message: `Gateway with ID ${id} not found.` }); + if (projectIds) { + await projectGatewayDAL.transaction(async (tx) => { + await projectGatewayDAL.delete({ gatewayId: gateway.id }, tx); + await projectGatewayDAL.insertMany( + projectIds.map((el) => ({ gatewayId: gateway.id, projectId: el })), + tx + ); + }); + } + + return gateway; + }; + + const deleteGatewayById = async ({ orgPermission, id }: TGetGatewayByIdDTO) => { + const { permission } = await permissionService.getOrgPermission( + orgPermission.type, + orgPermission.id, + orgPermission.orgId, + orgPermission.authMethod, + orgPermission.orgId + ); + ForbiddenError.from(permission).throwUnlessCan( + OrgPermissionGatewayActions.DeleteGateways, + OrgPermissionSubjects.Gateway + ); + const orgGatewayConfig = await orgGatewayConfigDAL.findOne({ orgId: orgPermission.orgId }); + if (!orgGatewayConfig) throw new NotFoundError({ message: `Gateway with ID ${id} not found.` }); + + const [gateway] = await gatewayDAL.delete({ id, orgGatewayRootCaId: orgGatewayConfig.id }); + if (!gateway) throw new NotFoundError({ message: `Gateway with ID ${id} not found.` }); + return gateway; + }; + + const getProjectGateways = async ({ projectId, projectPermission }: TGetProjectGatewayByIdDTO) => { + await permissionService.getProjectPermission({ + projectId, + actor: projectPermission.type, + actorId: projectPermission.id, + actorOrgId: projectPermission.orgId, + actorAuthMethod: projectPermission.authMethod, + actionProjectType: ActionProjectType.Any + }); + + const gateways = await gatewayDAL.findByProjectId(projectId); + return gateways; + }; + + // this has no permission check and used for dynamic secrets directly + // assumes permission check is already done + const fnGetGatewayClientTls = async (projectGatewayId: string) => { + const projectGateway = await projectGatewayDAL.findById(projectGatewayId); + if (!projectGateway) throw new NotFoundError({ message: `Project gateway with ID ${projectGatewayId} not found.` }); + + const { gatewayId } = projectGateway; + const gateway = await gatewayDAL.findById(gatewayId); + if (!gateway) throw new NotFoundError({ message: `Gateway with ID ${gatewayId} not found.` }); + + const orgGatewayConfig = await orgGatewayConfigDAL.findById(gateway.orgGatewayRootCaId); + const { decryptor: orgKmsDecryptor } = await kmsService.createCipherPairWithDataKey({ + type: KmsDataKey.Organization, + orgId: orgGatewayConfig.orgId + }); + + const rootCaCert = new x509.X509Certificate( + orgKmsDecryptor({ + cipherTextBlob: orgGatewayConfig.encryptedRootCaCertificate + }) + ); + const gatewayCaCert = new x509.X509Certificate( + orgKmsDecryptor({ + cipherTextBlob: orgGatewayConfig.encryptedGatewayCaCertificate + }) + ); + const clientCert = new x509.X509Certificate( + orgKmsDecryptor({ + cipherTextBlob: orgGatewayConfig.encryptedClientCertificate + }) + ); + + const clientSkObj = crypto.createPrivateKey({ + key: orgKmsDecryptor({ cipherTextBlob: orgGatewayConfig.encryptedClientPrivateKey }), + format: "der", + type: "pkcs8" + }); + + return { + relayAddress: orgKmsDecryptor({ cipherTextBlob: gateway.relayAddress }).toString(), + privateKey: clientSkObj.export({ type: "pkcs8", format: "pem" }), + certificate: clientCert.toString("pem"), + certChain: `${gatewayCaCert.toString("pem")}\n${rootCaCert.toString("pem")}`.trim(), + identityId: gateway.identityId, + orgId: orgGatewayConfig.orgId + }; + }; + + return { + getGatewayRelayDetails, + exchangeAllocatedRelayAddress, + listGateways, + getGatewayById, + updateGatewayById, + deleteGatewayById, + getProjectGateways, + fnGetGatewayClientTls, + heartbeat + }; +}; diff --git a/backend/src/ee/services/gateway/gateway-types.ts b/backend/src/ee/services/gateway/gateway-types.ts new file mode 100644 index 000000000..220dc7147 --- /dev/null +++ b/backend/src/ee/services/gateway/gateway-types.ts @@ -0,0 +1,39 @@ +import { OrgServiceActor } from "@app/lib/types"; +import { ActorAuthMethod } from "@app/services/auth/auth-type"; + +export type TExchangeAllocatedRelayAddressDTO = { + identityId: string; + identityOrg: string; + identityOrgAuthMethod: ActorAuthMethod; + relayAddress: string; +}; + +export type TListGatewaysDTO = { + orgPermission: OrgServiceActor; +}; + +export type TGetGatewayByIdDTO = { + id: string; + orgPermission: OrgServiceActor; +}; + +export type TUpdateGatewayByIdDTO = { + id: string; + name?: string; + projectIds?: string[]; + orgPermission: OrgServiceActor; +}; + +export type TDeleteGatewayByIdDTO = { + id: string; + orgPermission: OrgServiceActor; +}; + +export type TGetProjectGatewayByIdDTO = { + projectId: string; + projectPermission: OrgServiceActor; +}; + +export type THeartBeatDTO = { + orgPermission: OrgServiceActor; +}; diff --git a/backend/src/ee/services/gateway/org-gateway-config-dal.ts b/backend/src/ee/services/gateway/org-gateway-config-dal.ts new file mode 100644 index 000000000..9d4f9384a --- /dev/null +++ b/backend/src/ee/services/gateway/org-gateway-config-dal.ts @@ -0,0 +1,10 @@ +import { TDbClient } from "@app/db"; +import { TableName } from "@app/db/schemas"; +import { ormify } from "@app/lib/knex"; + +export type TOrgGatewayConfigDALFactory = ReturnType; + +export const orgGatewayConfigDALFactory = (db: TDbClient) => { + const orm = ormify(db, TableName.OrgGatewayConfig); + return orm; +}; diff --git a/backend/src/ee/services/gateway/project-gateway-dal.ts b/backend/src/ee/services/gateway/project-gateway-dal.ts new file mode 100644 index 000000000..44c36f5f6 --- /dev/null +++ b/backend/src/ee/services/gateway/project-gateway-dal.ts @@ -0,0 +1,10 @@ +import { TDbClient } from "@app/db"; +import { TableName } from "@app/db/schemas"; +import { ormify } from "@app/lib/knex"; + +export type TProjectGatewayDALFactory = ReturnType; + +export const projectGatewayDALFactory = (db: TDbClient) => { + const orm = ormify(db, TableName.ProjectGateway); + return orm; +}; diff --git a/backend/src/ee/services/license/license-fns.ts b/backend/src/ee/services/license/license-fns.ts index cab19a530..21d378802 100644 --- a/backend/src/ee/services/license/license-fns.ts +++ b/backend/src/ee/services/license/license-fns.ts @@ -51,7 +51,8 @@ export const getDefaultOnPremFeatures = (): TFeatureSet => ({ pkiEst: false, enforceMfa: false, projectTemplates: false, - kmip: false + kmip: false, + gateway: false }); export const setupLicenseRequestWithStore = (baseURL: string, refreshUrl: string, licenseKey: string) => { diff --git a/backend/src/ee/services/license/license-types.ts b/backend/src/ee/services/license/license-types.ts index 2b4dbe49e..34e350cf6 100644 --- a/backend/src/ee/services/license/license-types.ts +++ b/backend/src/ee/services/license/license-types.ts @@ -69,6 +69,7 @@ export type TFeatureSet = { enforceMfa: boolean; projectTemplates: false; kmip: false; + gateway: false; }; export type TOrgPlansTableDTO = { diff --git a/backend/src/ee/services/permission/org-permission.ts b/backend/src/ee/services/permission/org-permission.ts index 03d1747d4..dbabcc2c1 100644 --- a/backend/src/ee/services/permission/org-permission.ts +++ b/backend/src/ee/services/permission/org-permission.ts @@ -32,6 +32,14 @@ export enum OrgPermissionAdminConsoleAction { AccessAllProjects = "access-all-projects" } +export enum OrgPermissionGatewayActions { + // is there a better word for this. This mean can an identity be a gateway + CreateGateways = "create-gateways", + ListGateways = "list-gateways", + EditGateways = "edit-gateways", + DeleteGateways = "delete-gateways" +} + export enum OrgPermissionSubjects { Workspace = "workspace", Role = "role", @@ -50,7 +58,8 @@ export enum OrgPermissionSubjects { AuditLogs = "audit-logs", ProjectTemplates = "project-templates", AppConnections = "app-connections", - Kmip = "kmip" + Kmip = "kmip", + Gateway = "gateway" } export type AppConnectionSubjectFields = { @@ -73,6 +82,7 @@ export type OrgPermissionSet = | [OrgPermissionActions, OrgPermissionSubjects.Kms] | [OrgPermissionActions, OrgPermissionSubjects.AuditLogs] | [OrgPermissionActions, OrgPermissionSubjects.ProjectTemplates] + | [OrgPermissionGatewayActions, OrgPermissionSubjects.Gateway] | [ OrgPermissionAppConnectionActions, ( @@ -180,6 +190,12 @@ export const OrgPermissionSchema = z.discriminatedUnion("subject", [ action: CASL_ACTION_SCHEMA_NATIVE_ENUM(OrgPermissionKmipActions).describe( "Describe what action an entity can take." ) + }), + z.object({ + subject: z.literal(OrgPermissionSubjects.Gateway).describe("The entity this permission pertains to."), + action: CASL_ACTION_SCHEMA_NATIVE_ENUM(OrgPermissionGatewayActions).describe( + "Describe what action an entity can take." + ) }) ]); @@ -264,6 +280,11 @@ const buildAdminPermission = () => { can(OrgPermissionAppConnectionActions.Delete, OrgPermissionSubjects.AppConnections); can(OrgPermissionAppConnectionActions.Connect, OrgPermissionSubjects.AppConnections); + can(OrgPermissionGatewayActions.ListGateways, OrgPermissionSubjects.Gateway); + can(OrgPermissionGatewayActions.CreateGateways, OrgPermissionSubjects.Gateway); + can(OrgPermissionGatewayActions.EditGateways, OrgPermissionSubjects.Gateway); + can(OrgPermissionGatewayActions.DeleteGateways, OrgPermissionSubjects.Gateway); + can(OrgPermissionAdminConsoleAction.AccessAllProjects, OrgPermissionSubjects.AdminConsole); can(OrgPermissionKmipActions.Setup, OrgPermissionSubjects.Kmip); @@ -300,6 +321,8 @@ const buildMemberPermission = () => { can(OrgPermissionActions.Read, OrgPermissionSubjects.AuditLogs); can(OrgPermissionAppConnectionActions.Connect, OrgPermissionSubjects.AppConnections); + can(OrgPermissionGatewayActions.ListGateways, OrgPermissionSubjects.Gateway); + can(OrgPermissionGatewayActions.CreateGateways, OrgPermissionSubjects.Gateway); return rules; }; diff --git a/backend/src/keystore/keystore.ts b/backend/src/keystore/keystore.ts index a5f3c24c0..8ff07db26 100644 --- a/backend/src/keystore/keystore.ts +++ b/backend/src/keystore/keystore.ts @@ -1,12 +1,15 @@ import { Redis } from "ioredis"; +import { pgAdvisoryLockHashText } from "@app/lib/crypto/hashtext"; import { Redlock, Settings } from "@app/lib/red-lock"; -export enum PgSqlLock { - BootUpMigration = 2023, - SuperAdminInit = 2024, - KmsRootKeyInit = 2025 -} +export const PgSqlLock = { + BootUpMigration: 2023, + SuperAdminInit: 2024, + KmsRootKeyInit: 2025, + OrgGatewayRootCaInit: (orgId: string) => pgAdvisoryLockHashText(`org-gateway-root-ca:${orgId}`), + OrgGatewayCertExchange: (orgId: string) => pgAdvisoryLockHashText(`org-gateway-cert-exchange:${orgId}`) +} as const; export type TKeyStoreFactory = ReturnType; @@ -33,7 +36,8 @@ export const KeyStorePrefixes = { SecretSyncLastRunTimestamp: (syncId: string) => `secret-sync-last-run-${syncId}` as const, IdentityAccessTokenStatusUpdate: (identityAccessTokenId: string) => `identity-access-token-status:${identityAccessTokenId}`, - ServiceTokenStatusUpdate: (serviceTokenId: string) => `service-token-status:${serviceTokenId}` + ServiceTokenStatusUpdate: (serviceTokenId: string) => `service-token-status:${serviceTokenId}`, + GatewayIdentityCredential: (identityId: string) => `gateway-credentials:${identityId}` }; export const KeyStoreTtls = { diff --git a/backend/src/lib/config/env.ts b/backend/src/lib/config/env.ts index 801e937a2..c51809849 100644 --- a/backend/src/lib/config/env.ts +++ b/backend/src/lib/config/env.ts @@ -184,6 +184,14 @@ const envSchema = z USE_PG_QUEUE: zodStrBool.default("false"), SHOULD_INIT_PG_QUEUE: zodStrBool.default("false"), + /* Gateway----------------------------------------------------------------------------- */ + GATEWAY_INFISICAL_STATIC_IP_ADDRESS: zpStr(z.string().optional()), + GATEWAY_RELAY_ADDRESS: zpStr(z.string().optional()), + GATEWAY_RELAY_REALM: zpStr(z.string().optional()), + GATEWAY_RELAY_AUTH_SECRET: zpStr(z.string().optional()), + + /* ----------------------------------------------------------------------------- */ + /* App Connections ----------------------------------------------------------------------------- */ // aws diff --git a/backend/src/lib/crypto/hashtext.ts b/backend/src/lib/crypto/hashtext.ts new file mode 100644 index 000000000..221608382 --- /dev/null +++ b/backend/src/lib/crypto/hashtext.ts @@ -0,0 +1,29 @@ +// used for postgres lock +// this is something postgres does under the hood +// convert any string to a unique number +export const hashtext = (text: string) => { + // Convert text to UTF8 bytes array for consistent behavior with PostgreSQL + const encoder = new TextEncoder(); + const bytes = encoder.encode(text); + + // Implementation of hash_any + let result = 0; + + for (let i = 0; i < bytes.length; i += 1) { + // eslint-disable-next-line no-bitwise + result = ((result << 5) + result) ^ bytes[i]; + // Keep within 32-bit integer range + // eslint-disable-next-line no-bitwise + result >>>= 0; + } + + // Convert to signed 32-bit integer like PostgreSQL + // eslint-disable-next-line no-bitwise + return result | 0; +}; + +export const pgAdvisoryLockHashText = (text: string) => { + const hash = hashtext(text); + // Ensure positive value within PostgreSQL integer range + return Math.abs(hash) % 2 ** 31; +}; diff --git a/backend/src/lib/gateway/index.ts b/backend/src/lib/gateway/index.ts new file mode 100644 index 000000000..eaebd896d --- /dev/null +++ b/backend/src/lib/gateway/index.ts @@ -0,0 +1,264 @@ +/* eslint-disable no-await-in-loop */ +import net from "node:net"; +import tls from "node:tls"; + +import { BadRequestError } from "../errors"; +import { logger } from "../logger"; + +const DEFAULT_MAX_RETRIES = 3; +const DEFAULT_RETRY_DELAY = 1000; // 1 second + +const createTLSConnection = (relayHost: string, relayPort: number, tlsOptions: tls.TlsOptions = {}) => { + return new Promise((resolve, reject) => { + // @ts-expect-error this is resolved in next connect + const socket = new tls.TLSSocket(null, { + rejectUnauthorized: true, + ...tlsOptions + }); + + const cleanup = () => { + socket.removeAllListeners(); + socket.end(); + }; + + socket.once("error", (err) => { + cleanup(); + reject(err); + }); + + socket.connect(relayPort, relayHost, () => { + resolve(socket); + }); + }); +}; + +type TPingGatewayAndVerifyDTO = { + relayHost: string; + relayPort: number; + tlsOptions: tls.TlsOptions; + maxRetries?: number; + identityId: string; + orgId: string; +}; + +export const pingGatewayAndVerify = async ({ + relayHost, + relayPort, + tlsOptions = {}, + maxRetries = DEFAULT_MAX_RETRIES, + identityId, + orgId +}: TPingGatewayAndVerifyDTO) => { + let lastError: Error | null = null; + + for (let attempt = 1; attempt <= maxRetries; attempt += 1) { + try { + const socket = await createTLSConnection(relayHost, relayPort, tlsOptions); + socket.setTimeout(2000); + + const pingResult = await new Promise((resolve, reject) => { + socket.once("timeout", () => { + socket.destroy(); + reject(new Error("Timeout")); + }); + socket.once("close", () => { + socket.destroy(); + }); + + socket.once("end", () => { + socket.destroy(); + }); + socket.once("error", (err) => { + reject(err); + }); + + socket.write(Buffer.from("PING\n"), () => { + socket.once("data", (data) => { + const response = (data as string).toString(); + const certificate = socket.getPeerCertificate(); + + if (certificate.subject.CN !== identityId || certificate.subject.O !== orgId) { + throw new BadRequestError({ + message: `Invalid gateway. Certificate not found for ${identityId} in organization ${orgId}` + }); + } + + if (response === "PONG") { + resolve(true); + } else { + reject(new Error(`Unexpected response: ${response}`)); + } + }); + }); + }); + + socket.end(); + return pingResult; + } catch (err) { + lastError = err as Error; + + if (attempt < maxRetries) { + await new Promise((resolve) => { + setTimeout(resolve, DEFAULT_RETRY_DELAY); + }); + } + } + } + + logger.error(lastError); + throw new BadRequestError({ + message: `Failed to ping gateway after ${maxRetries} attempts. Last error: ${lastError?.message}` + }); +}; + +interface TProxyServer { + server: net.Server; + port: number; + cleanup: () => void; +} + +const setupProxyServer = ({ + targetPort, + targetHost, + tlsOptions = {}, + relayHost, + relayPort +}: { + targetHost: string; + targetPort: number; + relayPort: number; + relayHost: string; + tlsOptions: tls.TlsOptions; +}): Promise => { + return new Promise((resolve, reject) => { + const server = net.createServer(); + + // eslint-disable-next-line @typescript-eslint/no-misused-promises + server.on("connection", async (clientSocket) => { + try { + const targetSocket = await createTLSConnection(relayHost, relayPort, tlsOptions); + + targetSocket.write(Buffer.from(`FORWARD-TCP ${targetHost}:${targetPort}\n`), () => { + clientSocket.on("data", (data) => { + const flushed = targetSocket.write(data); + if (!flushed) { + clientSocket.pause(); + targetSocket.once("drain", () => { + clientSocket.resume(); + }); + } + }); + + targetSocket.on("data", (data) => { + const flushed = clientSocket.write(data as string); + if (!flushed) { + targetSocket.pause(); + clientSocket.once("drain", () => { + targetSocket.resume(); + }); + } + }); + }); + + const cleanup = () => { + clientSocket?.unpipe(); + clientSocket?.end(); + targetSocket?.unpipe(); + targetSocket?.end(); + }; + + clientSocket.on("error", (err) => { + logger.error(err, "Client socket error"); + cleanup(); + reject(err); + }); + + targetSocket.on("error", (err) => { + logger.error(err, "Target socket error"); + cleanup(); + reject(err); + }); + + clientSocket.on("end", cleanup); + targetSocket.on("end", cleanup); + } catch (err) { + logger.error(err, "Failed to establish target connection:"); + clientSocket.end(); + reject(err); + } + }); + + server.on("error", (err) => { + reject(err); + }); + + server.listen(0, () => { + const address = server.address(); + if (!address || typeof address === "string") { + server.close(); + reject(new Error("Failed to get server port")); + return; + } + + logger.info("Gateway proxy started"); + resolve({ + server, + port: address.port, + cleanup: () => { + server.close(); + } + }); + }); + }); +}; + +interface ProxyOptions { + targetHost: string; + targetPort: number; + relayHost: string; + relayPort: number; + tlsOptions?: tls.TlsOptions; + maxRetries?: number; + identityId: string; + orgId: string; +} + +export const withGatewayProxy = async ( + callback: (port: number) => Promise, + options: ProxyOptions +): Promise => { + const { + relayHost, + relayPort, + targetHost, + targetPort, + tlsOptions = {}, + maxRetries = DEFAULT_MAX_RETRIES, + identityId, + orgId + } = options; + + // First, try to ping the gateway + await pingGatewayAndVerify({ + relayHost, + relayPort, + tlsOptions, + maxRetries, + identityId, + orgId + }); + + // Setup the proxy server + const { port, cleanup } = await setupProxyServer({ targetHost, targetPort, relayPort, relayHost, tlsOptions }); + + try { + // Execute the callback with the allocated port + await callback(port); + } catch (err) { + logger.error(err, "Failed to proxy"); + throw new BadRequestError({ message: (err as Error)?.message }); + } finally { + // Ensure cleanup happens regardless of success or failure + cleanup(); + } +}; diff --git a/backend/src/lib/turn/credentials.ts b/backend/src/lib/turn/credentials.ts new file mode 100644 index 000000000..817148c30 --- /dev/null +++ b/backend/src/lib/turn/credentials.ts @@ -0,0 +1,16 @@ +import crypto from "node:crypto"; + +const TURN_TOKEN_TTL = 60 * 60 * 1000; // 24 hours in milliseconds +export const getTurnCredentials = (id: string, authSecret: string, ttl = TURN_TOKEN_TTL) => { + const timestamp = Math.floor((Date.now() + ttl) / 1000); + const username = `${timestamp}:${id}`; + + const hmac = crypto.createHmac("sha1", authSecret); + hmac.update(username); + const password = hmac.digest("base64"); + + return { + username, + password + }; +}; diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.ts index 155b52cfb..c1ab5d149 100644 --- a/backend/src/server/routes/index.ts +++ b/backend/src/server/routes/index.ts @@ -27,6 +27,10 @@ import { dynamicSecretLeaseQueueServiceFactory } from "@app/ee/services/dynamic- import { dynamicSecretLeaseServiceFactory } from "@app/ee/services/dynamic-secret-lease/dynamic-secret-lease-service"; import { externalKmsDALFactory } from "@app/ee/services/external-kms/external-kms-dal"; import { externalKmsServiceFactory } from "@app/ee/services/external-kms/external-kms-service"; +import { gatewayDALFactory } from "@app/ee/services/gateway/gateway-dal"; +import { gatewayServiceFactory } from "@app/ee/services/gateway/gateway-service"; +import { orgGatewayConfigDALFactory } from "@app/ee/services/gateway/org-gateway-config-dal"; +import { projectGatewayDALFactory } from "@app/ee/services/gateway/project-gateway-dal"; import { groupDALFactory } from "@app/ee/services/group/group-dal"; import { groupServiceFactory } from "@app/ee/services/group/group-service"; import { userGroupMembershipDALFactory } from "@app/ee/services/group/user-group-membership-dal"; @@ -393,6 +397,10 @@ export const registerRoutes = async ( const kmipOrgConfigDAL = kmipOrgConfigDALFactory(db); const kmipOrgServerCertificateDAL = kmipOrgServerCertificateDALFactory(db); + const orgGatewayConfigDAL = orgGatewayConfigDALFactory(db); + const gatewayDAL = gatewayDALFactory(db); + const projectGatewayDAL = projectGatewayDALFactory(db); + const permissionService = permissionServiceFactory({ permissionDAL, orgRoleDAL, @@ -1300,7 +1308,19 @@ export const registerRoutes = async ( kmsService }); - const dynamicSecretProviders = buildDynamicSecretProviders(); + const gatewayService = gatewayServiceFactory({ + permissionService, + gatewayDAL, + kmsService, + licenseService, + orgGatewayConfigDAL, + keyStore, + projectGatewayDAL + }); + + const dynamicSecretProviders = buildDynamicSecretProviders({ + gatewayService + }); const dynamicSecretQueueService = dynamicSecretLeaseQueueServiceFactory({ queueService, dynamicSecretLeaseDAL, @@ -1318,8 +1338,10 @@ export const registerRoutes = async ( folderDAL, permissionService, licenseService, - kmsService + kmsService, + projectGatewayDAL }); + const dynamicSecretLeaseService = dynamicSecretLeaseServiceFactory({ projectDAL, permissionService, @@ -1557,7 +1579,8 @@ export const registerRoutes = async ( appConnection: appConnectionService, secretSync: secretSyncService, kmip: kmipService, - kmipOperation: kmipOperationService + kmipOperation: kmipOperationService, + gateway: gatewayService }); const cronJobs: CronJob[] = []; diff --git a/cli/go.mod b/cli/go.mod index b96772c91..7339ec68f 100644 --- a/cli/go.mod +++ b/cli/go.mod @@ -18,14 +18,16 @@ require ( github.com/muesli/reflow v0.3.0 github.com/muesli/roff v0.1.0 github.com/petar-dambovaliev/aho-corasick v0.0.0-20211021192214-5ab2d9280aa9 + github.com/pion/logging v0.2.3 + github.com/pion/turn/v4 v4.0.0 github.com/posthog/posthog-go v0.0.0-20221221115252-24dfed35d71a github.com/rs/cors v1.11.0 github.com/rs/zerolog v1.26.1 github.com/spf13/cobra v1.6.1 github.com/spf13/viper v1.8.1 github.com/stretchr/testify v1.9.0 - golang.org/x/crypto v0.31.0 - golang.org/x/term v0.27.0 + golang.org/x/crypto v0.33.0 + golang.org/x/term v0.29.0 gopkg.in/yaml.v2 v2.4.0 ) @@ -81,6 +83,10 @@ require ( github.com/muesli/termenv v0.15.2 // indirect github.com/oklog/ulid v1.3.1 // indirect github.com/pelletier/go-toml v1.9.3 // indirect + github.com/pion/dtls/v3 v3.0.4 // indirect + github.com/pion/randutil v0.1.0 // indirect + github.com/pion/stun/v3 v3.0.0 // indirect + github.com/pion/transport/v3 v3.0.7 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rivo/uniseg v0.2.0 // indirect @@ -88,6 +94,7 @@ require ( github.com/spf13/cast v1.3.1 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/subosito/gotenv v1.2.0 // indirect + github.com/wlynxg/anet v0.0.5 // indirect github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c // indirect go.mongodb.org/mongo-driver v1.10.0 // indirect go.opencensus.io v0.24.0 // indirect @@ -98,9 +105,9 @@ require ( go.opentelemetry.io/otel/trace v1.24.0 // indirect golang.org/x/net v0.33.0 // indirect golang.org/x/oauth2 v0.21.0 // indirect - golang.org/x/sync v0.10.0 // indirect - golang.org/x/sys v0.28.0 // indirect - golang.org/x/text v0.21.0 // indirect + golang.org/x/sync v0.11.0 // indirect + golang.org/x/sys v0.30.0 // indirect + golang.org/x/text v0.22.0 // indirect golang.org/x/time v0.6.0 // indirect google.golang.org/api v0.188.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240701130421-f6361c86f094 // indirect diff --git a/cli/go.sum b/cli/go.sum index 67a3d3275..20215d776 100644 --- a/cli/go.sum +++ b/cli/go.sum @@ -347,6 +347,18 @@ github.com/pelletier/go-toml v1.9.3 h1:zeC5b1GviRUyKYd6OJPvBU/mcVDVoL1OhT17FCt5d github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/petar-dambovaliev/aho-corasick v0.0.0-20211021192214-5ab2d9280aa9 h1:lL+y4Xv20pVlCGyLzNHRC0I0rIHhIL1lTvHizoS/dU8= github.com/petar-dambovaliev/aho-corasick v0.0.0-20211021192214-5ab2d9280aa9/go.mod h1:EHPiTAKtiFmrMldLUNswFwfZ2eJIYBHktdaUTZxYWRw= +github.com/pion/dtls/v3 v3.0.4 h1:44CZekewMzfrn9pmGrj5BNnTMDCFwr+6sLH+cCuLM7U= +github.com/pion/dtls/v3 v3.0.4/go.mod h1:R373CsjxWqNPf6MEkfdy3aSe9niZvL/JaKlGeFphtMg= +github.com/pion/logging v0.2.3 h1:gHuf0zpoh1GW67Nr6Gj4cv5Z9ZscU7g/EaoC/Ke/igI= +github.com/pion/logging v0.2.3/go.mod h1:z8YfknkquMe1csOrxK5kc+5/ZPAzMxbKLX5aXpbpC90= +github.com/pion/randutil v0.1.0 h1:CFG1UdESneORglEsnimhUjf33Rwjubwj6xfiOXBa3mA= +github.com/pion/randutil v0.1.0/go.mod h1:XcJrSMMbbMRhASFVOlj/5hQial/Y8oH/HVo7TBZq+j8= +github.com/pion/stun/v3 v3.0.0 h1:4h1gwhWLWuZWOJIJR9s2ferRO+W3zA/b6ijOI6mKzUw= +github.com/pion/stun/v3 v3.0.0/go.mod h1:HvCN8txt8mwi4FBvS3EmDghW6aQJ24T+y+1TKjB5jyU= +github.com/pion/transport/v3 v3.0.7 h1:iRbMH05BzSNwhILHoBoAPxoB9xQgOaJk+591KC9P1o0= +github.com/pion/transport/v3 v3.0.7/go.mod h1:YleKiTZ4vqNxVwh77Z0zytYi7rXHl7j6uPLGhhz9rwo= +github.com/pion/turn/v4 v4.0.0 h1:qxplo3Rxa9Yg1xXDxxH8xaqcyGUtbHYw4QSCvmFWvhM= +github.com/pion/turn/v4 v4.0.0/go.mod h1:MuPDkm15nYSklKpN8vWJ9W2M0PlyQZqYt1McGuxG7mA= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -410,6 +422,8 @@ github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69 github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= +github.com/wlynxg/anet v0.0.5 h1:J3VJGi1gvo0JwZ/P1/Yc/8p63SoW98B5dHkYDmpgvvU= +github.com/wlynxg/anet v0.0.5/go.mod h1:eay5PRQr7fIVAMbTbchTnO9gG65Hg/uYGdc7mguHxoA= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g= github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8= @@ -458,8 +472,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20211215165025-cf75a172585e/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= -golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= +golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus= +golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -560,8 +574,8 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= -golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w= +golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -610,11 +624,11 @@ golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= -golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= +golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= -golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= +golang.org/x/term v0.29.0 h1:L6pJp37ocefwRRtYPKSWOWzOtWSxVajvz2ldH/xi3iU= +golang.org/x/term v0.29.0/go.mod h1:6bl4lRlvVuDgSf3179VpIxBF0o10JUpXWOnI7nErv7s= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -624,8 +638,8 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= -golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= +golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM= +golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= diff --git a/cli/packages/api/api.go b/cli/packages/api/api.go index 3d050cd97..454257405 100644 --- a/cli/packages/api/api.go +++ b/cli/packages/api/api.go @@ -544,3 +544,59 @@ func CallUpdateRawSecretsV3(httpClient *resty.Client, request UpdateRawSecretByN return nil } + +func CallRegisterGatewayIdentityV1(httpClient *resty.Client) (*GetRelayCredentialsResponseV1, error) { + var resBody GetRelayCredentialsResponseV1 + response, err := httpClient. + R(). + SetResult(&resBody). + SetHeader("User-Agent", USER_AGENT). + Post(fmt.Sprintf("%v/v1/gateways/register-identity", config.INFISICAL_URL)) + + if err != nil { + return nil, fmt.Errorf("CallRegisterGatewayIdentityV1: Unable to complete api request [err=%w]", err) + } + + if response.IsError() { + return nil, fmt.Errorf("CallRegisterGatewayIdentityV1: Unsuccessful response [%v %v] [status-code=%v] [response=%v]", response.Request.Method, response.Request.URL, response.StatusCode(), response.String()) + } + + return &resBody, nil +} + +func CallExchangeRelayCertV1(httpClient *resty.Client, request ExchangeRelayCertRequestV1) (*ExchangeRelayCertResponseV1, error) { + var resBody ExchangeRelayCertResponseV1 + response, err := httpClient. + R(). + SetResult(&resBody). + SetBody(request). + SetHeader("User-Agent", USER_AGENT). + Post(fmt.Sprintf("%v/v1/gateways/exchange-cert", config.INFISICAL_URL)) + + if err != nil { + return nil, fmt.Errorf("CallExchangeRelayCertV1: Unable to complete api request [err=%w]", err) + } + + if response.IsError() { + return nil, fmt.Errorf("CallExchangeRelayCertV1: Unsuccessful response [%v %v] [status-code=%v] [response=%v]", response.Request.Method, response.Request.URL, response.StatusCode(), response.String()) + } + + return &resBody, nil +} + +func CallGatewayHeartBeatV1(httpClient *resty.Client) error { + response, err := httpClient. + R(). + SetHeader("User-Agent", USER_AGENT). + Post(fmt.Sprintf("%v/v1/gateways/heartbeat", config.INFISICAL_URL)) + + if err != nil { + return fmt.Errorf("CallGatewayHeartBeatV1: Unable to complete api request [err=%w]", err) + } + + if response.IsError() { + return fmt.Errorf("CallGatewayHeartBeatV1: Unsuccessful response [%v %v] [status-code=%v] [response=%v]", response.Request.Method, response.Request.URL, response.StatusCode(), response.String()) + } + + return nil +} diff --git a/cli/packages/api/model.go b/cli/packages/api/model.go index 73a04200d..72dbbc97b 100644 --- a/cli/packages/api/model.go +++ b/cli/packages/api/model.go @@ -629,3 +629,22 @@ type GetRawSecretV3ByNameResponse struct { } `json:"secret"` ETag string } + +type GetRelayCredentialsResponseV1 struct { + TurnServerUsername string `json:"turnServerUsername"` + TurnServerPassword string `json:"turnServerPassword"` + TurnServerRealm string `json:"turnServerRealm"` + TurnServerAddress string `json:"turnServerAddress"` + InfisicalStaticIp string `json:"infisicalStaticIp"` +} + +type ExchangeRelayCertRequestV1 struct { + RelayAddress string `json:"relayAddress"` +} + +type ExchangeRelayCertResponseV1 struct { + SerialNumber string `json:"serialNumber"` + PrivateKey string `json:"privateKey"` + Certificate string `json:"certificate"` + CertificateChain string `json:"certificateChain"` +} diff --git a/cli/packages/cmd/gateway.go b/cli/packages/cmd/gateway.go new file mode 100644 index 000000000..e8591ca68 --- /dev/null +++ b/cli/packages/cmd/gateway.go @@ -0,0 +1,97 @@ +package cmd + +import ( + // "fmt" + + // "github.com/Infisical/infisical-merge/packages/api" + // "github.com/Infisical/infisical-merge/packages/models" + "context" + "fmt" + "os" + "os/signal" + "syscall" + "time" + + "github.com/Infisical/infisical-merge/packages/gateway" + "github.com/Infisical/infisical-merge/packages/util" + "github.com/rs/zerolog/log" + + // "github.com/Infisical/infisical-merge/packages/visualize" + // "github.com/rs/zerolog/log" + + // "github.com/go-resty/resty/v2" + "github.com/posthog/posthog-go" + "github.com/spf13/cobra" +) + +var gatewayCmd = &cobra.Command{ + Example: `infisical gateway`, + Short: "Used to infisical gateway", + Use: "gateway", + DisableFlagsInUseLine: true, + Args: cobra.NoArgs, + Run: func(cmd *cobra.Command, args []string) { + token, err := util.GetInfisicalToken(cmd) + if err != nil { + util.HandleError(err, "Unable to parse flag") + } + + if token == nil { + util.HandleError(fmt.Errorf("Token not found")) + } + + Telemetry.CaptureEvent("cli-command:gateway", posthog.NewProperties().Set("version", util.CLI_VERSION)) + + sigCh := make(chan os.Signal, 1) + signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM) + sigStopCh := make(chan bool, 1) + + ctx, cancel := context.WithCancel(cmd.Context()) + defer cancel() + + go func() { + <-sigCh + close(sigStopCh) + cancel() + }() + + for { + select { + case <-sigStopCh: + log.Info().Msg("Shutting down gateway") + return + default: + gatewayInstance, err := gateway.NewGateway(token.Token) + if err != nil { + util.HandleError(err) + } + + if err = gatewayInstance.ConnectWithRelay(); err != nil { + log.Error().Msgf("Gateway connection error with relay: %s", err) + log.Info().Msg("Restarting gateway...") + time.Sleep(5 * time.Second) + continue + } + err = gatewayInstance.Listen(ctx) + if err == nil { + // meaning everything went smooth and we are exiting + return + } + + log.Error().Msgf("Gateway listen error: %s", err) + log.Info().Msg("Restarting gateway...") + time.Sleep(5 * time.Second) + } + } + }, +} + +func init() { + gatewayCmd.SetHelpFunc(func(command *cobra.Command, strings []string) { + command.Flags().MarkHidden("domain") + command.Parent().HelpFunc()(command, strings) + }) + gatewayCmd.Flags().String("token", "", "Connect with Infisical using machine identity access token") + + rootCmd.AddCommand(gatewayCmd) +} diff --git a/cli/packages/gateway/connection.go b/cli/packages/gateway/connection.go new file mode 100644 index 000000000..c29804506 --- /dev/null +++ b/cli/packages/gateway/connection.go @@ -0,0 +1,107 @@ +package gateway + +import ( + "bufio" + "bytes" + "errors" + "io" + "net" + "sync" + + "github.com/rs/zerolog/log" +) + +func handleConnection(conn net.Conn) { + defer conn.Close() + log.Info().Msgf("New connection from: %s", conn.RemoteAddr().String()) + + // Use buffered reader for better handling of fragmented data + reader := bufio.NewReader(conn) + for { + msg, err := reader.ReadBytes('\n') + if err != nil { + if errors.Is(err, io.EOF) { + return + } + log.Error().Msgf("Error reading command: %s", err) + return + } + + cmd := bytes.ToUpper(bytes.TrimSpace(bytes.Split(msg, []byte(" "))[0])) + args := bytes.TrimSpace(bytes.TrimPrefix(msg, cmd)) + + switch string(cmd) { + case "FORWARD-TCP": + proxyAddress := string(bytes.Split(args, []byte(" "))[0]) + destTarget, err := net.Dial("tcp", proxyAddress) + if err != nil { + log.Error().Msgf("Failed to connect to target: %v", err) + return + } + defer destTarget.Close() + + // Handle buffered data + buffered := reader.Buffered() + if buffered > 0 { + bufferedData := make([]byte, buffered) + _, err := reader.Read(bufferedData) + if err != nil { + log.Error().Msgf("Error reading buffered data: %v", err) + return + } + + if _, err = destTarget.Write(bufferedData); err != nil { + log.Error().Msgf("Error writing buffered data: %v", err) + return + } + } + + CopyData(conn, destTarget) + return + case "PING": + if _, err := conn.Write([]byte("PONG")); err != nil { + log.Error().Msgf("Error writing PONG response: %v", err) + } + return + default: + log.Error().Msgf("Unknown command: %s", string(cmd)) + return + } + } +} + +type CloseWrite interface { + CloseWrite() error +} + +func CopyData(src, dst net.Conn) { + var wg sync.WaitGroup + wg.Add(2) + + copyAndClose := func(dst, src net.Conn, done chan<- bool) { + defer wg.Done() + _, err := io.Copy(dst, src) + if err != nil && !errors.Is(err, io.EOF) { + log.Error().Msgf("Copy error: %v", err) + } + + // Signal we're done writing + done <- true + + // Half close the connection if possible + if c, ok := dst.(CloseWrite); ok { + c.CloseWrite() + } + } + + done1 := make(chan bool, 1) + done2 := make(chan bool, 1) + + go copyAndClose(dst, src, done1) + go copyAndClose(src, dst, done2) + + // Wait for both copies to complete + <-done1 + <-done2 + wg.Wait() +} diff --git a/cli/packages/gateway/gateway.go b/cli/packages/gateway/gateway.go new file mode 100644 index 000000000..e5ec03293 --- /dev/null +++ b/cli/packages/gateway/gateway.go @@ -0,0 +1,314 @@ +package gateway + +import ( + "context" + "crypto/tls" + "crypto/x509" + "fmt" + "net" + "strings" + "sync" + "time" + + "github.com/Infisical/infisical-merge/packages/api" + "github.com/go-resty/resty/v2" + "github.com/pion/logging" + "github.com/pion/turn/v4" + "github.com/rs/zerolog/log" +) + +type GatewayConfig struct { + TurnServerUsername string + TurnServerPassword string + TurnServerAddress string + InfisicalStaticIp string + SerialNumber string + PrivateKey string + Certificate string + CertificateChain string +} + +type Gateway struct { + httpClient *resty.Client + config *GatewayConfig + client *turn.Client +} + +func NewGateway(identityToken string) (Gateway, error) { + httpClient := resty.New() + httpClient.SetAuthToken(identityToken) + + return Gateway{ + httpClient: httpClient, + config: &GatewayConfig{}, + }, nil +} + +func (g *Gateway) ConnectWithRelay() error { + relayDetails, err := api.CallRegisterGatewayIdentityV1(g.httpClient) + if err != nil { + return err + } + relayAddress, relayPort := strings.Split(relayDetails.TurnServerAddress, ":")[0], strings.Split(relayDetails.TurnServerAddress, ":")[1] + var conn net.Conn + + // Dial TURN Server + if relayPort == "5349" { + log.Info().Msgf("Provided relay port %s. Using TLS", relayPort) + conn, err = tls.Dial("tcp", relayDetails.TurnServerAddress, &tls.Config{ + InsecureSkipVerify: false, + ServerName: relayAddress, + }) + } else { + log.Info().Msgf("Provided relay port %s. Using non TLS connection.", relayPort) + peerAddr, err := net.ResolveTCPAddr("tcp", relayDetails.TurnServerAddress) + if err != nil { + return fmt.Errorf("Failed to parse turn server address: %w", err) + } + conn, err = net.DialTCP("tcp", nil, peerAddr) + } + + if err != nil { + return fmt.Errorf("Failed to connect with relay server: %w", err) + } + + // Start a new TURN Client and wrap our net.Conn in a STUNConn + // This allows us to simulate datagram based communication over a net.Conn + cfg := &turn.ClientConfig{ + STUNServerAddr: relayDetails.TurnServerAddress, + TURNServerAddr: relayDetails.TurnServerAddress, + Conn: turn.NewSTUNConn(conn), + Username: relayDetails.TurnServerUsername, + Password: relayDetails.TurnServerPassword, + Realm: relayDetails.TurnServerRealm, + LoggerFactory: logging.NewDefaultLoggerFactory(), + } + + client, err := turn.NewClient(cfg) + if err != nil { + return fmt.Errorf("Failed to create relay client: %w", err) + } + + g.config = &GatewayConfig{ + TurnServerUsername: relayDetails.TurnServerUsername, + TurnServerPassword: relayDetails.TurnServerPassword, + TurnServerAddress: relayDetails.TurnServerAddress, + InfisicalStaticIp: relayDetails.InfisicalStaticIp, + } + // if port not specific allow all port + if relayDetails.InfisicalStaticIp != "" && !strings.Contains(relayDetails.InfisicalStaticIp, ":") { + g.config.InfisicalStaticIp = g.config.InfisicalStaticIp + ":0" + } + + g.client = client + return nil +} + +func (g *Gateway) Listen(ctx context.Context) error { + defer g.client.Close() + err := g.client.Listen() + if err != nil { + return fmt.Errorf("Failed to listen to relay server: %w", err) + } + + log.Info().Msg("Connected with relay") + // Allocate a relay socket on the TURN server. On success, it + // will return a net.PacketConn which represents the remote + // socket. + relayNonTlsConn, err := g.client.AllocateTCP() + if err != nil { + return fmt.Errorf("Failed to allocate relay connection: %w", err) + } + + log.Info().Msg(relayNonTlsConn.Addr().String()) + defer func() { + if closeErr := relayNonTlsConn.Close(); closeErr != nil { + log.Error().Msgf("Failed to close connection: %s", closeErr) + } + }() + + gatewayCert, err := api.CallExchangeRelayCertV1(g.httpClient, api.ExchangeRelayCertRequestV1{ + RelayAddress: relayNonTlsConn.Addr().String(), + }) + if err != nil { + return err + } + + g.config.SerialNumber = gatewayCert.SerialNumber + g.config.PrivateKey = gatewayCert.PrivateKey + g.config.Certificate = gatewayCert.Certificate + g.config.CertificateChain = gatewayCert.CertificateChain + + done := make(chan bool, 1) + + if g.config.InfisicalStaticIp != "" { + log.Info().Msgf("Found static ip from Infisical: %s. Creating permission IP lifecycle", g.config.InfisicalStaticIp) + peerAddr, err := net.ResolveTCPAddr("tcp", g.config.InfisicalStaticIp) + if err != nil { + return fmt.Errorf("Failed to parse infisical static ip: %w", err) + } + g.registerPermissionLifecycle(func() error { + err := relayNonTlsConn.CreatePermissions(peerAddr) + return err + }, done) + } + + cert, err := tls.X509KeyPair([]byte(gatewayCert.Certificate), []byte(gatewayCert.PrivateKey)) + if err != nil { + return fmt.Errorf("failed to parse cert: %s", err) + } + + caCertPool := x509.NewCertPool() + caCertPool.AppendCertsFromPEM([]byte(gatewayCert.CertificateChain)) + + relayConn := tls.NewListener(relayNonTlsConn, &tls.Config{ + Certificates: []tls.Certificate{cert}, + MinVersion: tls.VersionTLS12, + ClientCAs: caCertPool, + ClientAuth: tls.RequireAndVerifyClientCert, + }) + + errCh := make(chan error, 1) + log.Info().Msg("Gateway started successfully") + g.registerHeartBeat(errCh, done) + g.registerRelayIsActive(relayNonTlsConn.Addr().String(), errCh, done) + + // Create a WaitGroup to track active connections + var wg sync.WaitGroup + + go func() { + for { + select { + case <-done: + return + default: + // Accept new relay connection + conn, err := relayConn.Accept() + if err != nil { + if !strings.Contains(err.Error(), "data contains incomplete STUN or TURN frame") { + log.Error().Msgf("Failed to accept connection: %v", err) + } + continue + } + + tlsConn, ok := conn.(*tls.Conn) + if !ok { + log.Error().Msg("Failed to convert to TLS connection") + conn.Close() + continue + } + + err = tlsConn.Handshake() + if err != nil { + log.Error().Msgf("TLS handshake failed: %v", err) + conn.Close() + continue + } + + // Get connection state which contains certificate information + state := tlsConn.ConnectionState() + if len(state.PeerCertificates) > 0 { + organizationUnit := state.PeerCertificates[0].Subject.OrganizationalUnit + commonName := state.PeerCertificates[0].Subject.CommonName + if organizationUnit[0] != "gateway-client" || commonName != "cloud" { + log.Error().Msgf("Client certificate verification failed. Received %s, %s", organizationUnit, commonName) + continue + } + } + + // Handle the connection in a goroutine + wg.Add(1) + go func() { + defer wg.Done() + handleConnection(conn) + }() + } + } + }() + + var isShutdown bool + select { + case <-ctx.Done(): + log.Info().Msg("Shutting down gateway...") + isShutdown = true + case err = <-errCh: + } + + // Signal the accept loop to stop + close(done) + wg.Wait() + + if isShutdown { + log.Info().Msg("Gateway shutdown complete") + } + + return err +} + +func (g *Gateway) registerHeartBeat(errCh chan error, done chan bool) { + ticker := time.NewTicker(1 * time.Hour) + + go func() { + time.Sleep(10 * time.Second) + log.Info().Msg("Registering first heart beat") + err := api.CallGatewayHeartBeatV1(g.httpClient) + if err != nil { + log.Error().Msgf("Failed to register heartbeat: %s", err) + } + + for { + select { + case <-done: + ticker.Stop() + return + case <-ticker.C: + log.Info().Msg("Registering heart beat") + err := api.CallGatewayHeartBeatV1(g.httpClient) + errCh <- err + } + } + }() +} + +func (g *Gateway) registerPermissionLifecycle(permissionFn func() error, done chan bool) { + ticker := time.NewTicker(3 * time.Minute) + + go func() { + // wait for 5 mins + permissionFn() + log.Printf("Created permission for incoming connections") + for { + select { + case <-done: + ticker.Stop() + return + case <-ticker.C: + permissionFn() + } + } + }() +} + +func (g *Gateway) registerRelayIsActive(serverAddr string, errCh chan error, done chan bool) { + ticker := time.NewTicker(10 * time.Second) + + go func() { + time.Sleep(5 * time.Second) + for { + select { + case <-done: + ticker.Stop() + return + case <-ticker.C: + conn, err := net.Dial("tcp", serverAddr) + if err != nil { + errCh <- err + return + } + if conn != nil { + conn.Close() + } + } + } + }() +} diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index d3526d841..f12d446ef 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -56,4 +56,3 @@ volumes: networks: infisical: - diff --git a/docs/documentation/platform/gateways/overview.mdx b/docs/documentation/platform/gateways/overview.mdx new file mode 100644 index 000000000..d263dc278 --- /dev/null +++ b/docs/documentation/platform/gateways/overview.mdx @@ -0,0 +1,81 @@ +--- +title: "Gateway" +sidebarTitle: "Overview" +description: "How to access private network resources from Infisical" +--- + +The Infisical Gateway provides secure access to private resources within your network without needing direct inbound connections to your environment. +This method keeps your resources fully protected from external access while enabling Infisical to securely interact with resources like databases. +Common use cases include generating dynamic credentials or rotating credentials for private databases. + + + **Note:** Gateway is a paid feature. - **Infisical Cloud users:** Gateway is + available under the **Enterprise Tier**. - **Self-Hosted Infisical:** Please + contact [sales@infisical.com](mailto:sales@infisical.com) to purchase an + enterprise license. + + +## How It Works + +The Gateway serves as a secure intermediary that facilitates direct communication between the Infisical server and your private network. +It’s a lightweight daemon packaged within the Infisical CLI, making it easy to deploy and manage. Once set up, the Gateway establishes a connection with a relay server, ensuring that all communication between Infisical and your Gateway is fully end-to-end encrypted. +This setup guarantees that only the platform and your Gateway can decrypt the transmitted information, keeping communication with your resources secure, private and isolated. + +## Deployment + +The Infisical Gateway is seamlessly integrated into the Infisical CLI under the `gateway` command, making it simple to deploy and manage. +You can install the Gateway in all the same ways you install the Infisical CLI—whether via npm, Docker, or a binary. +For detailed installation instructions, refer to the Infisical [CLI Installation instructions](/cli/overview). + +To function, the Gateway must authenticate with Infisical. This requires a machine identity configured with the appropriate permissions to create and manage a Gateway. +Once authenticated, the Gateway establishes a secure connection with Infisical to allow your private resources to be reachable. + +### Deployment process + + + + 1. Navigate to **Organization Access Control** in your Infisical dashboard. + 2. Create a dedicated machine identity for your Gateway. + 3. **Best Practice:** Assign a unique identity to each Gateway for better security and management. + ![Create Gateway Identity](../../../images/platform/gateways/create-identity-for-gateway.png) + + + + You'll need to choose an authentication method to initiate communication with Infisical. View the available machine identity authentication methods [here](/documentation/platform/identities/machine-identities). + + + + Use the Infisical CLI to deploy the Gateway. You can log in with your machine identity and start the Gateway in one command. The example below demonstrates how to deploy the Gateway using the Universal Auth method: + ```bash + infisical gateway --token $(infisical login --method=universal-auth --client-id=<> --client-secret=<> --plain) + ``` + Alternatively, if you already have the token, use it directly with the `--token` flag: + ```bash + infisical gateway --token + ``` + Or set it as an environment variable: + ```bash + export INFISICAL_TOKEN= + infisical gateway + ``` + + Ensure the deployed Gateway has network access to the private resources you intend to connect with Infisical. + + + + + To confirm your Gateway is working, check the deployment status by looking for the message **"Gateway started successfully"** in the Gateway logs. This indicates the Gateway is running properly. Next, verify its registration by opening your Infisical dashboard, navigating to **Organization Access Control**, and selecting the **Gateways** tab. Your newly deployed Gateway should appear in the list. + ![Gateway List](../../../images/platform/gateways/gateway-list.png) + + + + To enable Infisical features like dynamic secrets or secret rotation to access private resources through the Gateway, you need to link the Gateway to the relevant projects. + + Start by accessing the **Gateway settings** then locate the Gateway in the list, click the options menu (**:**), and select **Edit Details**. + ![Edit Gateway Option](../../../images/platform/gateways/edit-gateway.png) + In the edit modal that appears, choose the projects you want the Gateway to access and click **Save** to confirm your selections. + ![Project Assignment Modal](../../../images/platform/gateways/assign-project.png) + Once added to a project, the Gateway becomes available for use by any feature that supports Gateways within that project. + + + diff --git a/docs/images/platform/gateways/assign-project.png b/docs/images/platform/gateways/assign-project.png new file mode 100644 index 000000000..a1ff61909 Binary files /dev/null and b/docs/images/platform/gateways/assign-project.png differ diff --git a/docs/images/platform/gateways/create-identity-for-gateway.png b/docs/images/platform/gateways/create-identity-for-gateway.png new file mode 100644 index 000000000..d7ef6b02a Binary files /dev/null and b/docs/images/platform/gateways/create-identity-for-gateway.png differ diff --git a/docs/images/platform/gateways/dynamic-secret.png b/docs/images/platform/gateways/dynamic-secret.png new file mode 100644 index 000000000..bf742413e Binary files /dev/null and b/docs/images/platform/gateways/dynamic-secret.png differ diff --git a/docs/images/platform/gateways/edit-gateway.png b/docs/images/platform/gateways/edit-gateway.png new file mode 100644 index 000000000..04ef2a7d2 Binary files /dev/null and b/docs/images/platform/gateways/edit-gateway.png differ diff --git a/docs/images/platform/gateways/gateway-list.png b/docs/images/platform/gateways/gateway-list.png new file mode 100644 index 000000000..11f8206fe Binary files /dev/null and b/docs/images/platform/gateways/gateway-list.png differ diff --git a/docs/mint.json b/docs/mint.json index 62e40e1c9..9a355bcdf 100644 --- a/docs/mint.json +++ b/docs/mint.json @@ -201,6 +201,10 @@ "documentation/platform/dynamic-secrets/totp" ] }, + { + "group": "Gateway", + "pages": ["documentation/platform/gateways/overview"] + }, "documentation/platform/project-templates", { "group": "Workflow Integrations", diff --git a/frontend/public/lotties/gateway.json b/frontend/public/lotties/gateway.json new file mode 100644 index 000000000..d444658a4 --- /dev/null +++ b/frontend/public/lotties/gateway.json @@ -0,0 +1 @@ +{"v":"5.7.5","fr":100,"ip":0,"op":667,"w":200,"h":200,"nm":"Comp 1","ddd":0,"metadata":{},"assets":[],"layers":[{"ddd":0,"ind":12345679,"ty":4,"nm":"Group Layer 8","sr":1,"ks":{"p":{"a":0,"k":[146,185.75409836065575,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[20.491803278688526,20.491803278688526,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ty":"gr","it":[{"ty":"gr","it":[{"ty":"sh","d":1,"ks":{"a":0,"k":{"c":true,"v":[[220.741,37.184],[225.501,35.896],[228.749,32.36800000000001],[229.981,27.216000000000008],[228.749,22.12],[225.501,18.592],[220.741,17.304],[215.981,18.592],[212.677,22.12],[211.501,27.216000000000008],[212.677,32.36800000000001],[215.981,35.896],[220.741,37.184],[220.741,37.184],[220.741,37.184]],"i":[[0,0],[-1.380999999999972,0.8586999999999989],[-0.7839999999999918,1.493299999999991],[0,1.903999999999996],[0.8220000000000027,1.493299999999991],[1.382000000000062,0.8586999999999989],[1.79200000000003,0],[1.418999999999983,-0.8586999999999989],[0.8220000000000027,-1.493300000000005],[0,-1.904000000000011],[-0.7839999999999918,-1.5307000000000102],[-1.380999999999972,-0.8586999999999989],[-1.754000000000019,0],[0,0],[0,0]],"o":[[1.79200000000003,0],[1.382000000000062,-0.8586999999999989],[0.8220000000000027,-1.5307000000000102],[0,-1.904000000000011],[-0.7839999999999918,-1.493300000000005],[-1.380999999999972,-0.8586999999999989],[-1.754000000000019,0],[-1.380999999999972,0.8586999999999989],[-0.7839999999999918,1.493299999999991],[0,1.903999999999996],[0.8220000000000027,1.493299999999991],[1.418999999999983,0.8586999999999989],[0,0],[0,0],[0,0]]}}},{"ty":"tm","s":{"a":0,"k":0,"ix":2},"e":{"a":0,"k":100,"ix":2},"o":{"a":0,"k":0,"ix":2},"m":1},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[100,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}}]},{"ty":"gr","it":[{"ty":"sh","d":1,"ks":{"a":0,"k":{"c":true,"v":[[221.357,43.06400000000001],[214.917,41.608],[210.49300000000005,37.408],[211.221,36.232],[211.221,42.392],[205.173,42.392],[205.173,0],[211.501,0],[211.501,18.36800000000001],[210.49300000000005,16.912000000000006],[214.973,12.88],[221.357,11.424000000000007],[229.085,13.49600000000001],[234.51700000000005,19.152],[236.533,27.216000000000008],[234.51700000000005,35.28],[229.141,40.992],[221.357,43.06400000000001],[221.357,43.06400000000001],[221.357,43.06400000000001]],"i":[[0,0],[1.942000000000007,0.9706999999999937],[1.045999999999935,1.829300000000003],[-0.2426666666666506,0.3919999999999959],[0,-2.053333333333327],[2.015999999999963,0],[0,14.13066666666667],[-2.109333333333325,0],[0,-6.122666666666674],[0.3360000000000127,0.4853333333333296],[-1.865999999999985,0.9707000000000079],[-2.38900000000001,0],[-2.277000000000044,-1.3813000000000102],[-1.30600000000004,-2.389300000000006],[0,-2.986699999999999],[1.343999999999937,-2.389300000000006],[2.27800000000002,-1.4187000000000012],[2.912000000000035,0],[0,0],[0,0]],"o":[[-2.351999999999975,0],[-1.903999999999996,-0.9707000000000079],[0.2426666666666506,-0.3919999999999959],[0,2.053333333333327],[-2.015999999999963,0],[0,-14.13066666666667],[2.109333333333325,0],[0,6.122666666666667],[-0.3360000000000127,-0.4853333333333296],[1.120000000000005,-1.717300000000009],[1.867000000000075,-0.9706999999999937],[2.875,0],[2.314999999999941,1.381299999999996],[1.343999999999937,2.389300000000006],[0,2.986699999999999],[-1.30600000000004,2.389300000000006],[-2.27699999999993,1.381299999999996],[0,0],[0,0],[0,0]]}}},{"ty":"tm","s":{"a":0,"k":0,"ix":2},"e":{"a":0,"k":100,"ix":2},"o":{"a":0,"k":0,"ix":2},"m":1},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[100,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}}]},{"ty":"gr","it":[{"ty":"sh","d":1,"ks":{"a":0,"k":{"c":true,"v":[[181.87,43.06400000000001],[176.438,42],[172.854,38.976],[171.566,34.384],[172.63,29.960000000000008],[176.046,26.656000000000006],[181.814,24.752],[192.342,23.016000000000005],[192.342,28],[183.046,29.624],[179.35,31.248],[178.174,34.16],[179.462,37.016000000000005],[182.878,38.08],[187.35799999999995,36.96000000000001],[190.38199999999995,33.992],[191.446,29.792],[191.446,22.008],[189.766,18.36800000000001],[185.398,16.912000000000006],[180.974,18.256],[178.23,21.616],[172.966,18.98400000000001],[175.71,15.064000000000007],[180.134,12.376],[185.566,11.424000000000007],[191.894,12.768],[196.206,16.52],[197.774,22.008],[197.774,42.392],[191.726,42.392],[191.726,36.904],[193.014,37.072],[190.27,40.264],[186.518,42.336],[181.87,43.06400000000001],[181.87,43.06400000000001],[181.87,43.06400000000001]],"i":[[0,0],[1.567999999999984,0.7092999999999989],[0.8589999999999236,1.2693000000000012],[0,1.7547],[-0.7089999999999463,1.306699999999992],[-1.530000000000086,0.8960000000000008],[-2.313999999999965,0.3733000000000004],[-3.509333333333302,0.5786666666666633],[0,-1.661333333333332],[3.098666666666645,-0.541333333333327],[0.7839999999999918,-0.784000000000006],[0,-1.194699999999997],[-0.8579999999999472,-0.7467000000000041],[-1.381000000000085,0],[-1.268999999999892,0.7466999999999899],[-0.7089999999999463,1.2319999999999993],[0,1.530699999999996],[0,2.594666666666669],[1.120000000000005,0.9332999999999885],[1.829999999999927,0],[1.269999999999982,-0.8960000000000008],[0.5979999999999563,-1.381299999999996],[1.754666666666708,0.8773333333333255],[-1.269000000000005,1.11999999999999],[-1.680000000000064,0.6346999999999952],[-1.903999999999996,0],[-1.828999999999951,-0.8960000000000008],[-1.008000000000038,-1.6053],[0,-2.090699999999998],[0,-6.794666666666672],[2.015999999999963,0],[0,1.829333333333338],[-0.4293333333333749,-0.05599999999999739],[1.120000000000005,-0.8959999999999866],[1.418999999999983,-0.4852999999999952],[1.717999999999961,0],[0,0],[0,0]],"o":[[-2.052999999999997,0],[-1.529999999999973,-0.7467000000000041],[-0.8580000000000609,-1.306699999999992],[0,-1.642700000000005],[0.7469999999999573,-1.306700000000006],[1.530999999999949,-0.8960000000000008],[3.509333333333302,-0.5786666666666633],[0,1.661333333333332],[-3.098666666666645,0.541333333333327],[-1.680000000000064,0.2987000000000108],[-0.7839999999999918,0.7467000000000041],[0,1.157300000000006],[0.8959999999999582,0.7092999999999989],[1.717999999999961,0],[1.307000000000016,-0.7467000000000041],[0.7100000000000364,-1.2693000000000012],[0,-2.594666666666669],[0,-1.493299999999991],[-1.081999999999994,-0.9707000000000079],[-1.680000000000064,0],[-1.232000000000085,0.8586999999999989],[-1.754666666666708,-0.8773333333333255],[0.5599999999999454,-1.493300000000005],[1.269999999999982,-1.157300000000006],[1.717999999999961,-0.6347000000000094],[2.389999999999986,0],[1.866999999999962,0.8960000000000008],[1.045999999999935,1.568000000000012],[0,6.794666666666672],[-2.015999999999963,0],[0,-1.829333333333338],[0.4293333333333749,0.05599999999999739],[-0.70900000000006,1.2319999999999993],[-1.081999999999994,0.8960000000000008],[-1.380999999999972,0.4853000000000094],[0,0],[0,0],[0,0]]}}},{"ty":"tm","s":{"a":0,"k":0,"ix":2},"e":{"a":0,"k":100,"ix":2},"o":{"a":0,"k":0,"ix":2},"m":1},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[100,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}}]},{"ty":"gr","it":[{"ty":"sh","d":1,"ks":{"a":0,"k":{"c":true,"v":[[159.072,42.392],[159.072,0],[165.4,0],[165.4,42.392],[159.072,42.392],[159.072,42.392],[159.072,42.392]],"i":[[0,0],[0,14.13066666666667],[-2.109333333333325,0],[0,-14.13066666666667],[2.109333333333325,0],[0,0],[0,0]],"o":[[0,-14.13066666666667],[2.109333333333325,0],[0,14.13066666666667],[-2.109333333333325,0],[0,0],[0,0],[0,0]]}}},{"ty":"tm","s":{"a":0,"k":0,"ix":2},"e":{"a":0,"k":100,"ix":2},"o":{"a":0,"k":0,"ix":2},"m":1},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[100,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}}]},{"ty":"gr","it":[{"ty":"sh","d":1,"ks":{"a":0,"k":{"c":true,"v":[[138.952,43.06400000000001],[130.888,40.992],[125.456,35.28],[123.496,27.16],[125.456,19.040000000000006],[130.832,13.49600000000001],[138.448,11.424000000000007],[144.552,12.600000000000009],[149.088,15.848],[151.888,20.49600000000001],[152.896,26.096],[152.84,27.608],[152.616,29.064000000000007],[128.48,29.064000000000007],[128.48,24.024],[149.032,24.024],[146.008,26.320000000000007],[145.616,21.448000000000008],[142.816,18.032],[138.448,16.744],[133.968,18.032],[130.944,21.616],[130.104,27.216000000000008],[130.944,32.592],[134.192,36.176],[139.008,37.464],[143.65599999999995,36.232],[146.736,33.040000000000006],[151.888,35.56],[149.088,39.42400000000001],[144.60799999999995,42.11200000000001],[138.952,43.06400000000001],[138.952,43.06400000000001],[138.952,43.06400000000001]],"i":[[0,0],[2.351999999999975,1.381299999999996],[1.307000000000016,2.389300000000006],[0,2.986699999999999],[-1.307000000000016,2.35199999999999],[-2.240000000000009,1.343999999999994],[-2.836999999999989,0],[-1.79200000000003,-0.784000000000006],[-1.231999999999971,-1.381299999999996],[-0.6349999999999909,-1.754700000000014],[0,-1.978700000000003],[0.03699999999992087,-0.5227000000000004],[0.1119999999999663,-0.4480000000000075],[8.04533333333336,0],[0,1.680000000000007],[-6.850666666666712,0],[1.008000000000038,-0.7653333333333308],[0.6349999999999909,1.4187000000000012],[1.269000000000005,0.8213000000000079],[1.680000000000064,0],[1.307000000000016,-0.8586999999999989],[0.70900000000006,-1.567999999999998],[-0.1490000000000009,-2.202700000000007],[-0.7469999999999573,-1.530699999999996],[-1.380999999999972,-0.8586999999999989],[-1.79200000000003,0],[-1.268999999999892,0.8213000000000079],[-0.7469999999999573,1.306699999999992],[-1.717333333333386,-0.8400000000000034],[1.269000000000005,-1.157300000000006],[1.755000000000109,-0.6720000000000113],[2.052999999999997,0],[0,0],[0,0]],"o":[[-3.024000000000001,0],[-2.315000000000055,-1.4187000000000012],[-1.307000000000016,-2.426699999999997],[0,-3.061299999999989],[1.343999999999937,-2.352000000000004],[2.240000000000009,-1.3813000000000102],[2.277000000000044,0],[1.79200000000003,0.7839999999999918],[1.232000000000085,1.344000000000008],[0.6720000000000255,1.7547],[0,0.4852999999999952],[-0.03700000000003456,0.5227000000000004],[-8.04533333333336,0],[0,-1.680000000000007],[6.850666666666712,0],[-1.008000000000038,0.7653333333333308],[0.3729999999999336,-1.829300000000003],[-0.59699999999998,-1.456000000000003],[-1.232000000000085,-0.8586999999999989],[-1.67999999999995,0],[-1.306999999999903,0.8213000000000079],[-0.7089999999999463,1.530699999999996],[-0.1870000000000118,2.053299999999993],[0.7839999999999918,1.53070000000001],[1.418999999999983,0.8586999999999989],[1.828999999999951,0],[1.307000000000016,-0.8212999999999937],[1.717333333333386,0.8400000000000034],[-0.59699999999998,1.4187000000000012],[-1.231999999999971,1.11999999999999],[-1.716999999999985,0.6346999999999952],[0,0],[0,0],[0,0]]}}},{"ty":"tm","s":{"a":0,"k":0,"ix":2},"e":{"a":0,"k":100,"ix":2},"o":{"a":0,"k":0,"ix":2},"m":1},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[100,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}}]},{"ty":"gr","it":[{"ty":"sh","d":1,"ks":{"a":0,"k":{"c":true,"v":[[111.001,7.951999999999998],[111.001,0.6720000000000041],[117.329,0.6720000000000041],[117.329,7.951999999999998],[111.001,7.951999999999998],[111.001,7.951999999999998],[111.001,7.951999999999998]],"i":[[0,0],[0,2.426666666666662],[-2.109333333333325,0],[0,-2.426666666666662],[2.109333333333325,0],[0,0],[0,0]],"o":[[0,-2.426666666666662],[2.109333333333325,0],[0,2.426666666666662],[-2.109333333333325,0],[0,0],[0,0],[0,0]]}}},{"ty":"tm","s":{"a":0,"k":0,"ix":2},"e":{"a":0,"k":100,"ix":2},"o":{"a":0,"k":0,"ix":2},"m":1},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[100,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}}]},{"ty":"gr","it":[{"ty":"sh","d":1,"ks":{"a":0,"k":{"c":true,"v":[[111.001,42.392],[111.001,12.096],[117.329,12.096],[117.329,42.392],[111.001,42.392],[111.001,42.392],[111.001,42.392]],"i":[[0,0],[0,10.09866666666667],[-2.109333333333325,0],[0,-10.09866666666667],[2.109333333333325,0],[0,0],[0,0]],"o":[[0,-10.09866666666666],[2.109333333333325,0],[0,10.09866666666666],[-2.109333333333325,0],[0,0],[0,0],[0,0]]}}},{"ty":"tm","s":{"a":0,"k":0,"ix":2},"e":{"a":0,"k":100,"ix":2},"o":{"a":0,"k":0,"ix":2},"m":1},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[100,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}}]},{"ty":"gr","it":[{"ty":"sh","d":1,"ks":{"a":0,"k":{"c":true,"v":[[101.41,42.72800000000001],[94.01800000000003,40.040000000000006],[91.38599999999997,32.48],[91.38599999999997,17.808000000000007],[86.06600000000003,17.808000000000007],[86.06600000000003,12.096],[86.90599999999995,12.096],[90.21000000000004,10.864],[91.38599999999997,7.504000000000005],[91.38599999999997,5.152000000000001],[97.71400000000006,5.152000000000001],[97.71400000000006,12.096],[104.602,12.096],[104.602,17.808000000000007],[97.71400000000006,17.808000000000007],[97.71400000000006,32.2],[98.21799999999996,34.888000000000005],[99.84199999999998,36.568],[102.754,37.128],[103.76200000000006,37.072],[104.826,36.96000000000001],[104.826,42.392],[103.09,42.616],[101.41,42.72800000000001],[101.41,42.72800000000001],[101.41,42.72800000000001]],"i":[[0,0],[1.754999999999995,1.792000000000002],[0,3.248000000000005],[0,4.890666666666661],[1.773333333333312,0],[0,1.903999999999996],[-0.2799999999999727,0],[-0.7839999999999918,0.8212999999999937],[0,1.4187000000000012],[0,0.7839999999999989],[-2.109333333333325,0],[0,-2.314666666666668],[-2.295999999999935,0],[0,-1.903999999999996],[2.295999999999935,0],[0,-4.797333333333327],[-0.3360000000000127,-0.7467000000000041],[-0.7469999999999573,-0.4106999999999914],[-1.19500000000005,0],[-0.3730000000000473,0.03730000000000189],[-0.3360000000000127,0.03729999999998768],[0,-1.810666666666663],[0.6349999999999909,-0.07469999999999288],[0.4850000000000136,0],[0,0],[0,0]],"o":[[-3.173000000000002,0],[-1.754999999999995,-1.792000000000002],[0,-4.890666666666661],[-1.773333333333312,0],[0,-1.903999999999996],[0.2799999999999727,0],[1.419000000000096,0],[0.7839999999999918,-0.8213000000000079],[0,-0.7839999999999989],[2.109333333333325,0],[0,2.314666666666668],[2.295999999999935,0],[0,1.903999999999996],[-2.295999999999935,0],[0,4.797333333333327],[0,1.045299999999997],[0.3360000000000127,0.7092999999999989],[0.7470000000000709,0.3733000000000004],[0.2989999999999782,0],[0.3729999999999336,-0.03730000000000189],[0,1.810666666666663],[-0.5230000000000246,0.0747000000000071],[-0.6349999999999909,0.0747000000000071],[0,0],[0,0],[0,0]]}}},{"ty":"tm","s":{"a":0,"k":0,"ix":2},"e":{"a":0,"k":100,"ix":2},"o":{"a":0,"k":0,"ix":2},"m":1},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[100,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}}]},{"ty":"gr","it":[{"ty":"sh","d":1,"ks":{"a":0,"k":{"c":true,"v":[[78.71499999999997,42.72800000000001],[71.32299999999998,40.040000000000006],[68.69100000000003,32.48],[68.69100000000003,17.808000000000007],[63.37099999999998,17.808000000000007],[63.37099999999998,12.096],[64.21100000000001,12.096],[67.51499999999999,10.864],[68.69100000000003,7.504000000000005],[68.69100000000003,5.152000000000001],[75.019,5.152000000000001],[75.019,12.096],[81.90700000000004,12.096],[81.90700000000004,17.808000000000007],[75.019,17.808000000000007],[75.019,32.2],[75.52300000000002,34.888000000000005],[77.14699999999999,36.568],[80.05900000000003,37.128],[81.06700000000001,37.072],[82.13099999999997,36.96000000000001],[82.13099999999997,42.392],[80.39499999999998,42.616],[78.71499999999997,42.72800000000001],[78.71499999999997,42.72800000000001],[78.71499999999997,42.72800000000001]],"i":[[0,0],[1.754000000000019,1.792000000000002],[0,3.248000000000005],[0,4.890666666666661],[1.773333333333369,0],[0,1.903999999999996],[-0.2800000000000296,0],[-0.7839999999999918,0.8212999999999937],[0,1.4187000000000012],[0,0.7839999999999989],[-2.109333333333325,0],[0,-2.314666666666668],[-2.295999999999992,0],[0,-1.903999999999996],[2.295999999999992,0],[0,-4.797333333333327],[-0.3360000000000127,-0.7467000000000041],[-0.7470000000000141,-0.4106999999999914],[-1.19500000000005,0],[-0.3740000000000236,0.03730000000000189],[-0.3360000000000127,0.03729999999998768],[0,-1.810666666666663],[0.6340000000000146,-0.07469999999999288],[0.4850000000000136,0],[0,0],[0,0]],"o":[[-3.173999999999978,0],[-1.754999999999995,-1.792000000000002],[0,-4.890666666666661],[-1.773333333333369,0],[0,-1.903999999999996],[0.2800000000000296,0],[1.418000000000006,0],[0.7839999999999918,-0.8213000000000079],[0,-0.7839999999999989],[2.109333333333325,0],[0,2.314666666666668],[2.295999999999992,0],[0,1.903999999999996],[-2.295999999999992,0],[0,4.797333333333327],[0,1.045299999999997],[0.3359999999999559,0.7092999999999989],[0.7460000000000377,0.3733000000000004],[0.297999999999945,0],[0.3730000000000473,-0.03730000000000189],[0,1.810666666666663],[-0.5230000000000246,0.0747000000000071],[-0.6349999999999909,0.0747000000000071],[0,0],[0,0],[0,0]]}}},{"ty":"tm","s":{"a":0,"k":0,"ix":2},"e":{"a":0,"k":100,"ix":2},"o":{"a":0,"k":0,"ix":2},"m":1},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[100,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}}]},{"ty":"gr","it":[{"ty":"sh","d":1,"ks":{"a":0,"k":{"c":true,"v":[[44.18799999999999,37.184],[48.94799999999998,35.896],[52.19600000000003,32.36800000000001],[53.428,27.216000000000008],[52.19600000000003,22.12],[48.94799999999998,18.592],[44.18799999999999,17.304],[39.428,18.592],[36.12400000000002,22.12],[34.94799999999998,27.216000000000008],[36.12400000000002,32.36800000000001],[39.428,35.896],[44.18799999999999,37.184],[44.18799999999999,37.184],[44.18799999999999,37.184]],"i":[[0,0],[-1.381999999999948,0.8586999999999989],[-0.7840000000000487,1.493299999999991],[0,1.903999999999996],[0.8209999999999695,1.493299999999991],[1.381000000000029,0.8586999999999989],[1.79200000000003,0],[1.418000000000006,-0.8586999999999989],[0.8209999999999695,-1.493300000000005],[0,-1.904000000000011],[-0.7840000000000487,-1.5307000000000102],[-1.382000000000005,-0.8586999999999989],[-1.754999999999995,0],[0,0],[0,0]],"o":[[1.79200000000003,0],[1.381000000000029,-0.8586999999999989],[0.8209999999999695,-1.5307000000000102],[0,-1.904000000000011],[-0.7840000000000487,-1.493300000000005],[-1.381999999999948,-0.8586999999999989],[-1.754999999999995,0],[-1.382000000000005,0.8586999999999989],[-0.7840000000000487,1.493299999999991],[0,1.903999999999996],[0.8209999999999695,1.493299999999991],[1.418000000000006,0.8586999999999989],[0,0],[0,0],[0,0]]}}},{"ty":"tm","s":{"a":0,"k":0,"ix":2},"e":{"a":0,"k":100,"ix":2},"o":{"a":0,"k":0,"ix":2},"m":1},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[100,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}}]},{"ty":"gr","it":[{"ty":"sh","d":1,"ks":{"a":0,"k":{"c":true,"v":[[44.18799999999999,43.06400000000001],[36.18000000000001,40.992],[30.46800000000002,35.336],[28.33999999999997,27.216000000000008],[30.46800000000002,19.096],[36.18000000000001,13.49600000000001],[44.18799999999999,11.424000000000007],[52.19600000000003,13.49600000000001],[57.85199999999998,19.096],[59.98000000000002,27.216000000000008],[57.85199999999998,35.392],[52.139999999999986,41.048],[44.18799999999999,43.06400000000001],[44.18799999999999,43.06400000000001],[44.18799999999999,43.06400000000001]],"i":[[0,0],[2.425999999999988,1.381299999999996],[1.418000000000006,2.389300000000006],[0,3.024000000000001],[-1.41900000000004,2.352000000000004],[-2.389999999999986,1.343999999999994],[-2.949999999999989,0],[-2.352000000000032,-1.3813000000000102],[-1.381999999999948,-2.389300000000006],[0,-3.061300000000003],[1.418000000000006,-2.389299999999992],[2.38900000000001,-1.381299999999996],[2.912000000000035,0],[0,0],[0,0]],"o":[[-2.911999999999978,0],[-2.389999999999986,-1.381299999999996],[-1.41900000000004,-2.389299999999992],[0,-3.061300000000003],[1.418000000000006,-2.389300000000006],[2.38900000000001,-1.3813000000000102],[2.98599999999999,0],[2.388999999999953,1.343999999999994],[1.418000000000006,2.352000000000004],[0,3.061299999999989],[-1.418999999999983,2.389300000000006],[-2.389999999999986,1.343999999999994],[0,0],[0,0],[0,0]]}}},{"ty":"tm","s":{"a":0,"k":0,"ix":2},"e":{"a":0,"k":100,"ix":2},"o":{"a":0,"k":0,"ix":2},"m":1},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[100,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}}]},{"ty":"gr","it":[{"ty":"sh","d":1,"ks":{"a":0,"k":{"c":true,"v":[[0,42.392],[0,0.6720000000000041],[6.608000000000004,0.6720000000000041],[6.608000000000004,36.512],[24.639999999999986,36.512],[24.639999999999986,42.392],[0,42.392],[0,42.392],[0,42.392]],"i":[[0,0],[0,13.90666666666666],[-2.202666666666687,0],[0,-11.94666666666666],[-6.01066666666668,0],[0,-1.959999999999994],[8.21333333333331,0],[0,0],[0,0]],"o":[[0,-13.90666666666667],[2.202666666666687,0],[0,11.94666666666667],[6.01066666666668,0],[0,1.959999999999994],[-8.21333333333331,0],[0,0],[0,0],[0,0]]}}},{"ty":"tm","s":{"a":0,"k":0,"ix":2},"e":{"a":0,"k":100,"ix":2},"o":{"a":0,"k":0,"ix":2},"m":1},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[100,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}}]},{"ty":"fl","c":{"a":0,"k":[1,1,1],"ix":2},"o":{"a":0,"k":100,"ix":2},"r":1,"bm":0},{"ty":"tr","p":{"a":0,"k":[98.08047485351562,-21.67217254638672],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[99.99999403953552,99.99999403953552],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}}]},{"ty":"gr","it":[{"ty":"gr","it":[{"ty":"sh","d":1,"ks":{"a":0,"k":{"c":true,"v":[[246.681,42.392],[246.681,0],[253.009,0],[253.009,18.032],[252.001,17.248],[255.585,12.936000000000007],[261.297,11.424000000000007],[267.23299999999995,12.88],[271.265,16.912000000000006],[272.721,22.792],[272.721,42.392],[266.449,42.392],[266.449,24.528000000000006],[265.553,20.664],[263.201,18.2],[259.729,17.304],[256.25699999999995,18.2],[253.849,20.664],[253.009,24.528000000000006],[253.009,42.392],[246.681,42.392],[246.681,42.392],[246.681,42.392]],"i":[[0,0],[0,14.13066666666667],[-2.109333333333325,0],[0,-6.010666666666665],[0.3360000000000127,0.2613333333333259],[-1.643000000000029,0.9706999999999937],[-2.166000000000054,0],[-1.717999999999961,-0.9706999999999937],[-0.9710000000000036,-1.717300000000009],[0,-2.202699999999993],[0,-6.533333333333331],[2.090666666666721,0],[0,5.954666666666668],[0.59699999999998,1.045299999999997],[1.007999999999925,0.5600000000000023],[1.305999999999926,0],[1.045000000000073,-0.5973000000000042],[0.59699999999998,-1.082700000000003],[0,-1.493300000000005],[0,-5.954666666666668],[2.109333333333325,0],[0,0],[0,0]],"o":[[0,-14.13066666666667],[2.109333333333325,0],[0,6.010666666666665],[-0.3360000000000127,-0.2613333333333259],[0.7459999999999809,-1.903999999999996],[1.641999999999967,-1.0080000000000098],[2.240000000000009,0],[1.717000000000098,0.9707000000000079],[0.9700000000000273,1.717299999999994],[0,6.533333333333331],[-2.090666666666721,0],[0,-5.954666666666668],[0,-1.5307000000000102],[-0.5599999999999454,-1.082700000000003],[-1.008000000000038,-0.5973000000000042],[-1.270000000000095,0],[-1.007999999999953,0.5600000000000023],[-0.5600000000000023,1.082700000000003],[0,5.954666666666668],[-2.109333333333325,0],[0,0],[0,0],[0,0]]}}},{"ty":"tm","s":{"a":0,"k":0,"ix":2},"e":{"a":0,"k":100,"ix":2},"o":{"a":0,"k":0,"ix":2},"m":1},{"ty":"tr","p":{"a":0,"k":[-354.5325317382812,-77.50520324707031],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[100,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}}]},{"ty":"gr","it":[{"ty":"sh","d":1,"ks":{"a":0,"k":{"c":true,"v":[[237.089,42.72800000000001],[229.697,40.040000000000006],[227.065,32.48],[227.065,17.808000000000007],[221.745,17.808000000000007],[221.745,12.096],[222.585,12.096],[225.889,10.864],[227.065,7.504000000000005],[227.065,5.152000000000001],[233.393,5.152000000000001],[233.393,12.096],[240.281,12.096],[240.281,17.808000000000007],[233.393,17.808000000000007],[233.393,32.2],[233.897,34.888000000000005],[235.521,36.568],[238.433,37.128],[239.441,37.072],[240.505,36.96000000000001],[240.505,42.392],[238.769,42.616],[237.089,42.72800000000001],[237.089,42.72800000000001],[237.089,42.72800000000001]],"i":[[0,0],[1.755000000000052,1.792000000000002],[0,3.248000000000005],[0,4.890666666666661],[1.773333333333369,0],[0,1.903999999999996],[-0.2800000000000296,0],[-0.7839999999999918,0.8212999999999937],[0,1.4187000000000012],[0,0.7839999999999989],[-2.109333333333325,0],[0,-2.314666666666668],[-2.295999999999992,0],[0,-1.903999999999996],[2.295999999999992,0],[0,-4.797333333333327],[-0.3360000000000127,-0.7467000000000041],[-0.7459999999999809,-0.4106999999999914],[-1.194000000000017,0],[-0.3729999999999905,0.03730000000000189],[-0.3360000000000127,0.03729999999998768],[0,-1.810666666666663],[0.6350000000000477,-0.07469999999999288],[0.48599999999999,0],[0,0],[0,0]],"o":[[-3.173000000000002,0],[-1.753999999999962,-1.792000000000002],[0,-4.890666666666661],[-1.773333333333369,0],[0,-1.903999999999996],[0.2800000000000296,0],[1.418999999999983,0],[0.7839999999999918,-0.8213000000000079],[0,-0.7839999999999989],[2.109333333333325,0],[0,2.314666666666668],[2.295999999999992,0],[0,1.903999999999996],[-2.295999999999992,0],[0,4.797333333333327],[0,1.045299999999997],[0.3359999999999559,0.7092999999999989],[0.7470000000000141,0.3733000000000004],[0.2989999999999782,0],[0.3740000000000236,-0.03730000000000189],[0,1.810666666666663],[-0.5220000000000482,0.0747000000000071],[-0.6339999999999577,0.0747000000000071],[0,0],[0,0],[0,0]]}}},{"ty":"tm","s":{"a":0,"k":0,"ix":2},"e":{"a":0,"k":100,"ix":2},"o":{"a":0,"k":0,"ix":2},"m":1},{"ty":"tr","p":{"a":0,"k":[-354.5325317382812,-77.50520324707031],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[100,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}}]},{"ty":"gr","it":[{"ty":"sh","d":1,"ks":{"a":0,"k":{"c":true,"v":[[210.259,7.951999999999998],[210.259,0.6720000000000041],[216.587,0.6720000000000041],[216.587,7.951999999999998],[210.259,7.951999999999998],[210.259,7.951999999999998],[210.259,7.951999999999998]],"i":[[0,0],[0,2.426666666666662],[-2.109333333333325,0],[0,-2.426666666666662],[2.109333333333325,0],[0,0],[0,0]],"o":[[0,-2.426666666666662],[2.109333333333325,0],[0,2.426666666666662],[-2.109333333333325,0],[0,0],[0,0],[0,0]]}}},{"ty":"tm","s":{"a":0,"k":0,"ix":2},"e":{"a":0,"k":100,"ix":2},"o":{"a":0,"k":0,"ix":2},"m":1},{"ty":"tr","p":{"a":0,"k":[-354.5325317382812,-77.50520324707031],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[100,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}}]},{"ty":"gr","it":[{"ty":"sh","d":1,"ks":{"a":0,"k":{"c":true,"v":[[210.259,42.392],[210.259,12.096],[216.587,12.096],[216.587,42.392],[210.259,42.392],[210.259,42.392],[210.259,42.392]],"i":[[0,0],[0,10.09866666666667],[-2.109333333333325,0],[0,-10.09866666666667],[2.109333333333325,0],[0,0],[0,0]],"o":[[0,-10.09866666666666],[2.109333333333325,0],[0,10.09866666666666],[-2.109333333333325,0],[0,0],[0,0],[0,0]]}}},{"ty":"tm","s":{"a":0,"k":0,"ix":2},"e":{"a":0,"k":100,"ix":2},"o":{"a":0,"k":0,"ix":2},"m":1},{"ty":"tr","p":{"a":0,"k":[-354.5325317382812,-77.50520324707031],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[100,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}}]},{"ty":"gr","it":[{"ty":"sh","d":1,"ks":{"a":0,"k":{"c":true,"v":[[169.688,42.392],[159.272,12.096],[165.992,12.096],[173.944,36.232],[171.592,36.232],[179.712,12.096],[185.48,12.096],[193.544,36.232],[191.192,36.232],[199.2,12.096],[205.92,12.096],[195.448,42.392],[189.736,42.392],[181.56,17.696],[183.632,17.696],[175.456,42.392],[169.688,42.392],[169.688,42.392],[169.688,42.392]],"i":[[0,0],[3.47199999999998,10.09866666666667],[-2.240000000000009,0],[-2.650666666666666,-8.045333333333332],[0.7839999999999918,0],[-2.706666666666649,8.045333333333332],[-1.922666666666657,0],[-2.687999999999988,-8.045333333333332],[0.7839999999999918,0],[-2.669333333333327,8.045333333333332],[-2.240000000000009,0],[3.490666666666641,-10.09866666666667],[1.903999999999996,0],[2.725333333333367,8.232],[-0.6906666666666865,0],[2.72533333333331,-8.232],[1.922666666666657,0],[0,0],[0,0]],"o":[[-3.47199999999998,-10.09866666666666],[2.240000000000009,0],[2.650666666666666,8.045333333333332],[-0.7839999999999918,0],[2.706666666666649,-8.045333333333332],[1.922666666666657,0],[2.687999999999988,8.045333333333332],[-0.7839999999999918,0],[2.669333333333327,-8.045333333333332],[2.240000000000009,0],[-3.490666666666641,10.09866666666666],[-1.903999999999996,0],[-2.725333333333367,-8.232],[0.6906666666666865,0],[-2.72533333333331,8.232],[-1.922666666666657,0],[0,0],[0,0],[0,0]]}}},{"ty":"tm","s":{"a":0,"k":0,"ix":2},"e":{"a":0,"k":100,"ix":2},"o":{"a":0,"k":0,"ix":2},"m":1},{"ty":"tr","p":{"a":0,"k":[-354.5325317382812,-77.50520324707031],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[100,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}}]},{"ty":"fl","c":{"a":0,"k":[1,1,1],"ix":2},"o":{"a":0,"k":100,"ix":2},"r":1,"bm":0},{"ty":"tr","p":{"a":0,"k":[155.86146545410156,56.001014709472656],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[99.99999403953552,99.99999403953552],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}}]},{"ty":"gr","it":[{"ty":"gr","it":[{"ty":"sh","d":1,"ks":{"a":0,"k":{"c":true,"v":[[132.444,43.06400000000001],[124.38,40.992],[118.948,35.28],[116.988,27.16],[118.948,19.040000000000006],[124.324,13.49600000000001],[131.94,11.424000000000007],[138.044,12.600000000000009],[142.58,15.848],[145.38,20.49600000000001],[146.388,26.096],[146.332,27.608],[146.108,29.064000000000007],[121.972,29.064000000000007],[121.972,24.024],[142.524,24.024],[139.5,26.320000000000007],[139.108,21.448000000000008],[136.308,18.032],[131.94,16.744],[127.46,18.032],[124.436,21.616],[123.596,27.216000000000008],[124.436,32.592],[127.684,36.176],[132.5,37.464],[137.148,36.232],[140.228,33.040000000000006],[145.38,35.56],[142.58,39.42400000000001],[138.1,42.11200000000001],[132.444,43.06400000000001],[132.444,43.06400000000001],[132.444,43.06400000000001]],"i":[[0,0],[2.351999999999975,1.381299999999996],[1.305999999999983,2.389300000000006],[0,2.986699999999999],[-1.307000000000016,2.35199999999999],[-2.240000000000009,1.343999999999994],[-2.838000000000022,0],[-1.79200000000003,-0.784000000000006],[-1.232000000000028,-1.381299999999996],[-0.6350000000000477,-1.754700000000014],[0,-1.978700000000003],[0.03699999999997772,-0.5227000000000004],[0.1120000000000232,-0.4480000000000075],[8.045333333333303,0],[0,1.680000000000007],[-6.850666666666655,0],[1.007999999999981,-0.7653333333333308],[0.6340000000000146,1.4187000000000012],[1.269000000000005,0.8213000000000079],[1.67999999999995,0],[1.305999999999983,-0.8586999999999989],[0.7090000000000032,-1.567999999999998],[-0.1499999999999773,-2.202700000000007],[-0.7470000000000141,-1.530699999999996],[-1.382000000000005,-0.8586999999999989],[-1.791999999999973,0],[-1.269999999999982,0.8213000000000079],[-0.7469999999999573,1.306699999999992],[-1.717333333333329,-0.8400000000000034],[1.269000000000005,-1.157300000000006],[1.754000000000019,-0.6720000000000113],[2.052999999999997,0],[0,0],[0,0]],"o":[[-3.024000000000001,0],[-2.314999999999998,-1.4187000000000012],[-1.307000000000016,-2.426699999999997],[0,-3.061299999999989],[1.343999999999994,-2.352000000000004],[2.240000000000009,-1.3813000000000102],[2.276999999999987,0],[1.791999999999973,0.7839999999999918],[1.231999999999971,1.344000000000008],[0.6719999999999686,1.7547],[0,0.4852999999999952],[-0.03800000000001091,0.5227000000000004],[-8.045333333333303,0],[0,-1.680000000000007],[6.850666666666655,0],[-1.007999999999981,0.7653333333333308],[0.3730000000000473,-1.829300000000003],[-0.5979999999999563,-1.456000000000003],[-1.232000000000028,-0.8586999999999989],[-1.680000000000007,0],[-1.307000000000016,0.8213000000000079],[-0.7100000000000364,1.530699999999996],[-0.186999999999955,2.053299999999993],[0.7839999999999918,1.53070000000001],[1.418000000000006,0.8586999999999989],[1.829000000000008,0],[1.305999999999983,-0.8212999999999937],[1.717333333333329,0.8400000000000034],[-0.5980000000000132,1.4187000000000012],[-1.232000000000028,1.11999999999999],[-1.718000000000018,0.6346999999999952],[0,0],[0,0],[0,0]]}}},{"ty":"tm","s":{"a":0,"k":0,"ix":2},"e":{"a":0,"k":100,"ix":2},"o":{"a":0,"k":0,"ix":2},"m":1},{"ty":"tr","p":{"a":0,"k":[-211.7300415039062,-77.67320251464844],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[100,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}}]},{"ty":"gr","it":[{"ty":"sh","d":1,"ks":{"a":0,"k":{"c":true,"v":[[95.32,37.184],[100.024,35.896],[103.328,32.36800000000001],[104.56,27.216000000000008],[103.328,22.12],[100.024,18.592],[95.32,17.304],[90.56,18.592],[87.256,22.12],[86.08000000000001,27.216000000000008],[87.256,32.36800000000001],[90.50399999999999,35.896],[95.32,37.184],[95.32,37.184],[95.32,37.184]],"i":[[0,0],[-1.381,0.8586999999999989],[-0.7839999999999918,1.493299999999991],[0,1.903999999999996],[0.820999999999998,1.493299999999991],[1.419000000000011,0.8586999999999989],[1.754999999999995,0],[1.418999999999983,-0.8586999999999989],[0.7839999999999918,-1.493300000000005],[0,-1.904000000000011],[-0.7839999999999918,-1.5307000000000102],[-1.381,-0.8586999999999989],[-1.792000000000002,0],[0,0],[0,0]],"o":[[1.754999999999995,0],[1.419000000000011,-0.8586999999999989],[0.820999999999998,-1.5307000000000102],[0,-1.904000000000011],[-0.7839999999999918,-1.493300000000005],[-1.381,-0.8586999999999989],[-1.754999999999995,0],[-1.419000000000011,0.8586999999999989],[-0.7839999999999918,1.493299999999991],[0,1.903999999999996],[0.7839999999999918,1.493299999999991],[1.419000000000011,0.8586999999999989],[0,0],[0,0],[0,0]]}}},{"ty":"tm","s":{"a":0,"k":0,"ix":2},"e":{"a":0,"k":100,"ix":2},"o":{"a":0,"k":0,"ix":2},"m":1},{"ty":"tr","p":{"a":0,"k":[-211.7300415039062,-77.67320251464844],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[100,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}}]},{"ty":"gr","it":[{"ty":"sh","d":1,"ks":{"a":0,"k":{"c":true,"v":[[94.70400000000001,43.06400000000001],[86.864,40.992],[81.43199999999999,35.28],[79.47200000000001,27.216000000000008],[81.488,19.152],[86.91999999999999,13.49600000000001],[94.648,11.424000000000007],[101.088,12.88],[105.512,16.912000000000006],[104.56,18.36800000000001],[104.56,0],[110.832,0],[110.832,42.392],[104.84,42.392],[104.84,36.232],[105.568,37.408],[101.088,41.608],[94.70400000000001,43.06400000000001],[94.70400000000001,43.06400000000001],[94.70400000000001,43.06400000000001]],"i":[[0,0],[2.314999999999998,1.381299999999996],[1.344000000000023,2.389300000000006],[0,2.986699999999999],[-1.343999999999994,2.389300000000006],[-2.276999999999987,1.381299999999996],[-2.875,0],[-1.8669999999999902,-0.9706999999999937],[-1.082999999999998,-1.717300000000009],[0.3173333333333233,-0.4853333333333296],[0,6.122666666666674],[-2.090666666666664,0],[0,-14.13066666666667],[1.99733333333333,0],[0,2.053333333333327],[-0.242666666666679,-0.3919999999999959],[1.941000000000003,-0.9707000000000079],[2.314999999999998,0],[0,0],[0,0]],"o":[[-2.912000000000006,0],[-2.277000000000015,-1.4187000000000012],[-1.306999999999988,-2.389300000000006],[0,-2.986699999999999],[1.343999999999994,-2.389300000000006],[2.277000000000015,-1.3813000000000102],[2.426999999999992,0],[1.867000000000019,0.9707000000000079],[-0.3173333333333233,0.4853333333333296],[0,-6.122666666666674],[2.090666666666664,0],[0,14.13066666666667],[-1.99733333333333,0],[0,-2.053333333333327],[0.242666666666679,0.3919999999999959],[-1.045000000000016,1.829300000000003],[-1.941000000000003,0.9706999999999937],[0,0],[0,0],[0,0]]}}},{"ty":"tm","s":{"a":0,"k":0,"ix":2},"e":{"a":0,"k":100,"ix":2},"o":{"a":0,"k":0,"ix":2},"m":1},{"ty":"tr","p":{"a":0,"k":[-211.7300415039062,-77.67320251464844],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[100,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}}]},{"ty":"gr","it":[{"ty":"sh","d":1,"ks":{"a":0,"k":{"c":true,"v":[[57.40100000000001,43.06400000000001],[51.968999999999994,42],[48.38499999999999,38.976],[47.09700000000001,34.384],[48.161,29.960000000000008],[51.577,26.656000000000006],[57.345,24.752],[67.87299999999999,23.016000000000005],[67.87299999999999,28],[58.577,29.624],[54.881,31.248],[53.70500000000001,34.16],[54.992999999999995,37.016000000000005],[58.40899999999999,38.08],[62.88900000000001,36.96000000000001],[65.91300000000001,33.992],[66.977,29.792],[66.977,22.008],[65.297,18.36800000000001],[60.929,16.912000000000006],[56.505,18.256],[53.761,21.616],[48.496999999999986,18.98400000000001],[51.240999999999985,15.064000000000007],[55.66499999999999,12.376],[61.09700000000001,11.424000000000007],[67.42500000000001,12.768],[71.737,16.52],[73.305,22.008],[73.305,42.392],[67.257,42.392],[67.257,36.904],[68.54499999999999,37.072],[65.80099999999999,40.264],[62.04900000000001,42.336],[57.40100000000001,43.06400000000001],[57.40100000000001,43.06400000000001],[57.40100000000001,43.06400000000001]],"i":[[0,0],[1.568000000000012,0.7092999999999989],[0.8590000000000089,1.2693000000000012],[0,1.7547],[-0.7090000000000032,1.306699999999992],[-1.531000000000006,0.8960000000000008],[-2.314999999999998,0.3733000000000004],[-3.509333333333331,0.5786666666666633],[0,-1.661333333333332],[3.098666666666674,-0.541333333333327],[0.7839999999999918,-0.784000000000006],[0,-1.194699999999997],[-0.8590000000000089,-0.7467000000000041],[-1.381,0],[-1.269000000000005,0.7466999999999899],[-0.7090000000000032,1.2319999999999993],[0,1.530699999999996],[0,2.594666666666669],[1.120000000000005,0.9332999999999885],[1.829000000000008,0],[1.269000000000005,-0.8960000000000008],[0.5970000000000084,-1.381299999999996],[1.754666666666679,0.8773333333333255],[-1.268999999999977,1.11999999999999],[-1.680000000000007,0.6346999999999952],[-1.903999999999996,0],[-1.829000000000008,-0.8960000000000008],[-1.0080000000000098,-1.6053],[0,-2.090699999999998],[0,-6.794666666666672],[2.015999999999991,0],[0,1.829333333333338],[-0.429333333333318,-0.05599999999999739],[1.120000000000005,-0.8959999999999866],[1.418999999999983,-0.4852999999999952],[1.716999999999985,0],[0,0],[0,0]],"o":[[-2.053000000000026,0],[-1.531000000000006,-0.7467000000000041],[-0.8589999999999804,-1.306699999999992],[0,-1.642700000000005],[0.7469999999999857,-1.306700000000006],[1.531000000000006,-0.8960000000000008],[3.509333333333331,-0.5786666666666633],[0,1.661333333333332],[-3.098666666666674,0.541333333333327],[-1.680000000000007,0.2987000000000108],[-0.7839999999999918,0.7467000000000041],[0,1.157300000000006],[0.896000000000015,0.7092999999999989],[1.717000000000013,0],[1.306999999999988,-0.7467000000000041],[0.7089999999999748,-1.2693000000000012],[0,-2.594666666666669],[0,-1.493299999999991],[-1.082999999999998,-0.9707000000000079],[-1.680000000000007,0],[-1.2319999999999993,0.8586999999999989],[-1.754666666666679,-0.8773333333333255],[0.5600000000000023,-1.493300000000005],[1.269000000000005,-1.157300000000006],[1.717000000000013,-0.6347000000000094],[2.388999999999982,0],[1.86699999999999,0.8960000000000008],[1.045000000000016,1.568000000000012],[0,6.794666666666672],[-2.015999999999991,0],[0,-1.829333333333338],[0.429333333333318,0.05599999999999739],[-0.7089999999999748,1.2319999999999993],[-1.082999999999998,0.8960000000000008],[-1.381,0.4853000000000094],[0,0],[0,0],[0,0]]}}},{"ty":"tm","s":{"a":0,"k":0,"ix":2},"e":{"a":0,"k":100,"ix":2},"o":{"a":0,"k":0,"ix":2},"m":1},{"ty":"tr","p":{"a":0,"k":[-211.7300415039062,-77.67320251464844],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[100,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}}]},{"ty":"gr","it":[{"ty":"sh","d":1,"ks":{"a":0,"k":{"c":true,"v":[[0,42.392],[0,0.6720000000000041],[6.159999999999997,0.6720000000000041],[21.84,22.400000000000006],[18.75999999999999,22.400000000000006],[34.16,0.6720000000000041],[40.31999999999999,0.6720000000000041],[40.31999999999999,42.392],[33.768,42.392],[33.768,8.456000000000003],[36.232,9.128],[20.49600000000001,30.632000000000005],[19.824000000000012,30.632000000000005],[4.424000000000007,9.128],[6.608000000000004,8.456000000000003],[6.608000000000004,42.392],[0,42.392],[0,42.392],[0,42.392]],"i":[[0,0],[0,13.90666666666666],[-2.053333333333342,0],[-5.226666666666659,-7.242666666666665],[1.026666666666671,0],[-5.133333333333326,7.242666666666672],[-2.053333333333342,0],[0,-13.90666666666667],[2.183999999999997,0],[0,11.312],[-0.8213333333333424,-0.2240000000000038],[5.245333333333321,-7.168000000000006],[0.2239999999999895,0],[5.133333333333326,7.168000000000006],[-0.7280000000000086,0.2240000000000038],[0,-11.312],[2.202666666666659,0],[0,0],[0,0]],"o":[[0,-13.90666666666667],[2.053333333333342,0],[5.226666666666659,7.242666666666672],[-1.026666666666671,0],[5.133333333333326,-7.242666666666665],[2.053333333333342,0],[0,13.90666666666666],[-2.183999999999997,0],[0,-11.312],[0.8213333333333424,0.2240000000000038],[-5.245333333333321,7.168000000000006],[-0.2239999999999895,0],[-5.133333333333326,-7.168000000000006],[0.7280000000000086,-0.2240000000000038],[0,11.312],[-2.202666666666659,0],[0,0],[0,0],[0,0]]}}},{"ty":"tm","s":{"a":0,"k":0,"ix":2},"e":{"a":0,"k":100,"ix":2},"o":{"a":0,"k":0,"ix":2},"m":1},{"ty":"tr","p":{"a":0,"k":[-211.7300415039062,-77.67320251464844],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[100,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}}]},{"ty":"fl","c":{"a":0,"k":[1,1,1],"ix":2},"o":{"a":0,"k":100,"ix":2},"r":1,"bm":0},{"ty":"tr","p":{"a":0,"k":[2.91259765625,56.001014709472656],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[99.99999403953552,99.99999403953552],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}}]},{"ty":"gr","it":[{"ty":"rc","d":1,"s":{"a":0,"k":[702.6863719370097,144],"ix":2},"p":{"a":0,"k":[0,0],"ix":2},"r":{"a":0,"k":72,"ix":2}},{"ty":"fl","c":{"a":0,"k":[0,0,0],"ix":2},"o":{"a":0,"k":100,"ix":2},"r":1,"bm":0},{"ty":"tm","s":{"a":0,"k":0,"ix":2},"e":{"a":0,"k":100,"ix":2},"o":{"a":0,"k":0,"ix":2},"m":1},{"ty":"tr","p":{"a":0,"k":[56.54167175292969,-0.000022762338630855083],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[99.99999403953552,99.99999403953552],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":80,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}}]},{"ty":"tr","p":{"a":0,"k":[122.0000003294881,25.00000012138912],"ix":2},"a":{"a":0,"k":[56.54167175292969,-0.00002288818359375],"ix":2},"s":{"a":0,"k":[34.403572049765366,34.403572049765366],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}}]}],"ip":0,"op":668,"st":0,"bm":0},{"ddd":0,"ind":1,"ty":4,"nm":"Line (Group)","sr":1,"ks":{"p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[100,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ty":"gr","it":[{"ty":"gr","it":[{"ty":"gr","nm":"Group 1","it":[{"ty":"gr","nm":"Path 1","it":[{"ty":"sh","d":1,"ks":{"a":0,"k":{"c":false,"v":[[3.475,0.875],[-0.5,-3.292]],"i":[[0,0],[0,0]],"o":[[0,0],[0,0]]}}},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[100,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}}]},{"ty":"gr","nm":"Path 2","it":[{"ty":"sh","d":1,"ks":{"a":0,"k":{"c":false,"v":[[-4.9,0.875],[-0.5,-3.292],[-0.528,9.25]],"i":[[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0]]}}},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[100,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}}]},{"ty":"st","c":{"a":0,"k":[1,1,1],"ix":2},"o":{"a":0,"k":100,"ix":2},"w":{"a":0,"k":4,"ix":2},"lc":2,"lj":2,"ml":4},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[100,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}}]},{"ty":"tr","p":{"a":0,"k":[9.5,12.125],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[100,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}}]},{"ty":"tr","p":{"a":0,"k":[27,24.984],"ix":2},"a":{"a":0,"k":[9.5,12.734],"ix":2},"s":{"a":1,"k":[{"t":25,"s":[0,0],"i":{"x":[0.658],"y":[1]},"o":{"x":[0.461],"y":[0]}},{"t":53,"s":[134,134],"i":{"x":[0.343],"y":[1]},"o":{"x":[0.41],"y":[0]}},{"t":75,"s":[100,100],"i":{"x":[0.75],"y":[0.75]},"o":{"x":[0.25],"y":[0.25]}}],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}}]},{"ty":"tr","p":{"a":1,"k":[{"t":103,"s":[106.9561767578125,94.498046875],"i":{"x":[0.537],"y":[1]},"o":{"x":[0.457],"y":[0]},"ti":[0,0],"to":[-7.5,0]},{"t":223,"s":[61.9561767578125,94.498046875],"i":{"x":[0.565],"y":[0.988]},"o":{"x":[0.452],"y":[0]},"ti":[-7.5,0],"to":[0,0]},{"t":343,"s":[106.9561767578125,94.498046875],"i":{"x":[0.75],"y":[0.75]},"o":{"x":[0.25],"y":[0.25]}}],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":1,"k":[{"t":3,"s":[0,0],"i":{"x":[0.658],"y":[1]},"o":{"x":[0.461],"y":[0]}},{"t":47,"s":[231.297699213028,231.297699213028],"i":{"x":[0.598],"y":[1]},"o":{"x":[0.488],"y":[0]}},{"t":80,"s":[139.8142808675766,139.8142808675766],"i":{"x":[0.49],"y":[1]},"o":{"x":[0.392],"y":[0]}},{"t":103,"s":[172.61022329330444,172.61022329330444],"i":{"x":[0.75],"y":[0.75]},"o":{"x":[0.25],"y":[0.25]}}],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}}]}],"ip":0,"op":668,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"Line","sr":1,"ks":{"p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[100,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ty":"gr","nm":"Group 1","it":[{"ty":"sh","d":1,"ks":{"a":0,"k":{"c":true,"v":[[17,0],[0,17],[-17,0],[0,-17],[17,0]],"i":[[0,0],[9.389,0],[0,9.389],[-9.389,0],[0,-9.389]],"o":[[0,9.389],[-9.389,0],[0,-9.389],[9.389,0],[0,0]]}}},{"ty":"st","c":{"a":0,"k":[1,1,1],"ix":2},"o":{"a":0,"k":100,"ix":2},"w":{"a":0,"k":6,"ix":2},"lc":2,"lj":1,"ml":4},{"ty":"tr","p":{"a":0,"k":[27,27],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[100,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}}]},{"ty":"tr","p":{"a":1,"k":[{"t":103,"s":[106.9561767578125,94.498046875],"i":{"x":[0.537],"y":[1]},"o":{"x":[0.457],"y":[0]},"ti":[0,0],"to":[-7.5,0]},{"t":223,"s":[61.9561767578125,94.498046875],"i":{"x":[0.565],"y":[0.988]},"o":{"x":[0.452],"y":[0]},"ti":[-7.5,0],"to":[0,0]},{"t":343,"s":[106.9561767578125,94.498046875],"i":{"x":[0.75],"y":[0.75]},"o":{"x":[0.25],"y":[0.25]}}],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":1,"k":[{"t":3,"s":[0,0],"i":{"x":[0.658],"y":[1]},"o":{"x":[0.461],"y":[0]}},{"t":47,"s":[231.297699213028,231.297699213028],"i":{"x":[0.598],"y":[1]},"o":{"x":[0.488],"y":[0]}},{"t":80,"s":[139.8142808675766,139.8142808675766],"i":{"x":[0.49],"y":[1]},"o":{"x":[0.392],"y":[0]}},{"t":103,"s":[172.61022329330444,172.61022329330444],"i":{"x":[0.75],"y":[0.75]},"o":{"x":[0.25],"y":[0.25]}}],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}}]}],"ip":0,"op":668,"st":0,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"Line","sr":1,"ks":{"p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[100,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}},"ao":0,"shapes":[{"ty":"gr","nm":"Line","it":[{"ty":"sh","d":1,"ks":{"a":0,"k":{"c":false,"v":[[-27.40187177921811,4.543100883332414],[-4.315255398302065,-18.988849854688404],[21.47271086195107,5.7461940883790295],[-4.3014465810274976,30.26202305721272],[-89.75731228468294,30.20506168595513]],"i":[[0,0],[-9.600580210142434,0.32450720595231525],[-0.0034522043186416516,-15.348500400680782],[18.757552165339415,-0.16397970513547847],[2.825629234808192,-0.01553491943388743]],"o":[[0,-16.734560434615407],[13.503297192366823,-0.4556909700606981],[0.0017261021593208258,9.40898287045782],[-2.3664860604288522,0.02071322591184991],[0,0]]}}},{"ty":"tm","s":{"a":1,"k":[{"t":73,"s":[36],"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]}},{"t":100,"s":[21],"i":{"x":[0.75],"y":[0.75]},"o":{"x":[0.25],"y":[0.25]}}],"ix":2},"e":{"a":1,"k":[{"t":73,"s":[36],"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]}},{"t":100,"s":[57],"i":{"x":[0.833],"y":[1]},"o":{"x":[0.333],"y":[0]}},{"t":103,"s":[57],"i":{"x":[0.647],"y":[1]},"o":{"x":[0.336],"y":[0]}},{"t":223,"s":[95],"i":{"x":[0.653],"y":[1.011]},"o":{"x":[0.353],"y":[0]}},{"t":343,"s":[57],"i":{"x":[0.647],"y":[1]},"o":{"x":[0.336],"y":[0]}},{"t":463,"s":[95],"i":{"x":[0.67],"y":[1]},"o":{"x":[0.369],"y":[0]}},{"t":583,"s":[57],"i":{"x":[0.647],"y":[1]},"o":{"x":[0.336],"y":[0]}},{"t":703,"s":[95],"i":{"x":[0.715],"y":[0.99]},"o":{"x":[0.369],"y":[0]}},{"t":833,"s":[57],"i":{"x":[0.75],"y":[0.75]},"o":{"x":[0.25],"y":[0.25]}}],"ix":2},"o":{"a":0,"k":-57,"ix":2},"m":1},{"ty":"st","c":{"a":0,"k":[1,1,1],"ix":2},"o":{"a":0,"k":100,"ix":2},"w":{"a":0,"k":8,"ix":2},"lc":2,"lj":1,"ml":4},{"ty":"tr","p":{"a":0,"k":[169.95892333984375,104.85466003417969],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[100,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}}]}],"ip":0,"op":668,"st":0,"bm":0},{"ddd":0,"ind":4,"ty":4,"nm":"Line","sr":1,"ks":{"p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[100,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}},"ao":0,"shapes":[{"ty":"gr","nm":"Line","it":[{"ty":"sh","d":1,"ks":{"a":0,"k":{"c":false,"v":[[-7.762281410465753,-27.947320061563488],[-21.576276991510323,-31.39434607372718],[-52.64611585928519,-0.0017261021593208258],[-21.576276991510323,31.39434607372718],[45.52594445208678,31.287327739849292]],"i":[[0,0],[4.962543708047374,0],[0,-17.15918156580833],[-17.15918156580833,0],[0,0]],"o":[[-4.161632306122511,-2.0695964890256704],[-17.15918156580833,0],[0,17.15918156580833],[0,0],[0,0]]}}},{"ty":"tm","s":{"a":1,"k":[{"t":103,"s":[100],"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]}},{"t":223,"s":[58],"i":{"x":[0.653],"y":[1]},"o":{"x":[0.322],"y":[0]}},{"t":343,"s":[100],"i":{"x":[0.75],"y":[0.75]},"o":{"x":[0.25],"y":[0.25]}}],"ix":2},"e":{"a":1,"k":[{"t":3,"s":[100],"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]}},{"t":40,"s":[0],"i":{"x":[0.833],"y":[1]},"o":{"x":[0.167],"y":[0]}},{"t":103,"s":[0],"i":{"x":[0.75],"y":[0.75]},"o":{"x":[0.25],"y":[0.25]}}],"ix":2},"o":{"a":0,"k":0,"ix":2},"m":1},{"ty":"st","c":{"a":0,"k":[1,1,1],"ix":2},"o":{"a":0,"k":100,"ix":2},"w":{"a":0,"k":8,"ix":2},"lc":2,"lj":1,"ml":4},{"ty":"tr","p":{"a":0,"k":[61.2144775390625,103.66709899902344],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[100,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}}]}],"ip":0,"op":668,"st":0,"bm":0},{"ddd":0,"ind":5,"ty":4,"nm":"Line","sr":1,"ks":{"p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[100,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}},"ao":0,"shapes":[{"ty":"gr","nm":"Line","it":[{"ty":"sh","d":1,"ks":{"a":0,"k":{"c":false,"v":[[-36.88335094036741,20.71322591184991],[4.543100883332414,-20.71322591184991],[36.88335094036741,-5.1800325801217975]],"i":[[0,0],[-22.879484121797546,0],[-7.593123398852313,-9.469396446034049]],"o":[[0,-22.879484121797546],[13.082128265492537,0],[0,0]]}}},{"ty":"tm","s":{"a":0,"k":0,"ix":2},"e":{"a":1,"k":[{"t":30,"s":[0],"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]}},{"t":63,"s":[100],"i":{"x":[0.75],"y":[0.75]},"o":{"x":[0.25],"y":[0.25]}}],"ix":2},"o":{"a":0,"k":0,"ix":2},"m":1},{"ty":"st","c":{"a":0,"k":[1,1,1],"ix":2},"o":{"a":0,"k":100,"ix":2},"w":{"a":0,"k":8,"ix":2},"lc":2,"lj":1,"ml":4},{"ty":"tr","p":{"a":0,"k":[78.67915344238281,50.26668167114258],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[100,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}}]}],"ip":0,"op":668,"st":0,"bm":0},{"ddd":0,"ind":6,"ty":4,"nm":"Line","sr":1,"ks":{"p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[100,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}},"ao":0,"shapes":[{"ty":"gr","nm":"Line","it":[{"ty":"sh","d":1,"ks":{"a":0,"k":{"c":false,"v":[[-31.677426827855797,-3.4539304208009725],[-2.8446163585607205,-18.987123752529083],[31.677426827855797,15.534919433887433],[31.508268816242357,18.987123752529083]],"i":[[0,0],[-12.049919174218685,0],[0,-19.06652445185784],[0.11219664035585368,-1.1357752208331036]],"o":[[6.175993526049915,-9.358925907837518],[19.06652445185784,0],[0,1.1651189575415575],[0,0]]}}},{"ty":"tm","s":{"a":1,"k":[{"t":57,"s":[22],"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]}},{"t":83,"s":[0],"i":{"x":[0.75],"y":[0.75]},"o":{"x":[0.25],"y":[0.25]}}],"ix":2},"e":{"a":1,"k":[{"t":57,"s":[22],"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0.223]}},{"t":83,"s":[100],"i":{"x":[0.75],"y":[0.75]},"o":{"x":[0.25],"y":[0.25]}}],"ix":2},"o":{"a":0,"k":0,"ix":2},"m":1},{"ty":"st","c":{"a":0,"k":[1,1,1],"ix":2},"o":{"a":0,"k":100,"ix":2},"w":{"a":0,"k":8,"ix":2},"lc":2,"lj":1,"ml":4},{"ty":"tr","p":{"a":0,"k":[137.41671752929688,64.291259765625],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[100,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}}]}],"ip":0,"op":668,"st":0,"bm":0},{"ddd":0,"ind":7,"ty":4,"nm":"Line","sr":1,"ks":{"p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[100,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}},"ao":0,"shapes":[{"ty":"gr","nm":"Line","it":[{"ty":"sh","d":1,"ks":{"a":0,"k":{"c":false,"v":[[14.544136794437279,1.0287568869552122],[-14.544136794437279,11.053958228290568]],"i":[[0,0],[8.373321574865326,-22.107916456581137]],"o":[[0,0],[0,0]]}}},{"ty":"tm","s":{"a":1,"k":[{"t":33,"s":[50],"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]}},{"t":57,"s":[0],"i":{"x":[0.75],"y":[0.75]},"o":{"x":[0.25],"y":[0.25]}}],"ix":2},"e":{"a":1,"k":[{"t":33,"s":[50],"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]}},{"t":57,"s":[100],"i":{"x":[0.75],"y":[0.75]},"o":{"x":[0.25],"y":[0.25]}}],"ix":2},"o":{"a":0,"k":0,"ix":2},"m":1},{"ty":"st","c":{"a":0,"k":[1,1,1],"ix":2},"o":{"a":0,"k":100,"ix":2},"w":{"a":0,"k":4,"ix":2},"lc":2,"lj":2,"ml":4},{"ty":"tr","p":{"a":0,"k":[61.34219741821289,102.09980773925781],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[100,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}}]}],"ip":0,"op":668,"st":0,"bm":0},{"ddd":0,"ind":8,"ty":4,"nm":"Line","sr":1,"ks":{"p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[100,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}},"ao":0,"shapes":[{"ty":"gr","nm":"Line","it":[{"ty":"sh","d":1,"ks":{"a":0,"k":{"c":false,"v":[[14.544136794437279,1.0287568869552122],[-14.544136794437279,11.053958228290568]],"i":[[0,0],[8.373321574865326,-22.107916456581137]],"o":[[0,0],[0,0]]}}},{"ty":"tm","s":{"a":1,"k":[{"t":77,"s":[50],"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]}},{"t":97,"s":[0],"i":{"x":[0.75],"y":[0.75]},"o":{"x":[0.25],"y":[0.25]}}],"ix":2},"e":{"a":1,"k":[{"t":77,"s":[50],"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]}},{"t":97,"s":[100],"i":{"x":[0.75],"y":[0.75]},"o":{"x":[0.25],"y":[0.25]}}],"ix":2},"o":{"a":0,"k":0,"ix":2},"m":1},{"ty":"st","c":{"a":0,"k":[1,1,1],"ix":2},"o":{"a":0,"k":100,"ix":2},"w":{"a":0,"k":4,"ix":2},"lc":2,"lj":2,"ml":4},{"ty":"tr","p":{"a":0,"k":[109.67306518554688,72.75605773925781],"ix":2},"a":{"a":0,"k":[0,0],"ix":2},"s":{"a":0,"k":[100,100],"ix":2},"r":{"a":0,"k":0,"ix":2},"o":{"a":0,"k":100,"ix":2},"sk":{"a":0,"k":0,"ix":2},"sa":{"a":0,"k":0,"ix":2}}]}],"ip":0,"op":668,"st":0,"bm":0}],"markers":[]} \ No newline at end of file diff --git a/frontend/src/components/v2/Modal/Modal.tsx b/frontend/src/components/v2/Modal/Modal.tsx index 9b7baa921..f3b63eae4 100644 --- a/frontend/src/components/v2/Modal/Modal.tsx +++ b/frontend/src/components/v2/Modal/Modal.tsx @@ -45,7 +45,11 @@ export const ModalContent = forwardRef( )} style={{ maxHeight: "90%" }} > - {title && {title}} + {title && ( + + {title} + + )} { + const queryClient = useQueryClient(); + return useMutation({ + mutationFn: (id: string) => { + return apiRequest.delete(`/api/v1/gateways/${id}`); + }, + onSuccess: () => { + queryClient.invalidateQueries(gatewaysQueryKeys.list()); + } + }); +}; + +export const useUpdateGatewayById = () => { + const queryClient = useQueryClient(); + return useMutation({ + mutationFn: ({ id, name, projectIds }: TUpdateGatewayDTO) => { + return apiRequest.patch(`/api/v1/gateways/${id}`, { name, projectIds }); + }, + onSuccess: () => { + queryClient.invalidateQueries(gatewaysQueryKeys.list()); + } + }); +}; diff --git a/frontend/src/hooks/api/gateways/queries.tsx b/frontend/src/hooks/api/gateways/queries.tsx new file mode 100644 index 000000000..6ec374a6c --- /dev/null +++ b/frontend/src/hooks/api/gateways/queries.tsx @@ -0,0 +1,33 @@ +import { queryOptions } from "@tanstack/react-query"; + +import { apiRequest } from "@app/config/request"; + +import { TGateway, TListProjectGatewayDTO, TProjectGateway } from "./types"; + +export const gatewaysQueryKeys = { + allKey: () => ["gateways"], + listKey: () => [...gatewaysQueryKeys.allKey(), "list"], + list: () => + queryOptions({ + queryKey: gatewaysQueryKeys.listKey(), + queryFn: async () => { + const { data } = await apiRequest.get<{ gateways: TGateway[] }>("/api/v1/gateways"); + return data.gateways; + } + }), + listProjectGatewayKey: ({ projectId }: TListProjectGatewayDTO) => [ + ...gatewaysQueryKeys.allKey(), + "list", + { projectId } + ], + listProjectGateways: ({ projectId }: TListProjectGatewayDTO) => + queryOptions({ + queryKey: gatewaysQueryKeys.listProjectGatewayKey({ projectId }), + queryFn: async () => { + const { data } = await apiRequest.get<{ gateways: TProjectGateway[] }>( + `/api/v1/gateways/projects/${projectId}` + ); + return data.gateways; + } + }) +}; diff --git a/frontend/src/hooks/api/gateways/types.ts b/frontend/src/hooks/api/gateways/types.ts new file mode 100644 index 000000000..a522b6c48 --- /dev/null +++ b/frontend/src/hooks/api/gateways/types.ts @@ -0,0 +1,49 @@ +export type TGateway = { + id: string; + identityId: string; + name: string; + createdAt: string; + updatedAt: string; + issuedAt: string; + serialNumber: string; + heartbeat: string; + identity: { + name: string; + id: string; + }; + projects: { + name: string; + id: string; + slug: string; + }[]; +}; + +export type TProjectGateway = { + id: string; + identityId: string; + name: string; + createdAt: string; + updatedAt: string; + issuedAt: string; + serialNumber: string; + heartbeat: string; + projectGatewayId: string; + identity: { + name: string; + id: string; + }; +}; + +export type TUpdateGatewayDTO = { + id: string; + name?: string; + projectIds?: string[]; +}; + +export type TDeleteGatewayDTO = { + id: string; +}; + +export type TListProjectGatewayDTO = { + projectId: string; +}; diff --git a/frontend/src/hooks/api/index.tsx b/frontend/src/hooks/api/index.tsx index 441b5ba86..8311dbf2d 100644 --- a/frontend/src/hooks/api/index.tsx +++ b/frontend/src/hooks/api/index.tsx @@ -10,6 +10,7 @@ export * from "./certificates"; export * from "./certificateTemplates"; export * from "./dynamicSecret"; export * from "./dynamicSecretLease"; +export * from "./gateways"; export * from "./groups"; export * from "./identities"; export * from "./identityProjectAdditionalPrivilege"; diff --git a/frontend/src/hooks/api/subscriptions/types.ts b/frontend/src/hooks/api/subscriptions/types.ts index 3129dd508..b6b653ece 100644 --- a/frontend/src/hooks/api/subscriptions/types.ts +++ b/frontend/src/hooks/api/subscriptions/types.ts @@ -42,6 +42,7 @@ export type SubscriptionPlan = { has_used_trial: boolean; caCrl: boolean; instanceUserManagement: boolean; + gateway: boolean; externalKms: boolean; pkiEst: boolean; enforceMfa: boolean; diff --git a/frontend/src/layouts/OrganizationLayout/OrganizationLayout.tsx b/frontend/src/layouts/OrganizationLayout/OrganizationLayout.tsx index 589e82895..ed5a0ab10 100644 --- a/frontend/src/layouts/OrganizationLayout/OrganizationLayout.tsx +++ b/frontend/src/layouts/OrganizationLayout/OrganizationLayout.tsx @@ -101,6 +101,13 @@ export const OrganizationLayout = () => { )} + + {({ isActive }) => ( + + Gateways + + )} + {({ isActive }) => ( diff --git a/frontend/src/layouts/OrganizationLayout/components/MinimizedOrgSidebar/MinimizedOrgSidebar.tsx b/frontend/src/layouts/OrganizationLayout/components/MinimizedOrgSidebar/MinimizedOrgSidebar.tsx index 02c352bcc..4a255acad 100644 --- a/frontend/src/layouts/OrganizationLayout/components/MinimizedOrgSidebar/MinimizedOrgSidebar.tsx +++ b/frontend/src/layouts/OrganizationLayout/components/MinimizedOrgSidebar/MinimizedOrgSidebar.tsx @@ -5,6 +5,7 @@ import { faBook, faCheck, faCog, + faDoorClosed, faEnvelope, faInfinity, faInfo, @@ -352,6 +353,13 @@ export const MinimizedOrgSidebar = () => { App Connections + + } + > + Gateways + + {(window.location.origin.includes("https://app.infisical.com") || window.location.origin.includes("https://eu.infisical.com") || window.location.origin.includes("https://gamma.infisical.com")) && ( diff --git a/frontend/src/pages/organization/Gateways/GatewayListPage/GatewayListPage.tsx b/frontend/src/pages/organization/Gateways/GatewayListPage/GatewayListPage.tsx new file mode 100644 index 000000000..85ec82334 --- /dev/null +++ b/frontend/src/pages/organization/Gateways/GatewayListPage/GatewayListPage.tsx @@ -0,0 +1,260 @@ +import { useState } from "react"; +import { Helmet } from "react-helmet"; +import { + faArrowUpRightFromSquare, + faBookOpen, + faEdit, + faEllipsisV, + faInfoCircle, + faMagnifyingGlass, + faPlug, + faSearch, + faTrash +} from "@fortawesome/free-solid-svg-icons"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { useQuery } from "@tanstack/react-query"; +import { format, formatRelative } from "date-fns"; + +import { createNotification } from "@app/components/notifications"; +import { OrgPermissionCan } from "@app/components/permissions"; +import { + DeleteActionModal, + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuTrigger, + EmptyState, + IconButton, + Input, + Modal, + ModalContent, + PageHeader, + Table, + TableContainer, + TableSkeleton, + Tag, + TBody, + Td, + Th, + THead, + Tooltip, + Tr +} from "@app/components/v2"; +import { + OrgGatewayPermissionActions, + OrgPermissionAppConnectionActions, + OrgPermissionSubjects +} from "@app/context/OrgPermissionContext/types"; +import { withPermission } from "@app/hoc"; +import { usePopUp } from "@app/hooks"; +import { gatewaysQueryKeys, useDeleteGatewayById } from "@app/hooks/api/gateways"; + +import { EditGatewayDetailsModal } from "./components/EditGatewayDetailsModal"; + +export const GatewayListPage = withPermission( + () => { + const [search, setSearch] = useState(""); + const { data: gateways, isPending: isGatewayLoading } = useQuery(gatewaysQueryKeys.list()); + + const { popUp, handlePopUpOpen, handlePopUpToggle } = usePopUp([ + "deleteGateway", + "editDetails" + ] as const); + + const deleteGatewayById = useDeleteGatewayById(); + + const handleDeleteGateway = async () => { + await deleteGatewayById.mutateAsync((popUp.deleteGateway.data as { id: string }).id, { + onSuccess: () => { + handlePopUpToggle("deleteGateway"); + createNotification({ + type: "success", + text: "Successfully delete gateway" + }); + } + }); + }; + + const filteredGateway = gateways?.filter((el) => + el.name.toLowerCase().includes(search.toLowerCase()) + ); + + return ( +
+ + Infisical | Gateways + + +
+
+ + Gateways + +
+ + Docs + +
+
+
+ } + description="Create and configure gateway to access private network resources from Infisical" + /> +
+
+
+ setSearch(e.target.value)} + leftIcon={} + placeholder="Search gateway..." + className="flex-1" + /> +
+ + + + + + + + + + + + + {isGatewayLoading && ( + + )} + {filteredGateway?.map((el) => ( + + + + + + + + + ))} + +
NameCert Issued AtProjectsIdentity + Health Check + + + + +
{el.name}{format(new Date(el.issuedAt), "yyyy-MM-dd hh:mm:ss aaa")} + {el.projects.map((projectDetails) => ( + + {projectDetails.name} + + ))} + {el.identity.name} + {el.heartbeat + ? formatRelative(new Date(el.heartbeat), new Date()) + : "-"} + + + + + + + + + + + {(isAllowed: boolean) => ( + } + onClick={() => handlePopUpOpen("editDetails", el)} + > + Edit Details + + )} + + + {(isAllowed: boolean) => ( + } + className="text-red" + onClick={() => handlePopUpOpen("deleteGateway", el)} + > + Delete Gateway + + )} + + + + +
+ handlePopUpToggle("editDetails", isOpen)} + > + + handlePopUpToggle("editDetails")} + /> + + + {!isGatewayLoading && !filteredGateway?.length && ( + + )} + handlePopUpToggle("deleteGateway", isOpen)} + deleteKey="confirm" + onDeleteApproved={() => handleDeleteGateway()} + /> +
+
+
+
+
+ + ); + }, + { + action: OrgPermissionAppConnectionActions.Read, + subject: OrgPermissionSubjects.AppConnections + } +); diff --git a/frontend/src/pages/organization/Gateways/GatewayListPage/components/EditGatewayDetailsModal.tsx b/frontend/src/pages/organization/Gateways/GatewayListPage/components/EditGatewayDetailsModal.tsx new file mode 100644 index 000000000..d41fd5489 --- /dev/null +++ b/frontend/src/pages/organization/Gateways/GatewayListPage/components/EditGatewayDetailsModal.tsx @@ -0,0 +1,113 @@ +import { Controller, useForm } from "react-hook-form"; +import { zodResolver } from "@hookform/resolvers/zod"; +import { z } from "zod"; + +import { createNotification } from "@app/components/notifications"; +import { Button, FilterableSelect, FormControl, Input } from "@app/components/v2"; +import { useGetUserWorkspaces, useUpdateGatewayById } from "@app/hooks/api"; +import { TGateway } from "@app/hooks/api/gateways/types"; +import { ProjectType } from "@app/hooks/api/workspace/types"; + +type Props = { + gatewayDetails: TGateway; + onClose: () => void; +}; + +const schema = z.object({ + name: z.string(), + projects: z + .object({ + id: z.string(), + name: z.string() + }) + .array() +}); + +export type FormData = z.infer; + +export const EditGatewayDetailsModal = ({ gatewayDetails, onClose }: Props) => { + const { + control, + handleSubmit, + formState: { isSubmitting } + } = useForm({ + resolver: zodResolver(schema), + defaultValues: { + name: gatewayDetails?.name + } + }); + + const updateGatewayById = useUpdateGatewayById(); + // when gateway goes to other products switch to all + const { data: secretManagerWorkspaces, isLoading: isSecretManagerLoading } = useGetUserWorkspaces( + { + type: ProjectType.SecretManager + } + ); + + const onFormSubmit = ({ name, projects }: FormData) => { + if (isSubmitting) return; + updateGatewayById.mutate( + { + id: gatewayDetails.id, + name, + projectIds: projects.map((el) => el.id) + }, + { + onSuccess: () => { + createNotification({ + type: "success", + text: "Successfully updated gateway" + }); + onClose(); + } + } + ); + }; + + return ( +
+ ( + + + + )} + /> + ( + + option.id} + getOptionLabel={(option) => option.name} + /> + + )} + /> +
+ + +
+ + ); +}; diff --git a/frontend/src/pages/organization/Gateways/GatewayListPage/route.tsx b/frontend/src/pages/organization/Gateways/GatewayListPage/route.tsx new file mode 100644 index 000000000..ab03869a3 --- /dev/null +++ b/frontend/src/pages/organization/Gateways/GatewayListPage/route.tsx @@ -0,0 +1,23 @@ +import { faHome } from "@fortawesome/free-solid-svg-icons"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { createFileRoute, linkOptions } from "@tanstack/react-router"; + +import { GatewayListPage } from "./GatewayListPage"; + +export const Route = createFileRoute( + "/_authenticate/_inject-org-details/_org-layout/organization/gateways/" +)({ + component: GatewayListPage, + context: () => ({ + breadcrumbs: [ + { + label: "Home", + icon: () => , + link: linkOptions({ to: "/organization/secret-manager/overview" }) + }, + { + label: "Gateways" + } + ] + }) +}); diff --git a/frontend/src/pages/organization/RoleByIDPage/components/OrgRoleModifySection.utils.ts b/frontend/src/pages/organization/RoleByIDPage/components/OrgRoleModifySection.utils.ts index 209373285..42dd31417 100644 --- a/frontend/src/pages/organization/RoleByIDPage/components/OrgRoleModifySection.utils.ts +++ b/frontend/src/pages/organization/RoleByIDPage/components/OrgRoleModifySection.utils.ts @@ -3,6 +3,7 @@ import { z } from "zod"; import { OrgPermissionSubjects } from "@app/context"; import { + OrgGatewayPermissionActions, OrgPermissionAppConnectionActions, OrgPermissionKmipActions } from "@app/context/OrgPermissionContext/types"; @@ -34,6 +35,15 @@ const kmipPermissionSchema = z }) .optional(); +const orgGatewayPermissionSchema = z + .object({ + [OrgGatewayPermissionActions.ListGateways]: z.boolean().optional(), + [OrgGatewayPermissionActions.EditGateways]: z.boolean().optional(), + [OrgGatewayPermissionActions.DeleteGateways]: z.boolean().optional(), + [OrgGatewayPermissionActions.CreateGateways]: z.boolean().optional() + }) + .optional(); + const adminConsolePermissionSchmea = z .object({ "access-all-projects": z.boolean().optional() @@ -72,7 +82,8 @@ export const formSchema = z.object({ [OrgPermissionSubjects.Kms]: generalPermissionSchema, [OrgPermissionSubjects.ProjectTemplates]: generalPermissionSchema, "app-connections": appConnectionsPermissionSchema, - kmip: kmipPermissionSchema + kmip: kmipPermissionSchema, + gateway: orgGatewayPermissionSchema }) .optional() }); diff --git a/frontend/src/pages/organization/RoleByIDPage/components/RolePermissionsSection/OrgPermissionGatewayRow.tsx b/frontend/src/pages/organization/RoleByIDPage/components/RolePermissionsSection/OrgPermissionGatewayRow.tsx new file mode 100644 index 000000000..46e88653a --- /dev/null +++ b/frontend/src/pages/organization/RoleByIDPage/components/RolePermissionsSection/OrgPermissionGatewayRow.tsx @@ -0,0 +1,182 @@ +import { useEffect, useMemo } from "react"; +import { Control, Controller, UseFormSetValue, useWatch } from "react-hook-form"; +import { faChevronDown, faChevronRight } from "@fortawesome/free-solid-svg-icons"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; + +import { createNotification } from "@app/components/notifications"; +import { Checkbox, Select, SelectItem, Td, Tr } from "@app/components/v2"; +import { OrgGatewayPermissionActions } from "@app/context/OrgPermissionContext/types"; +import { useToggle } from "@app/hooks"; + +import { TFormSchema } from "../OrgRoleModifySection.utils"; + +type Props = { + isEditable: boolean; + setValue: UseFormSetValue; + control: Control; +}; + +enum Permission { + NoAccess = "no-access", + ReadOnly = "read-only", + FullAccess = "full-access", + Custom = "custom" +} + +const PERMISSION_ACTIONS = [ + { action: OrgGatewayPermissionActions.ListGateways, label: "List Gateways" }, + { action: OrgGatewayPermissionActions.CreateGateways, label: "Create Gateways" }, + { action: OrgGatewayPermissionActions.EditGateways, label: "Edit Gateways" }, + { action: OrgGatewayPermissionActions.DeleteGateways, label: "Delete Gateways" } +] as const; + +export const OrgGatewayPermissionRow = ({ isEditable, control, setValue }: Props) => { + const [isRowExpanded, setIsRowExpanded] = useToggle(); + const [isCustom, setIsCustom] = useToggle(); + + const rule = useWatch({ + control, + name: "permissions.gateway" + }); + + const selectedPermissionCategory = useMemo(() => { + const actions = Object.keys(rule || {}) as Array; + const totalActions = PERMISSION_ACTIONS.length; + const score = actions.map((key) => (rule?.[key] ? 1 : 0)).reduce((a, b) => a + b, 0 as number); + + if (isCustom) return Permission.Custom; + if (score === 0) return Permission.NoAccess; + if (score === totalActions) return Permission.FullAccess; + if (score === 1 && rule?.[OrgGatewayPermissionActions.ListGateways]) return Permission.ReadOnly; + + return Permission.Custom; + }, [rule, isCustom]); + + useEffect(() => { + if (selectedPermissionCategory === Permission.Custom) setIsCustom.on(); + else setIsCustom.off(); + }, [selectedPermissionCategory]); + + useEffect(() => { + const isRowCustom = selectedPermissionCategory === Permission.Custom; + if (isRowCustom) { + setIsRowExpanded.on(); + } + }, []); + + const handlePermissionChange = (val: Permission) => { + if (!val) return; + if (val === Permission.Custom) { + setIsRowExpanded.on(); + setIsCustom.on(); + return; + } + setIsCustom.off(); + + switch (val) { + case Permission.FullAccess: + setValue( + "permissions.gateway", + { + [OrgGatewayPermissionActions.ListGateways]: true, + [OrgGatewayPermissionActions.EditGateways]: true, + [OrgGatewayPermissionActions.CreateGateways]: true, + [OrgGatewayPermissionActions.DeleteGateways]: true + }, + { shouldDirty: true } + ); + break; + case Permission.ReadOnly: + setValue( + "permissions.gateway", + { + [OrgGatewayPermissionActions.ListGateways]: true, + [OrgGatewayPermissionActions.EditGateways]: false, + [OrgGatewayPermissionActions.CreateGateways]: false, + [OrgGatewayPermissionActions.DeleteGateways]: false + }, + { shouldDirty: true } + ); + break; + + case Permission.NoAccess: + default: + setValue( + "permissions.gateway", + { + [OrgGatewayPermissionActions.ListGateways]: false, + [OrgGatewayPermissionActions.EditGateways]: false, + [OrgGatewayPermissionActions.CreateGateways]: false, + [OrgGatewayPermissionActions.DeleteGateways]: false + }, + { shouldDirty: true } + ); + } + }; + + return ( + <> + setIsRowExpanded.toggle()} + > + + + + Gateways + + + + + {isRowExpanded && ( + + +
+ {PERMISSION_ACTIONS.map(({ action, label }) => { + return ( + ( + { + if (!isEditable) { + createNotification({ + type: "error", + text: "Failed to update default role" + }); + return; + } + field.onChange(e); + }} + id={`permissions.gateways.${action}`} + > + {label} + + )} + /> + ); + })} +
+ + + )} + + ); +}; diff --git a/frontend/src/pages/organization/RoleByIDPage/components/RolePermissionsSection/RolePermissionRow.tsx b/frontend/src/pages/organization/RoleByIDPage/components/RolePermissionsSection/RolePermissionRow.tsx index 0820cbf5a..aed309d04 100644 --- a/frontend/src/pages/organization/RoleByIDPage/components/RolePermissionsSection/RolePermissionRow.tsx +++ b/frontend/src/pages/organization/RoleByIDPage/components/RolePermissionsSection/RolePermissionRow.tsx @@ -74,7 +74,7 @@ type Props = { title: string; formName: keyof Omit< Exclude, - "workspace" | "organization-admin-console" | "kmip" + "workspace" | "organization-admin-console" | "kmip" | "gateway" >; setValue: UseFormSetValue; control: Control; diff --git a/frontend/src/pages/organization/RoleByIDPage/components/RolePermissionsSection/RolePermissionsSection.tsx b/frontend/src/pages/organization/RoleByIDPage/components/RolePermissionsSection/RolePermissionsSection.tsx index 9f66e358a..de9fbde80 100644 --- a/frontend/src/pages/organization/RoleByIDPage/components/RolePermissionsSection/RolePermissionsSection.tsx +++ b/frontend/src/pages/organization/RoleByIDPage/components/RolePermissionsSection/RolePermissionsSection.tsx @@ -14,6 +14,7 @@ import { TFormSchema } from "../OrgRoleModifySection.utils"; import { OrgPermissionAdminConsoleRow } from "./OrgPermissionAdminConsoleRow"; +import { OrgGatewayPermissionRow } from "./OrgPermissionGatewayRow"; import { OrgPermissionKmipRow } from "./OrgPermissionKmipRow"; import { OrgRoleWorkspaceRow } from "./OrgRoleWorkspaceRow"; import { RolePermissionRow } from "./RolePermissionRow"; @@ -171,6 +172,11 @@ export const RolePermissionsSection = ({ roleId }: Props) => { setValue={setValue} isEditable={isCustomRole} /> + { const valMs = ms(val); @@ -124,6 +127,8 @@ export const SqlDatabaseInputForm = ({ secretPath, projectSlug }: Props) => { + const { currentWorkspace } = useWorkspace(); + const { control, setValue, @@ -137,6 +142,9 @@ export const SqlDatabaseInputForm = ({ }); const createDynamicSecret = useCreateDynamicSecret(); + const { data: projectGateways, isPending: isProjectGatewaysLoading } = useQuery( + gatewaysQueryKeys.listProjectGateways({ projectId: currentWorkspace.id }) + ); const handleCreateDynamicSecret = async ({ name, maxTTL, provider, defaultTTL }: TForm) => { // wait till previous request is finished @@ -222,6 +230,42 @@ export const SqlDatabaseInputForm = ({ /> +
+ ( + + + + )} + /> +
Configuration diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretSqlProviderForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretSqlProviderForm.tsx index 18543502f..493806258 100644 --- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretSqlProviderForm.tsx +++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretSqlProviderForm.tsx @@ -1,5 +1,6 @@ import { Controller, useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; +import { useQuery } from "@tanstack/react-query"; import ms from "ms"; import { z } from "zod"; @@ -18,7 +19,8 @@ import { SelectItem, TextArea } from "@app/components/v2"; -import { useUpdateDynamicSecret } from "@app/hooks/api"; +import { useWorkspace } from "@app/context"; +import { gatewaysQueryKeys, useUpdateDynamicSecret } from "@app/hooks/api"; import { SqlProviders, TDynamicSecret } from "@app/hooks/api/dynamicSecret/types"; const formSchema = z.object({ @@ -33,7 +35,8 @@ const formSchema = z.object({ creationStatement: z.string().min(1), revocationStatement: z.string().min(1), renewStatement: z.string().optional(), - ca: z.string().optional() + ca: z.string().optional(), + projectGatewayId: z.string().optional() }) .partial(), defaultTTL: z.string().superRefine((val, ctx) => { @@ -81,6 +84,7 @@ export const EditDynamicSecretSqlProviderForm = ({ }: Props) => { const { control, + watch, formState: { isSubmitting }, handleSubmit } = useForm({ @@ -94,8 +98,15 @@ export const EditDynamicSecretSqlProviderForm = ({ } } }); + const { currentWorkspace } = useWorkspace(); + const { data: projectGateways, isPending: isProjectGatewaysLoading } = useQuery( + gatewaysQueryKeys.listProjectGateways({ projectId: currentWorkspace.id }) + ); const updateDynamicSecret = useUpdateDynamicSecret(); + const selectedProjectGatewayId = watch("inputs.projectGatewayId"); + const isGatewayInActive = + projectGateways?.findIndex((el) => el.projectGatewayId === selectedProjectGatewayId) === -1; const handleUpdateDynamicSecret = async ({ inputs, maxTTL, defaultTTL, newName }: TForm) => { // wait till previous request is finished @@ -109,7 +120,10 @@ export const EditDynamicSecretSqlProviderForm = ({ data: { maxTTL: maxTTL || undefined, defaultTTL, - inputs, + inputs: { + ...inputs, + projectGatewayId: isGatewayInActive ? null : inputs.projectGatewayId + }, newName: newName === dynamicSecret.name ? undefined : newName } }); @@ -176,6 +190,44 @@ export const EditDynamicSecretSqlProviderForm = ({ />
+
+ ( + + + + )} + /> +
Configuration
diff --git a/frontend/src/routeTree.gen.ts b/frontend/src/routeTree.gen.ts index 3b7f260ad..aa74e98ad 100644 --- a/frontend/src/routeTree.gen.ts +++ b/frontend/src/routeTree.gen.ts @@ -60,6 +60,7 @@ import { Route as organizationKmsOverviewPageRouteImport } from './pages/organiz import { Route as organizationIdentityDetailsByIDPageRouteImport } from './pages/organization/IdentityDetailsByIDPage/route' import { Route as organizationGroupDetailsByIDPageRouteImport } from './pages/organization/GroupDetailsByIDPage/route' import { Route as organizationCertManagerOverviewPageRouteImport } from './pages/organization/CertManagerOverviewPage/route' +import { Route as organizationGatewaysGatewayListPageRouteImport } from './pages/organization/Gateways/GatewayListPage/route' import { Route as organizationAppConnectionsAppConnectionsPageRouteImport } from './pages/organization/AppConnections/AppConnectionsPage/route' import { Route as projectAccessControlPageRouteSshImport } from './pages/project/AccessControlPage/route-ssh' import { Route as projectAccessControlPageRouteSecretManagerImport } from './pages/project/AccessControlPage/route-secret-manager' @@ -209,6 +210,10 @@ const AuthenticateInjectOrgDetailsOrgLayoutSecretManagerProjectIdImport = createFileRoute( '/_authenticate/_inject-org-details/_org-layout/secret-manager/$projectId', )() +const AuthenticateInjectOrgDetailsOrgLayoutOrganizationGatewaysImport = + createFileRoute( + '/_authenticate/_inject-org-details/_org-layout/organization/gateways', + )() const AuthenticateInjectOrgDetailsOrgLayoutOrganizationAppConnectionsImport = createFileRoute( '/_authenticate/_inject-org-details/_org-layout/organization/app-connections', @@ -454,6 +459,14 @@ const AuthenticateInjectOrgDetailsOrgLayoutSecretManagerProjectIdRoute = getParentRoute: () => organizationLayoutRoute, } as any) +const AuthenticateInjectOrgDetailsOrgLayoutOrganizationGatewaysRoute = + AuthenticateInjectOrgDetailsOrgLayoutOrganizationGatewaysImport.update({ + id: '/gateways', + path: '/gateways', + getParentRoute: () => + AuthenticateInjectOrgDetailsOrgLayoutOrganizationRoute, + } as any) + const AuthenticateInjectOrgDetailsOrgLayoutOrganizationAppConnectionsRoute = AuthenticateInjectOrgDetailsOrgLayoutOrganizationAppConnectionsImport.update({ id: '/app-connections', @@ -625,6 +638,14 @@ const organizationCertManagerOverviewPageRouteRoute = AuthenticateInjectOrgDetailsOrgLayoutOrganizationRoute, } as any) +const organizationGatewaysGatewayListPageRouteRoute = + organizationGatewaysGatewayListPageRouteImport.update({ + id: '/', + path: '/', + getParentRoute: () => + AuthenticateInjectOrgDetailsOrgLayoutOrganizationGatewaysRoute, + } as any) + const organizationAppConnectionsAppConnectionsPageRouteRoute = organizationAppConnectionsAppConnectionsPageRouteImport.update({ id: '/', @@ -1886,6 +1907,13 @@ declare module '@tanstack/react-router' { preLoaderRoute: typeof AuthenticateInjectOrgDetailsOrgLayoutOrganizationAppConnectionsImport parentRoute: typeof AuthenticateInjectOrgDetailsOrgLayoutOrganizationImport } + '/_authenticate/_inject-org-details/_org-layout/organization/gateways': { + id: '/_authenticate/_inject-org-details/_org-layout/organization/gateways' + path: '/gateways' + fullPath: '/organization/gateways' + preLoaderRoute: typeof AuthenticateInjectOrgDetailsOrgLayoutOrganizationGatewaysImport + parentRoute: typeof AuthenticateInjectOrgDetailsOrgLayoutOrganizationImport + } '/_authenticate/_inject-org-details/_org-layout/secret-manager/$projectId': { id: '/_authenticate/_inject-org-details/_org-layout/secret-manager/$projectId' path: '/secret-manager/$projectId' @@ -1907,6 +1935,13 @@ declare module '@tanstack/react-router' { preLoaderRoute: typeof organizationAppConnectionsAppConnectionsPageRouteImport parentRoute: typeof AuthenticateInjectOrgDetailsOrgLayoutOrganizationAppConnectionsImport } + '/_authenticate/_inject-org-details/_org-layout/organization/gateways/': { + id: '/_authenticate/_inject-org-details/_org-layout/organization/gateways/' + path: '/' + fullPath: '/organization/gateways/' + preLoaderRoute: typeof organizationGatewaysGatewayListPageRouteImport + parentRoute: typeof AuthenticateInjectOrgDetailsOrgLayoutOrganizationGatewaysImport + } '/_authenticate/_inject-org-details/_org-layout/organization/cert-manager/overview': { id: '/_authenticate/_inject-org-details/_org-layout/organization/cert-manager/overview' path: '/cert-manager/overview' @@ -2900,6 +2935,21 @@ const AuthenticateInjectOrgDetailsOrgLayoutOrganizationAppConnectionsRouteWithCh AuthenticateInjectOrgDetailsOrgLayoutOrganizationAppConnectionsRouteChildren, ) +interface AuthenticateInjectOrgDetailsOrgLayoutOrganizationGatewaysRouteChildren { + organizationGatewaysGatewayListPageRouteRoute: typeof organizationGatewaysGatewayListPageRouteRoute +} + +const AuthenticateInjectOrgDetailsOrgLayoutOrganizationGatewaysRouteChildren: AuthenticateInjectOrgDetailsOrgLayoutOrganizationGatewaysRouteChildren = + { + organizationGatewaysGatewayListPageRouteRoute: + organizationGatewaysGatewayListPageRouteRoute, + } + +const AuthenticateInjectOrgDetailsOrgLayoutOrganizationGatewaysRouteWithChildren = + AuthenticateInjectOrgDetailsOrgLayoutOrganizationGatewaysRoute._addFileChildren( + AuthenticateInjectOrgDetailsOrgLayoutOrganizationGatewaysRouteChildren, + ) + interface AuthenticateInjectOrgDetailsOrgLayoutOrganizationRouteChildren { organizationAccessManagementPageRouteRoute: typeof organizationAccessManagementPageRouteRoute organizationAdminPageRouteRoute: typeof organizationAdminPageRouteRoute @@ -2909,6 +2959,7 @@ interface AuthenticateInjectOrgDetailsOrgLayoutOrganizationRouteChildren { organizationSecretSharingPageRouteRoute: typeof organizationSecretSharingPageRouteRoute organizationSettingsPageRouteRoute: typeof organizationSettingsPageRouteRoute AuthenticateInjectOrgDetailsOrgLayoutOrganizationAppConnectionsRoute: typeof AuthenticateInjectOrgDetailsOrgLayoutOrganizationAppConnectionsRouteWithChildren + AuthenticateInjectOrgDetailsOrgLayoutOrganizationGatewaysRoute: typeof AuthenticateInjectOrgDetailsOrgLayoutOrganizationGatewaysRouteWithChildren organizationCertManagerOverviewPageRouteRoute: typeof organizationCertManagerOverviewPageRouteRoute organizationGroupDetailsByIDPageRouteRoute: typeof organizationGroupDetailsByIDPageRouteRoute organizationIdentityDetailsByIDPageRouteRoute: typeof organizationIdentityDetailsByIDPageRouteRoute @@ -2933,6 +2984,8 @@ const AuthenticateInjectOrgDetailsOrgLayoutOrganizationRouteChildren: Authentica organizationSettingsPageRouteRoute: organizationSettingsPageRouteRoute, AuthenticateInjectOrgDetailsOrgLayoutOrganizationAppConnectionsRoute: AuthenticateInjectOrgDetailsOrgLayoutOrganizationAppConnectionsRouteWithChildren, + AuthenticateInjectOrgDetailsOrgLayoutOrganizationGatewaysRoute: + AuthenticateInjectOrgDetailsOrgLayoutOrganizationGatewaysRouteWithChildren, organizationCertManagerOverviewPageRouteRoute: organizationCertManagerOverviewPageRouteRoute, organizationGroupDetailsByIDPageRouteRoute: @@ -3608,9 +3661,11 @@ export interface FileRoutesByFullPath { '/cert-manager/$projectId': typeof certManagerLayoutRouteWithChildren '/kms/$projectId': typeof kmsLayoutRouteWithChildren '/organization/app-connections': typeof AuthenticateInjectOrgDetailsOrgLayoutOrganizationAppConnectionsRouteWithChildren + '/organization/gateways': typeof AuthenticateInjectOrgDetailsOrgLayoutOrganizationGatewaysRouteWithChildren '/secret-manager/$projectId': typeof secretManagerLayoutRouteWithChildren '/ssh/$projectId': typeof sshLayoutRouteWithChildren '/organization/app-connections/': typeof organizationAppConnectionsAppConnectionsPageRouteRoute + '/organization/gateways/': typeof organizationGatewaysGatewayListPageRouteRoute '/organization/cert-manager/overview': typeof organizationCertManagerOverviewPageRouteRoute '/organization/groups/$groupId': typeof organizationGroupDetailsByIDPageRouteRoute '/organization/identities/$identityId': typeof organizationIdentityDetailsByIDPageRouteRoute @@ -3780,6 +3835,7 @@ export interface FileRoutesByTo { '/secret-manager/$projectId': typeof secretManagerLayoutRouteWithChildren '/ssh/$projectId': typeof sshLayoutRouteWithChildren '/organization/app-connections': typeof organizationAppConnectionsAppConnectionsPageRouteRoute + '/organization/gateways': typeof organizationGatewaysGatewayListPageRouteRoute '/organization/cert-manager/overview': typeof organizationCertManagerOverviewPageRouteRoute '/organization/groups/$groupId': typeof organizationGroupDetailsByIDPageRouteRoute '/organization/identities/$identityId': typeof organizationIdentityDetailsByIDPageRouteRoute @@ -3956,9 +4012,11 @@ export interface FileRoutesById { '/_authenticate/_inject-org-details/_org-layout/cert-manager/$projectId': typeof AuthenticateInjectOrgDetailsOrgLayoutCertManagerProjectIdRouteWithChildren '/_authenticate/_inject-org-details/_org-layout/kms/$projectId': typeof AuthenticateInjectOrgDetailsOrgLayoutKmsProjectIdRouteWithChildren '/_authenticate/_inject-org-details/_org-layout/organization/app-connections': typeof AuthenticateInjectOrgDetailsOrgLayoutOrganizationAppConnectionsRouteWithChildren + '/_authenticate/_inject-org-details/_org-layout/organization/gateways': typeof AuthenticateInjectOrgDetailsOrgLayoutOrganizationGatewaysRouteWithChildren '/_authenticate/_inject-org-details/_org-layout/secret-manager/$projectId': typeof AuthenticateInjectOrgDetailsOrgLayoutSecretManagerProjectIdRouteWithChildren '/_authenticate/_inject-org-details/_org-layout/ssh/$projectId': typeof AuthenticateInjectOrgDetailsOrgLayoutSshProjectIdRouteWithChildren '/_authenticate/_inject-org-details/_org-layout/organization/app-connections/': typeof organizationAppConnectionsAppConnectionsPageRouteRoute + '/_authenticate/_inject-org-details/_org-layout/organization/gateways/': typeof organizationGatewaysGatewayListPageRouteRoute '/_authenticate/_inject-org-details/_org-layout/organization/cert-manager/overview': typeof organizationCertManagerOverviewPageRouteRoute '/_authenticate/_inject-org-details/_org-layout/organization/groups/$groupId': typeof organizationGroupDetailsByIDPageRouteRoute '/_authenticate/_inject-org-details/_org-layout/organization/identities/$identityId': typeof organizationIdentityDetailsByIDPageRouteRoute @@ -4136,9 +4194,11 @@ export interface FileRouteTypes { | '/cert-manager/$projectId' | '/kms/$projectId' | '/organization/app-connections' + | '/organization/gateways' | '/secret-manager/$projectId' | '/ssh/$projectId' | '/organization/app-connections/' + | '/organization/gateways/' | '/organization/cert-manager/overview' | '/organization/groups/$groupId' | '/organization/identities/$identityId' @@ -4307,6 +4367,7 @@ export interface FileRouteTypes { | '/secret-manager/$projectId' | '/ssh/$projectId' | '/organization/app-connections' + | '/organization/gateways' | '/organization/cert-manager/overview' | '/organization/groups/$groupId' | '/organization/identities/$identityId' @@ -4481,9 +4542,11 @@ export interface FileRouteTypes { | '/_authenticate/_inject-org-details/_org-layout/cert-manager/$projectId' | '/_authenticate/_inject-org-details/_org-layout/kms/$projectId' | '/_authenticate/_inject-org-details/_org-layout/organization/app-connections' + | '/_authenticate/_inject-org-details/_org-layout/organization/gateways' | '/_authenticate/_inject-org-details/_org-layout/secret-manager/$projectId' | '/_authenticate/_inject-org-details/_org-layout/ssh/$projectId' | '/_authenticate/_inject-org-details/_org-layout/organization/app-connections/' + | '/_authenticate/_inject-org-details/_org-layout/organization/gateways/' | '/_authenticate/_inject-org-details/_org-layout/organization/cert-manager/overview' | '/_authenticate/_inject-org-details/_org-layout/organization/groups/$groupId' | '/_authenticate/_inject-org-details/_org-layout/organization/identities/$identityId' @@ -4848,6 +4911,7 @@ export const routeTree = rootRoute "/_authenticate/_inject-org-details/_org-layout/organization/secret-sharing", "/_authenticate/_inject-org-details/_org-layout/organization/settings", "/_authenticate/_inject-org-details/_org-layout/organization/app-connections", + "/_authenticate/_inject-org-details/_org-layout/organization/gateways", "/_authenticate/_inject-org-details/_org-layout/organization/cert-manager/overview", "/_authenticate/_inject-org-details/_org-layout/organization/groups/$groupId", "/_authenticate/_inject-org-details/_org-layout/organization/identities/$identityId", @@ -4919,6 +4983,13 @@ export const routeTree = rootRoute "/_authenticate/_inject-org-details/_org-layout/organization/app-connections/$appConnection/oauth/callback" ] }, + "/_authenticate/_inject-org-details/_org-layout/organization/gateways": { + "filePath": "", + "parent": "/_authenticate/_inject-org-details/_org-layout/organization", + "children": [ + "/_authenticate/_inject-org-details/_org-layout/organization/gateways/" + ] + }, "/_authenticate/_inject-org-details/_org-layout/secret-manager/$projectId": { "filePath": "", "parent": "/_authenticate/_inject-org-details/_org-layout", @@ -4937,6 +5008,10 @@ export const routeTree = rootRoute "filePath": "organization/AppConnections/AppConnectionsPage/route.tsx", "parent": "/_authenticate/_inject-org-details/_org-layout/organization/app-connections" }, + "/_authenticate/_inject-org-details/_org-layout/organization/gateways/": { + "filePath": "organization/Gateways/GatewayListPage/route.tsx", + "parent": "/_authenticate/_inject-org-details/_org-layout/organization/gateways" + }, "/_authenticate/_inject-org-details/_org-layout/organization/cert-manager/overview": { "filePath": "organization/CertManagerOverviewPage/route.tsx", "parent": "/_authenticate/_inject-org-details/_org-layout/organization" diff --git a/frontend/src/routes.ts b/frontend/src/routes.ts index d1c64d47e..bc04e9631 100644 --- a/frontend/src/routes.ts +++ b/frontend/src/routes.ts @@ -29,7 +29,8 @@ const organizationRoutes = route("/organization", [ "/$appConnection/oauth/callback", "organization/AppConnections/OauthCallbackPage/route.tsx" ) - ]) + ]), + route("/gateways", [index("organization/Gateways/GatewayListPage/route.tsx")]) ]); const secretManagerRoutes = route("/secret-manager/$projectId", [ diff --git a/sink/docker-compose.coturn.yml b/sink/docker-compose.coturn.yml new file mode 100644 index 000000000..e69de29bb