From eb2ee9582114e0d6c35cad8ad03a88ec07ceba92 Mon Sep 17 00:00:00 2001 From: ellamartirosyan Date: Thu, 12 Feb 2026 13:08:24 +0200 Subject: [PATCH] fix: access token --- helm/templates/configmap.yaml | 6 +++--- helm/values.yaml | 4 ++++ src/utils/Cesium/CesiumResource.ts | 9 +++++---- src/utils/Config.ts | 8 +++++--- src/utils/requestHandler.ts | 4 +--- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/helm/templates/configmap.yaml b/helm/templates/configmap.yaml index 21f0d3a..6ffffc4 100644 --- a/helm/templates/configmap.yaml +++ b/helm/templates/configmap.yaml @@ -9,12 +9,12 @@ RESPONSE_COMPRESSION_ENABLED: {{ .Values.env.responseCompressionEnabled | quote }} {{- end }} default.conf: {{ tpl (.Files.Get "config/default.conf") . | quote }} - CONFIGURATION_ACCESS_TOKEN_ATTRIBUTE_NAME: {{ quote .Values.global.shared.accessToken.attributeName }} - CONFIGURATION_ACCESS_TOKEN_INJECTION_TYPE: {{ quote .Values.global.shared.accessToken.injectionType }} - CONFIGURATION_ACCESS_TOKEN_VALUE: {{ quote .Values.global.shared.accessToken.tokenValue }} CONFIGURATION_IMAGE_TAG: {{ quote .Values.configValues.image.tag }} CONFIGURATION_PUBLIC_URL: {{ quote .Values.env.publicUrl }} CONFIGURATION_LANGUAGE: {{ quote .Values.env.language }} + CONFIGURATION_ACCESS_TOKEN_ATTRIBUTE_NAME: {{ quote .Values.env.accessToken.attributeName }} + CONFIGURATION_ACCESS_TOKEN_INJECTION_TYPE: {{ quote .Values.env.accessToken.injectionType }} + CONFIGURATION_ACCESS_TOKEN_VALUE: {{ quote .Values.env.accessToken.tokenValue }} CONFIGURATION_MAP_CENTER: {{ quote .Values.env.map.center }} CONFIGURATION_MAP_ZOOM: {{ quote .Values.env.map.zoom }} CONFIGURATION_BASE_MAPS: {{ quote .Values.env.baseMaps }} diff --git a/helm/values.yaml b/helm/values.yaml index daf6942..5635d48 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -101,6 +101,10 @@ env: requestPayloadLimit: 1mb publicUrl: '' language: he + accessToken: + attributeName: token + injectionType: queryParam + tokenValue: TOKEN map: center: '[34.811, 31.908]' zoom: 7 diff --git a/src/utils/Cesium/CesiumResource.ts b/src/utils/Cesium/CesiumResource.ts index ce6d3c0..907794c 100644 --- a/src/utils/Cesium/CesiumResource.ts +++ b/src/utils/Cesium/CesiumResource.ts @@ -3,13 +3,14 @@ import appConfig from '../Config'; export const getTokenResource = (url: string): CesiumResource => { const tokenProps: any = { url }; - if (appConfig.tokenInjectionType && appConfig.tokenInjectionType.toLowerCase() === 'header') { + const { injectionType, attributeName, tokenValue } = appConfig.accessToken; + if (injectionType && injectionType.toLowerCase() === 'header') { tokenProps.headers = { - [appConfig.tokenAttributeName]: appConfig.tokenValue + [attributeName]: tokenValue }; - } else if (appConfig.tokenInjectionType && appConfig.tokenInjectionType.toLowerCase() === 'queryparam') { + } else if (injectionType && injectionType.toLowerCase() === 'queryparam') { tokenProps.queryParameters = { - [appConfig.tokenAttributeName]: appConfig.tokenValue + [attributeName]: tokenValue }; } return new CesiumResource(tokenProps); diff --git a/src/utils/Config.ts b/src/utils/Config.ts index 6a8ab7c..7f74ee8 100644 --- a/src/utils/Config.ts +++ b/src/utils/Config.ts @@ -33,9 +33,11 @@ const enrichBaseMaps = (baseMaps: IBaseMaps): IBaseMaps => { }; class Config { - public tokenInjectionType = ACCESS_TOKEN_INJECTION_TYPE; - public tokenAttributeName = ACCESS_TOKEN_ATTRIBUTE_NAME; - public tokenValue = ACCESS_TOKEN_VALUE; + public accessToken = { + injectionType: ACCESS_TOKEN_INJECTION_TYPE, + attributeName: ACCESS_TOKEN_ATTRIBUTE_NAME, + tokenValue: ACCESS_TOKEN_VALUE + }; public publicUrl = PUBLIC_URL || '.'; public language = LANGUAGE || 'he'; public mapCenter = MAP_CENTER || '[34.817, 31.911]'; diff --git a/src/utils/requestHandler.ts b/src/utils/requestHandler.ts index 84fda3d..5a0c908 100644 --- a/src/utils/requestHandler.ts +++ b/src/utils/requestHandler.ts @@ -44,9 +44,7 @@ export const requestHandler = async (url: string, method: string, params: AxiosR }; export const requestHandlerWithToken = async (url: string, method: string, params: AxiosRequestConfig): Promise => { - const injectionType = appConfig.tokenInjectionType; - const attributeName = appConfig.tokenAttributeName; - const tokenValue = appConfig.tokenValue; + const { injectionType, attributeName, tokenValue } = appConfig.accessToken; const reqConfig = { ...params }; if (isHeader(injectionType)) {