mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
misc: addressed greptile comments 1
This commit is contained in:
@@ -65,7 +65,18 @@ export const registerProxyRouter = async (server: FastifyZodProvider) => {
|
||||
name: z.string()
|
||||
}),
|
||||
response: {
|
||||
200: z.any()
|
||||
200: z.object({
|
||||
pki: z.object({
|
||||
serverCertificate: z.string(),
|
||||
serverPrivateKey: z.string(),
|
||||
clientCertificateChain: z.string()
|
||||
}),
|
||||
ssh: z.object({
|
||||
serverCertificate: z.string(),
|
||||
serverPrivateKey: z.string(),
|
||||
clientCAPublicKey: z.string()
|
||||
})
|
||||
})
|
||||
}
|
||||
},
|
||||
onRequest: verifyAuth([AuthMode.IDENTITY_ACCESS_TOKEN]),
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
export const INSTANCE_PROXY_PREFIX = "infisical-";
|
||||
|
||||
export const isInstanceProxy = (proxyName: string) => {
|
||||
return proxyName.startsWith("infisical-");
|
||||
return proxyName.startsWith(INSTANCE_PROXY_PREFIX);
|
||||
};
|
||||
|
||||
@@ -405,7 +405,7 @@ export const proxyServiceFactory = ({
|
||||
format: "der",
|
||||
type: "pkcs8"
|
||||
});
|
||||
const orgProxyClientCaPrivateKey = await crypto.nativeCrypto.subtle.importKey(
|
||||
const orgProxyCaPrivateKey = await crypto.nativeCrypto.subtle.importKey(
|
||||
"pkcs8",
|
||||
orgProxyCaSkObj.export({ format: "der", type: "pkcs8" }),
|
||||
alg,
|
||||
@@ -425,7 +425,7 @@ export const proxyServiceFactory = ({
|
||||
issuer: orgProxyCaCert.subject,
|
||||
notBefore: orgProxyClientCaIssuedAt,
|
||||
notAfter: orgProxyClientCaExpiration,
|
||||
signingKey: orgProxyClientCaPrivateKey,
|
||||
signingKey: orgProxyCaPrivateKey,
|
||||
publicKey: orgProxyClientCaKeys.publicKey,
|
||||
signingAlgorithm: alg,
|
||||
extensions: [
|
||||
@@ -460,7 +460,7 @@ export const proxyServiceFactory = ({
|
||||
issuer: orgProxyCaCert.subject,
|
||||
notBefore: orgProxyServerCaIssuedAt,
|
||||
notAfter: orgProxyServerCaExpiration,
|
||||
signingKey: orgProxyClientCaPrivateKey,
|
||||
signingKey: orgProxyCaPrivateKey,
|
||||
publicKey: orgProxyServerCaKeys.publicKey,
|
||||
signingAlgorithm: alg,
|
||||
extensions: [
|
||||
|
||||
@@ -3,6 +3,7 @@ import tls from "node:tls";
|
||||
|
||||
import https from "https";
|
||||
|
||||
import { verifyHostInputValidity } from "@app/ee/services/dynamic-secret/dynamic-secret-fns";
|
||||
import { splitPemChain } from "@app/services/certificate/certificate-fns";
|
||||
|
||||
import { BadRequestError } from "../errors";
|
||||
@@ -27,12 +28,13 @@ const createProxyConnection = async ({
|
||||
clientPrivateKey: string;
|
||||
serverCertificateChain: string;
|
||||
}): Promise<net.Socket> => {
|
||||
const [host, portStr] = proxyIp.split(":");
|
||||
const port = parseInt(portStr, 10) || 443;
|
||||
const [targetHost] = await verifyHostInputValidity(proxyIp);
|
||||
const [, portStr] = proxyIp.split(":");
|
||||
const port = parseInt(portStr, 10) || 8443;
|
||||
|
||||
const serverCAs = splitPemChain(serverCertificateChain);
|
||||
const tlsOptions: tls.ConnectionOptions = {
|
||||
host,
|
||||
host: targetHost,
|
||||
port,
|
||||
cert: clientCertificate,
|
||||
key: clientPrivateKey,
|
||||
|
||||
@@ -121,7 +121,8 @@ export const injectIdentity = fp(async (server: FastifyZodProvider) => {
|
||||
return;
|
||||
}
|
||||
|
||||
if (req.url.includes("/api/v1/proxies/register-instance-proxy")) {
|
||||
// Authentication is handled on a route-level
|
||||
if (req.url === "/api/v1/proxies/register-instance-proxy") {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import https from "https";
|
||||
|
||||
import { verifyHostInputValidity } from "@app/ee/services/dynamic-secret/dynamic-secret-fns";
|
||||
import { TGatewayServiceFactory } from "@app/ee/services/gateway/gateway-service";
|
||||
import { TGatewayV2ServiceFactory } from "@app/ee/services/gateway-v2/gateway-v2-service";
|
||||
import { request } from "@app/lib/config/request";
|
||||
import { BadRequestError } from "@app/lib/errors";
|
||||
import { removeTrailingSlash } from "@app/lib/fn";
|
||||
@@ -144,7 +145,9 @@ export const getHCVaultAccessToken = async (
|
||||
|
||||
export const validateHCVaultConnectionCredentials = async (
|
||||
connection: THCVaultConnection,
|
||||
gatewayService: Pick<TGatewayServiceFactory, "fnGetGatewayClientTlsByGatewayId">
|
||||
gatewayService: Pick<TGatewayServiceFactory, "fnGetGatewayClientTlsByGatewayId">,
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
_gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPlatformConnectionDetailsByGatewayId">
|
||||
) => {
|
||||
const instanceUrl = await getHCVaultInstanceUrl(connection);
|
||||
|
||||
|
||||
@@ -12,8 +12,10 @@ export const gatewaysQueryKeys = {
|
||||
queryOptions({
|
||||
queryKey: gatewaysQueryKeys.listKey(),
|
||||
queryFn: async () => {
|
||||
const { data } = await apiRequest.get<{ gateways: TGateway[] }>("/api/v1/gateways");
|
||||
const { data: dataV2 } = await apiRequest.get<TGatewayV2[]>("/api/v2/gateways");
|
||||
const [{ data }, { data: dataV2 }] = await Promise.all([
|
||||
apiRequest.get<{ gateways: TGateway[] }>("/api/v1/gateways"),
|
||||
apiRequest.get<TGatewayV2[]>("/api/v2/gateways")
|
||||
]);
|
||||
|
||||
return [
|
||||
...data.gateways.map((g) => ({
|
||||
|
||||
Reference in New Issue
Block a user