Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions helm/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
4 changes: 4 additions & 0 deletions helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions src/utils/Cesium/CesiumResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 5 additions & 3 deletions src/utils/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]';
Expand Down
4 changes: 1 addition & 3 deletions src/utils/requestHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<AxiosResponse> => {
const injectionType = appConfig.tokenInjectionType;
const attributeName = appConfig.tokenAttributeName;
const tokenValue = appConfig.tokenValue;
const { injectionType, attributeName, tokenValue } = appConfig.accessToken;
const reqConfig = { ...params };

if (isHeader(injectionType)) {
Expand Down