From c81a1aa2b02f9361a1560e7335a7a8380666cebd Mon Sep 17 00:00:00 2001 From: Andrei Kvapil Date: Wed, 24 Sep 2025 21:36:18 +0200 Subject: [PATCH] [dashboard] fix listing namespaces as unprivileged user Signed-off-by: Andrei Kvapil --- .../images/openapi-ui-k8s-bff/Dockerfile | 3 +++ .../patches/namespaces.diff | 21 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 packages/system/dashboard/images/openapi-ui-k8s-bff/patches/namespaces.diff diff --git a/packages/system/dashboard/images/openapi-ui-k8s-bff/Dockerfile b/packages/system/dashboard/images/openapi-ui-k8s-bff/Dockerfile index 737ccc95..e21829d2 100644 --- a/packages/system/dashboard/images/openapi-ui-k8s-bff/Dockerfile +++ b/packages/system/dashboard/images/openapi-ui-k8s-bff/Dockerfile @@ -7,6 +7,9 @@ WORKDIR /src ARG COMMIT_REF=22f9143f5109fb90332651c857d70b51bffccd9b RUN wget -O- https://github.com/PRO-Robotech/openapi-ui-k8s-bff/archive/${COMMIT_REF}.tar.gz | tar xzf - --strip-components=1 +COPY patches /patches +RUN git apply /patches/*.diff + ENV PATH=/src/node_modules/.bin:$PATH RUN npm install RUN npm run build diff --git a/packages/system/dashboard/images/openapi-ui-k8s-bff/patches/namespaces.diff b/packages/system/dashboard/images/openapi-ui-k8s-bff/patches/namespaces.diff new file mode 100644 index 00000000..6a8ecbbe --- /dev/null +++ b/packages/system/dashboard/images/openapi-ui-k8s-bff/patches/namespaces.diff @@ -0,0 +1,21 @@ +diff --git a/src/endpoints/forms/formPrepare/formPrepare.ts b/src/endpoints/forms/formPrepare/formPrepare.ts +index 7e437db..90c40f6 100644 +--- a/src/endpoints/forms/formPrepare/formPrepare.ts ++++ b/src/endpoints/forms/formPrepare/formPrepare.ts +@@ -15,6 +15,7 @@ export const prepareFormProps: RequestHandler = async (req: TPrepareFormReq, res + + const filteredHeaders = { ...req.headers } + delete filteredHeaders['host'] // Avoid passing internal host header ++ delete filteredHeaders['content-length'] // This header causes "stream has been aborted" + + const { data: formsOverridesData } = await userKubeApi.get( + `/apis/${BASE_API_GROUP}/${BASE_API_VERSION}/customformsoverrides`, +@@ -40,7 +41,7 @@ export const prepareFormProps: RequestHandler = async (req: TPrepareFormReq, res + }, + ) + +- const { data: namespacesData } = await userKubeApi.get(`/api/v1/namespaces`, { ++ const { data: namespacesData } = await userKubeApi.get(`/apis/core.cozystack.io/v1alpha1/tenantnamespaces`, { + headers: { + // Authorization: `Bearer ${bearerToken}`, + // Cookie: cookies,