mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-15 14:27:23 +00:00
misc: updated proxy terminology to relay
This commit is contained in:
@@ -23,8 +23,8 @@ import { registerOrgRoleRouter } from "./org-role-router";
|
||||
import { registerPITRouter } from "./pit-router";
|
||||
import { registerProjectRoleRouter } from "./project-role-router";
|
||||
import { registerProjectRouter } from "./project-router";
|
||||
import { registerProxyRouter } from "./proxy-router";
|
||||
import { registerRateLimitRouter } from "./rate-limit-router";
|
||||
import { registerRelayRouter } from "./relay-router";
|
||||
import { registerSamlRouter } from "./saml-router";
|
||||
import { registerScimRouter } from "./scim-router";
|
||||
import { registerSecretApprovalPolicyRouter } from "./secret-approval-policy-router";
|
||||
@@ -80,7 +80,7 @@ export const registerV1EERoutes = async (server: FastifyZodProvider) => {
|
||||
);
|
||||
|
||||
await server.register(registerGatewayRouter, { prefix: "/gateways" });
|
||||
await server.register(registerProxyRouter, { prefix: "/proxies" });
|
||||
await server.register(registerRelayRouter, { prefix: "/relays" });
|
||||
await server.register(registerGithubOrgSyncRouter, { prefix: "/github-org-sync-config" });
|
||||
|
||||
await server.register(
|
||||
|
||||
@@ -7,12 +7,12 @@ import { writeLimit } from "@app/server/config/rateLimiter";
|
||||
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
|
||||
import { AuthMode } from "@app/services/auth/auth-type";
|
||||
|
||||
export const registerProxyRouter = async (server: FastifyZodProvider) => {
|
||||
export const registerRelayRouter = async (server: FastifyZodProvider) => {
|
||||
const appCfg = getConfig();
|
||||
|
||||
server.route({
|
||||
method: "POST",
|
||||
url: "/register-instance-proxy",
|
||||
url: "/register-instance-relay",
|
||||
config: {
|
||||
rateLimit: writeLimit
|
||||
},
|
||||
@@ -39,8 +39,8 @@ export const registerProxyRouter = async (server: FastifyZodProvider) => {
|
||||
onRequest: (req, _, next) => {
|
||||
const authHeader = req.headers.authorization;
|
||||
|
||||
if (appCfg.PROXY_AUTH_SECRET && authHeader) {
|
||||
const expectedHeader = `Bearer ${appCfg.PROXY_AUTH_SECRET}`;
|
||||
if (appCfg.RELAY_AUTH_SECRET && authHeader) {
|
||||
const expectedHeader = `Bearer ${appCfg.RELAY_AUTH_SECRET}`;
|
||||
if (
|
||||
authHeader.length === expectedHeader.length &&
|
||||
crypto.nativeCrypto.timingSafeEqual(Buffer.from(authHeader), Buffer.from(expectedHeader))
|
||||
@@ -50,11 +50,11 @@ export const registerProxyRouter = async (server: FastifyZodProvider) => {
|
||||
}
|
||||
|
||||
throw new UnauthorizedError({
|
||||
message: "Invalid proxy auth secret"
|
||||
message: "Invalid relay auth secret"
|
||||
});
|
||||
},
|
||||
handler: async (req) => {
|
||||
return server.services.proxy.registerProxy({
|
||||
return server.services.relay.registerRelay({
|
||||
...req.body
|
||||
});
|
||||
}
|
||||
@@ -62,7 +62,7 @@ export const registerProxyRouter = async (server: FastifyZodProvider) => {
|
||||
|
||||
server.route({
|
||||
method: "POST",
|
||||
url: "/register-org-proxy",
|
||||
url: "/register-org-relay",
|
||||
config: {
|
||||
rateLimit: writeLimit
|
||||
},
|
||||
@@ -89,10 +89,10 @@ export const registerProxyRouter = async (server: FastifyZodProvider) => {
|
||||
onRequest: verifyAuth([AuthMode.IDENTITY_ACCESS_TOKEN]),
|
||||
handler: async (req) => {
|
||||
throw new BadRequestError({
|
||||
message: "Org proxy registration is not yet supported"
|
||||
message: "Org relay registration is not yet supported"
|
||||
});
|
||||
|
||||
return server.services.proxy.registerProxy({
|
||||
return server.services.relay.registerRelay({
|
||||
...req.body,
|
||||
identityId: req.permission.id,
|
||||
orgId: req.permission.orgId
|
||||
@@ -79,9 +79,9 @@ export const KubernetesProvider = ({
|
||||
);
|
||||
},
|
||||
{
|
||||
proxyIp: gatewayV2ConnectionDetails.proxyIp,
|
||||
relayIp: gatewayV2ConnectionDetails.relayIp,
|
||||
gateway: gatewayV2ConnectionDetails.gateway,
|
||||
proxy: gatewayV2ConnectionDetails.proxy,
|
||||
relay: gatewayV2ConnectionDetails.relay,
|
||||
protocol: inputs.reviewTokenThroughGateway ? GatewayProxyProtocol.Http : GatewayProxyProtocol.Tcp,
|
||||
httpsAgent: inputs.httpsAgent
|
||||
}
|
||||
|
||||
@@ -201,9 +201,9 @@ export const SqlDatabaseProvider = ({
|
||||
await gatewayCallback("localhost", port);
|
||||
},
|
||||
{
|
||||
proxyIp: gatewayV2ConnectionDetails.proxyIp,
|
||||
relayIp: gatewayV2ConnectionDetails.relayIp,
|
||||
gateway: gatewayV2ConnectionDetails.gateway,
|
||||
proxy: gatewayV2ConnectionDetails.proxy,
|
||||
relay: gatewayV2ConnectionDetails.relay,
|
||||
protocol: GatewayProxyProtocol.Tcp
|
||||
}
|
||||
);
|
||||
|
||||
@@ -3,7 +3,7 @@ import net from "node:net";
|
||||
import { ForbiddenError } from "@casl/ability";
|
||||
import * as x509 from "@peculiar/x509";
|
||||
|
||||
import { TProxies } from "@app/db/schemas";
|
||||
import { TRelays } from "@app/db/schemas";
|
||||
import { PgSqlLock } from "@app/keystore/keystore";
|
||||
import { crypto } from "@app/lib/crypto";
|
||||
import { DatabaseErrorCode } from "@app/lib/error-codes";
|
||||
@@ -24,9 +24,9 @@ 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-types";
|
||||
import { TProxyDALFactory } from "../proxy/proxy-dal";
|
||||
import { isInstanceProxy } from "../proxy/proxy-fns";
|
||||
import { TProxyServiceFactory } from "../proxy/proxy-service";
|
||||
import { TRelayDALFactory } from "../relay/relay-dal";
|
||||
import { isInstanceRelay } from "../relay/relay-fns";
|
||||
import { TRelayServiceFactory } from "../relay/relay-service";
|
||||
import { GATEWAY_ACTOR_OID, GATEWAY_ROUTING_INFO_OID } from "./gateway-v2-constants";
|
||||
import { TGatewayV2DALFactory } from "./gateway-v2-dal";
|
||||
import { TOrgGatewayConfigV2DALFactory } from "./org-gateway-config-v2-dal";
|
||||
@@ -35,9 +35,9 @@ type TGatewayV2ServiceFactoryDep = {
|
||||
orgGatewayConfigV2DAL: Pick<TOrgGatewayConfigV2DALFactory, "findOne" | "create" | "transaction" | "findById">;
|
||||
licenseService: Pick<TLicenseServiceFactory, "onPremFeatures" | "getPlan">;
|
||||
kmsService: TKmsServiceFactory;
|
||||
proxyService: TProxyServiceFactory;
|
||||
relayService: TRelayServiceFactory;
|
||||
gatewayV2DAL: TGatewayV2DALFactory;
|
||||
proxyDAL: TProxyDALFactory;
|
||||
relayDAL: TRelayDALFactory;
|
||||
permissionService: TPermissionServiceFactory;
|
||||
};
|
||||
|
||||
@@ -47,9 +47,9 @@ export const gatewayV2ServiceFactory = ({
|
||||
orgGatewayConfigV2DAL,
|
||||
licenseService,
|
||||
kmsService,
|
||||
proxyService,
|
||||
relayService,
|
||||
gatewayV2DAL,
|
||||
proxyDAL,
|
||||
relayDAL,
|
||||
permissionService
|
||||
}: TGatewayV2ServiceFactoryDep) => {
|
||||
const $validateIdentityAccessToGateway = async (orgId: string, actorId: string, actorAuthMethod: ActorAuthMethod) => {
|
||||
@@ -285,9 +285,9 @@ export const gatewayV2ServiceFactory = ({
|
||||
throw new NotFoundError({ message: `Gateway Config for org ${gateway.orgId} not found.` });
|
||||
}
|
||||
|
||||
if (!gateway.proxyId) {
|
||||
if (!gateway.relayId) {
|
||||
throw new BadRequestError({
|
||||
message: "Gateway is not associated with a proxy"
|
||||
message: "Gateway is not associated with a relay"
|
||||
});
|
||||
}
|
||||
|
||||
@@ -392,23 +392,23 @@ export const gatewayV2ServiceFactory = ({
|
||||
|
||||
const gatewayClientCertPrivateKey = crypto.nativeCrypto.KeyObject.from(clientKeys.privateKey);
|
||||
|
||||
const proxyCredentials = await proxyService.getCredentialsForClient({
|
||||
proxyId: gateway.proxyId,
|
||||
const relayCredentials = await relayService.getCredentialsForClient({
|
||||
relayId: gateway.relayId,
|
||||
orgId: gateway.orgId,
|
||||
gatewayId
|
||||
});
|
||||
|
||||
return {
|
||||
proxyIp: proxyCredentials.proxyIp,
|
||||
relayIp: relayCredentials.relayIp,
|
||||
gateway: {
|
||||
clientCertificate: clientCert.toString("pem"),
|
||||
clientPrivateKey: gatewayClientCertPrivateKey.export({ format: "pem", type: "pkcs8" }).toString(),
|
||||
serverCertificateChain: constructPemChainFromCerts([gatewayServerCaCert, rootGatewayCaCert])
|
||||
},
|
||||
proxy: {
|
||||
clientCertificate: proxyCredentials.clientCertificate,
|
||||
clientPrivateKey: proxyCredentials.clientPrivateKey,
|
||||
serverCertificateChain: proxyCredentials.serverCertificateChain
|
||||
relay: {
|
||||
clientCertificate: relayCredentials.clientCertificate,
|
||||
clientPrivateKey: relayCredentials.clientPrivateKey,
|
||||
serverCertificateChain: relayCredentials.serverCertificateChain
|
||||
}
|
||||
};
|
||||
};
|
||||
@@ -417,27 +417,27 @@ export const gatewayV2ServiceFactory = ({
|
||||
orgId,
|
||||
actorId,
|
||||
actorAuthMethod,
|
||||
proxyName,
|
||||
relayName,
|
||||
name
|
||||
}: {
|
||||
orgId: string;
|
||||
actorId: string;
|
||||
actorAuthMethod: ActorAuthMethod;
|
||||
proxyName: string;
|
||||
relayName: string;
|
||||
name: string;
|
||||
}) => {
|
||||
await $validateIdentityAccessToGateway(orgId, actorId, actorAuthMethod);
|
||||
const orgCAs = await $getOrgCAs(orgId);
|
||||
|
||||
let proxy: TProxies;
|
||||
if (isInstanceProxy(proxyName)) {
|
||||
proxy = await proxyDAL.findOne({ name: proxyName });
|
||||
let relay: TRelays;
|
||||
if (isInstanceRelay(relayName)) {
|
||||
relay = await relayDAL.findOne({ name: relayName });
|
||||
} else {
|
||||
proxy = await proxyDAL.findOne({ orgId, name: proxyName });
|
||||
relay = await relayDAL.findOne({ orgId, name: relayName });
|
||||
}
|
||||
|
||||
if (!proxy) {
|
||||
throw new NotFoundError({ message: `Proxy ${proxyName} not found` });
|
||||
if (!relay) {
|
||||
throw new NotFoundError({ message: `Relay ${relayName} not found` });
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -447,7 +447,7 @@ export const gatewayV2ServiceFactory = ({
|
||||
orgId,
|
||||
name,
|
||||
identityId: actorId,
|
||||
proxyId: proxy.id
|
||||
relayId: relay.id
|
||||
}
|
||||
],
|
||||
["identityId"]
|
||||
@@ -507,24 +507,24 @@ export const gatewayV2ServiceFactory = ({
|
||||
extensions: gatewayServerCertExtensions
|
||||
});
|
||||
|
||||
const proxyCredentials = await proxyService.getCredentialsForGateway({
|
||||
proxyName,
|
||||
const relayCredentials = await relayService.getCredentialsForGateway({
|
||||
relayName,
|
||||
orgId,
|
||||
gatewayId: gateway.id
|
||||
});
|
||||
|
||||
return {
|
||||
gatewayId: gateway.id,
|
||||
proxyIp: proxyCredentials.proxyIp,
|
||||
relayIp: relayCredentials.relayIp,
|
||||
pki: {
|
||||
serverCertificate: gatewayServerCertificate.toString("pem"),
|
||||
serverPrivateKey: gatewayServerCertPrivateKey.export({ format: "pem", type: "pkcs8" }).toString(),
|
||||
clientCertificateChain: constructPemChainFromCerts([gatewayClientCaCert, rootGatewayCaCert])
|
||||
},
|
||||
ssh: {
|
||||
clientCertificate: proxyCredentials.clientSshCert,
|
||||
clientPrivateKey: proxyCredentials.clientSshPrivateKey,
|
||||
serverCAPublicKey: proxyCredentials.serverCAPublicKey
|
||||
clientCertificate: relayCredentials.clientSshCert,
|
||||
clientPrivateKey: relayCredentials.clientSshPrivateKey,
|
||||
serverCAPublicKey: relayCredentials.serverCAPublicKey
|
||||
}
|
||||
};
|
||||
} catch (err) {
|
||||
@@ -613,9 +613,9 @@ export const gatewayV2ServiceFactory = ({
|
||||
},
|
||||
{
|
||||
protocol: GatewayProxyProtocol.Ping,
|
||||
proxyIp: gatewayV2ConnectionDetails.proxyIp,
|
||||
relayIp: gatewayV2ConnectionDetails.relayIp,
|
||||
gateway: gatewayV2ConnectionDetails.gateway,
|
||||
proxy: gatewayV2ConnectionDetails.proxy
|
||||
relay: gatewayV2ConnectionDetails.relay
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
import { TDbClient } from "@app/db";
|
||||
import { TableName } from "@app/db/schemas";
|
||||
import { ormify } from "@app/lib/knex";
|
||||
|
||||
export type TInstanceProxyConfigDALFactory = ReturnType<typeof instanceProxyConfigDalFactory>;
|
||||
|
||||
export const instanceProxyConfigDalFactory = (db: TDbClient) => {
|
||||
const orm = ormify(db, TableName.InstanceProxyConfig);
|
||||
|
||||
return orm;
|
||||
};
|
||||
@@ -1,11 +0,0 @@
|
||||
import { TDbClient } from "@app/db";
|
||||
import { TableName } from "@app/db/schemas";
|
||||
import { ormify } from "@app/lib/knex";
|
||||
|
||||
export type TOrgProxyConfigDALFactory = ReturnType<typeof orgProxyConfigDalFactory>;
|
||||
|
||||
export const orgProxyConfigDalFactory = (db: TDbClient) => {
|
||||
const orm = ormify(db, TableName.OrgProxyConfig);
|
||||
|
||||
return orm;
|
||||
};
|
||||
@@ -1,11 +0,0 @@
|
||||
import { TDbClient } from "@app/db";
|
||||
import { TableName } from "@app/db/schemas";
|
||||
import { ormify } from "@app/lib/knex";
|
||||
|
||||
export type TProxyDALFactory = ReturnType<typeof proxyDalFactory>;
|
||||
|
||||
export const proxyDalFactory = (db: TDbClient) => {
|
||||
const orm = ormify(db, TableName.Proxy);
|
||||
|
||||
return orm;
|
||||
};
|
||||
@@ -1,5 +0,0 @@
|
||||
export const INSTANCE_PROXY_PREFIX = "infisical-";
|
||||
|
||||
export const isInstanceProxy = (proxyName: string) => {
|
||||
return proxyName.startsWith(INSTANCE_PROXY_PREFIX);
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
||||
import { TDbClient } from "@app/db";
|
||||
import { TableName } from "@app/db/schemas";
|
||||
import { ormify } from "@app/lib/knex";
|
||||
|
||||
export type TInstanceRelayConfigDALFactory = ReturnType<typeof instanceRelayConfigDalFactory>;
|
||||
|
||||
export const instanceRelayConfigDalFactory = (db: TDbClient) => {
|
||||
const orm = ormify(db, TableName.InstanceRelayConfig);
|
||||
|
||||
return orm;
|
||||
};
|
||||
@@ -0,0 +1,11 @@
|
||||
import { TDbClient } from "@app/db";
|
||||
import { TableName } from "@app/db/schemas";
|
||||
import { ormify } from "@app/lib/knex";
|
||||
|
||||
export type TOrgRelayConfigDALFactory = ReturnType<typeof orgRelayConfigDalFactory>;
|
||||
|
||||
export const orgRelayConfigDalFactory = (db: TDbClient) => {
|
||||
const orm = ormify(db, TableName.OrgRelayConfig);
|
||||
|
||||
return orm;
|
||||
};
|
||||
@@ -0,0 +1,11 @@
|
||||
import { TDbClient } from "@app/db";
|
||||
import { TableName } from "@app/db/schemas";
|
||||
import { ormify } from "@app/lib/knex";
|
||||
|
||||
export type TRelayDALFactory = ReturnType<typeof relayDalFactory>;
|
||||
|
||||
export const relayDalFactory = (db: TDbClient) => {
|
||||
const orm = ormify(db, TableName.Relay);
|
||||
|
||||
return orm;
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
export const INSTANCE_RELAY_PREFIX = "infisical-";
|
||||
|
||||
export const isInstanceRelay = (relayName: string) => {
|
||||
return relayName.startsWith(INSTANCE_RELAY_PREFIX);
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user