fix: allow https on gateway k8s hosts

This commit is contained in:
Daniel Hougaard
2025-05-29 16:39:47 +04:00
parent 10d14edc20
commit f6b7717517
2 changed files with 10 additions and 1 deletions

View File

@@ -104,6 +104,7 @@ export const registerIdentityKubernetesRouter = async (server: FastifyZodProvide
.object({
kubernetesHost: z
.string()
.url()
.trim()
.min(1)
.describe(KUBERNETES_AUTH.ATTACH.kubernetesHost)
@@ -223,6 +224,7 @@ export const registerIdentityKubernetesRouter = async (server: FastifyZodProvide
.object({
kubernetesHost: z
.string()
.url()
.trim()
.min(1)
.optional()

View File

@@ -2,6 +2,7 @@ import { ForbiddenError } from "@casl/ability";
import axios, { AxiosError } from "axios";
import https from "https";
import jwt from "jsonwebtoken";
import RE2 from "re2";
import { IdentityAuthMethod, TIdentityKubernetesAuthsUpdate } from "@app/db/schemas";
import { TGatewayDALFactory } from "@app/ee/services/gateway/gateway-dal";
@@ -185,7 +186,13 @@ export const identityKubernetesAuthServiceFactory = ({
return res.data;
};
const [k8sHost, k8sPort] = identityKubernetesAuth.kubernetesHost.split(":");
let { kubernetesHost } = identityKubernetesAuth;
if (kubernetesHost.startsWith("https://") || kubernetesHost.startsWith("http://")) {
kubernetesHost = kubernetesHost.replace(new RE2("^https?:\\/\\/"), "");
}
const [k8sHost, k8sPort] = kubernetesHost.split(":") ?? [];
const data = identityKubernetesAuth.gatewayId
? await $gatewayProxyWrapper(