Skip to content

Commit 63ca8d7

Browse files
committed
feat: Implement enhanced configuration system for Industry Core Hub frontend
- Added a comprehensive README.md detailing the new configuration system, including type safety, environment-specific configurations, runtime configuration, authentication support, feature flags, and API key management. - Introduced schema definitions in schema.ts for application configuration, governance policies, and authentication types. - Created AuthService.ts for managing Keycloak authentication, including token management, user profile handling, and session management. - Enhanced EnvironmentService.ts to provide type-safe access to configuration values and support for backward compatibility. - Updated vite-env.d.ts to include new environment variables for the enhanced configuration. - Modified vite.config.ts to inject build-time variables and optimize build settings for production and development environments.
1 parent cefd8df commit 63ca8d7

File tree

14 files changed

+2247
-64
lines changed

14 files changed

+2247
-64
lines changed

charts/industry-core-hub/templates/deployment-frontend.yaml

Lines changed: 70 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,77 @@ spec:
6363
containerPort: {{ .Values.frontend.service.portContainer }}
6464
protocol: TCP
6565
env:
66+
# Core application
67+
- name: APP_ENVIRONMENT
68+
value: "{{ .Values.frontend.config.environment }}"
69+
- name: APP_VERSION
70+
value: "{{ .Values.frontend.config.version }}"
71+
72+
# API configuration
6673
- name: ICHUB_BACKEND_URL
67-
value: "{{ .Values.frontend.env.backendUrl }}"
68-
- name: PARTICIPANT_ID
69-
value: "{{ .Values.participantId }}"
70-
- name: GOVERNANCE_CONFIG
71-
value: {{ .Values.frontend.consumption.governance | toJson | quote }}
72-
- name: DTR_POLICIES_CONFIG
73-
value: {{ .Values.frontend.consumption.digitalTwinRegistry.policies | toJson | quote }}
74+
value: "{{ .Values.frontend.config.ichubBackendUrl }}"
75+
- name: API_TIMEOUT
76+
value: "{{ .Values.frontend.config.apiTimeout }}"
77+
- name: API_RETRY_ATTEMPTS
78+
value: "{{ .Values.frontend.config.apiRetryAttempts }}"
79+
- name: REQUIRE_HTTPS_URL_PATTERN
80+
value: "{{ .Values.frontend.config.requireHttpsUrlPattern }}"
81+
82+
# API key configuration
83+
{{- if .Values.frontend.config.apiKey }}
84+
- name: API_KEY
85+
value: "{{ .Values.frontend.config.apiKey }}"
86+
{{- end }}
87+
- name: API_KEY_HEADER
88+
value: "{{ .Values.frontend.config.apiKeyHeader }}"
89+
- name: ENABLE_API_KEY_ROTATION
90+
value: "{{ .Values.frontend.config.enableApiKeyRotation }}"
91+
- name: API_KEY_EXPIRY_WARNING_DAYS
92+
value: "{{ .Values.frontend.config.apiKeyExpiryWarningDays }}"
93+
94+
# Authentication configuration
95+
- name: AUTH_ENABLED
96+
value: "{{ .Values.frontend.config.authEnabled }}"
97+
- name: AUTH_PROVIDER
98+
value: "{{ .Values.frontend.config.authProvider }}"
99+
100+
# Core application
101+
- name: APP_ENVIRONMENT
102+
value: "{{ .Values.frontend.config.environment }}"
103+
- name: APP_VERSION
104+
value: "{{ .Values.frontend.config.version }}"
105+
106+
# API configuration
107+
- name: ICHUB_BACKEND_URL
108+
value: "{{ .Values.frontend.config.ichubBackendUrl }}"
109+
- name: API_TIMEOUT
110+
value: "{{ .Values.frontend.config.apiTimeout }}"
111+
- name: API_RETRY_ATTEMPTS
112+
value: "{{ .Values.frontend.config.apiRetryAttempts }}"
113+
- name: REQUIRE_HTTPS_URL_PATTERN
114+
value: "{{ .Values.frontend.config.requireHttpsUrlPattern }}"
115+
116+
# Authentication configuration
117+
- name: AUTH_ENABLED
118+
value: "{{ .Values.frontend.config.authEnabled }}"
119+
- name: AUTH_PROVIDER
120+
value: "{{ .Values.frontend.config.authProvider }}"
121+
122+
# Feature flags
123+
- name: ENABLE_ADVANCED_LOGGING
124+
value: "{{ .Values.frontend.config.enableAdvancedLogging }}"
125+
- name: ENABLE_PERFORMANCE_MONITORING
126+
value: "{{ .Values.frontend.config.enablePerformanceMonitoring }}"
127+
- name: ENABLE_DEV_TOOLS
128+
value: "{{ .Values.frontend.config.enableDevTools }}"
129+
130+
# UI configuration
131+
- name: UI_THEME
132+
value: "{{ .Values.frontend.config.uiTheme }}"
133+
- name: UI_LOCALE
134+
value: "{{ .Values.frontend.config.uiLocale }}"
135+
- name: UI_COMPACT_MODE
136+
value: "{{ .Values.frontend.config.uiCompactMode }}"
74137
{{- if .Values.frontend.healthChecks.startup.enabled }}
75138
startupProbe:
76139
httpGet:

charts/industry-core-hub/values-int-manufacturer.yaml

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,66 @@ frontend:
4343
name: "manufacturer-ichub-frontend"
4444
nameOverride: "manufacturer-ichub-frontend"
4545
fullnameOverride: "manufacturer-ichub-frontend"
46+
config:
47+
# Core application
48+
environment: "integration"
49+
version: "1.0.0"
50+
51+
# API configuration
52+
ichubBackendUrl: "https://backend-ichub-manufacturer.int.catena-x.net/v1"
53+
apiTimeout: 20000
54+
apiRetryAttempts: 2
55+
requireHttpsUrlPattern: true
56+
57+
# API key configuration (disabled for integration)
58+
apiKey: ""
59+
apiKeyHeader: "X-API-Key"
60+
enableApiKeyRotation: false
61+
apiKeyExpiryWarningDays: 7
62+
63+
# Authentication configuration (disabled for integration)
64+
authEnabled: false
65+
authProvider: "none"
66+
authSessionTimeout: 3600
67+
authRenewTokenMinValidity: 60
68+
authLogoutRedirectUri: ""
69+
70+
# Keycloak configuration (disabled for integration)
71+
keycloak:
72+
url: ""
73+
realm: ""
74+
clientId: ""
75+
onLoad: "check-sso"
76+
checkLoginIframe: true
77+
silentCheckSsoRedirectUri: ""
78+
pkceMethod: "S256"
79+
enableLogging: false
80+
minValidity: 30
81+
checkLoginIframeInterval: 5
82+
flow: "standard"
83+
84+
# Feature flags for integration environment
85+
enableAdvancedLogging: true
86+
enablePerformanceMonitoring: true
87+
enableDevTools: false
88+
89+
# UI configuration
90+
uiTheme: "auto"
91+
uiLocale: "en"
92+
uiCompactMode: false
93+
94+
# Governance configuration
95+
governanceApiUrl: ""
96+
governanceTimeout: 30000
97+
governanceRetryAttempts: 2
98+
99+
# Participant configuration
100+
participantApiUrl: ""
101+
participantTimeout: 30000
102+
participantRetryAttempts: 2
103+
46104
env:
47-
# -- industry-core-hub backend base URL
105+
# Legacy backend URL (maintained for backward compatibility)
48106
backendUrl: "https://backend-ichub-manufacturer.int.catena-x.net/v1"
49107
ingress:
50108
enabled: true

charts/industry-core-hub/values-int.yaml

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,66 @@ pgadmin4:
5050
hosts:
5151
- "pgadmin-ichub.int.catena-x.net"
5252
frontend:
53+
config:
54+
# Core application
55+
environment: "integration"
56+
version: "1.0.0"
57+
58+
# API configuration
59+
ichubBackendUrl: "https://backend-ichub.int.catena-x.net/v1"
60+
apiTimeout: 20000
61+
apiRetryAttempts: 2
62+
requireHttpsUrlPattern: true
63+
64+
# API key configuration (disabled for integration)
65+
apiKey: ""
66+
apiKeyHeader: "X-API-Key"
67+
enableApiKeyRotation: false
68+
apiKeyExpiryWarningDays: 7
69+
70+
# Authentication configuration (disabled for integration)
71+
authEnabled: false
72+
authProvider: "none"
73+
authSessionTimeout: 3600
74+
authRenewTokenMinValidity: 60
75+
authLogoutRedirectUri: ""
76+
77+
# Keycloak configuration (disabled for integration)
78+
keycloak:
79+
url: ""
80+
realm: ""
81+
clientId: ""
82+
onLoad: "check-sso"
83+
checkLoginIframe: true
84+
silentCheckSsoRedirectUri: ""
85+
pkceMethod: "S256"
86+
enableLogging: false
87+
minValidity: 30
88+
checkLoginIframeInterval: 5
89+
flow: "standard"
90+
91+
# Feature flags for integration environment
92+
enableAdvancedLogging: true
93+
enablePerformanceMonitoring: true
94+
enableDevTools: false
95+
96+
# UI configuration
97+
uiTheme: "auto"
98+
uiLocale: "en"
99+
uiCompactMode: false
100+
101+
# Governance configuration
102+
governanceApiUrl: ""
103+
governanceTimeout: 30000
104+
governanceRetryAttempts: 2
105+
106+
# Participant configuration
107+
participantApiUrl: ""
108+
participantTimeout: 30000
109+
participantRetryAttempts: 2
110+
53111
env:
54-
# -- industry-core-hub backend base URL
112+
# Legacy backend URL (maintained for backward compatibility)
55113
backendUrl: "https://backend-ichub.int.catena-x.net/v1"
56114
ingress:
57115
enabled: true

charts/industry-core-hub/values.yaml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,83 @@ backend:
375375
keep_alive: 300 # 5 minutes for DTR operations
376376
graceful_shutdown: 30 # 30 seconds for graceful shutdown
377377
frontend:
378+
# -- Enhanced frontend configuration
379+
config:
380+
# Core application settings
381+
environment: "development" # development, staging, production
382+
version: "1.0.0"
383+
384+
# API and backend configuration
385+
ichubBackendUrl: "https://<backend-hostname>"
386+
apiTimeout: 30000
387+
apiRetryAttempts: 3
388+
requireHttpsUrlPattern: false
389+
390+
# API key configuration (optional)
391+
apiKey: ""
392+
apiKeyHeader: "X-API-Key"
393+
enableApiKeyRotation: false
394+
apiKeyExpiryWarningDays: 7
395+
396+
# Authentication configuration
397+
authEnabled: false
398+
authProvider: "none" # none, keycloak
399+
400+
# Keycloak configuration (only used when authProvider is keycloak)
401+
keycloak:
402+
url: ""
403+
realm: ""
404+
clientId: ""
405+
onLoad: "check-sso" # check-sso, login-required
406+
checkLoginIframe: true
407+
silentCheckSsoRedirectUri: ""
408+
pkceMethod: "S256"
409+
enableLogging: false
410+
minValidity: 30
411+
checkLoginIframeInterval: 5
412+
flow: "standard" # standard, implicit, hybrid
413+
414+
# Session management
415+
authSessionTimeout: 3600000 # 1 hour in milliseconds
416+
authRenewTokenMinValidity: 300 # 5 minutes in seconds
417+
authLogoutRedirectUri: ""
418+
419+
# Participant configuration
420+
participantId: "BPNL0000000093Q7"
421+
bpnValidationPattern: "^BPN[LAS]\\d{10}[a-zA-Z0-9]{2}$"
422+
423+
# Governance and policies configuration
424+
governanceConfig: []
425+
dtrPoliciesConfig:
426+
- strict: false
427+
permission:
428+
action: "odrl:use"
429+
LogicalConstraint: "odrl:and"
430+
constraints:
431+
- leftOperand: "cx-policy:FrameworkAgreement"
432+
operator: "odrl:eq"
433+
rightOperand: "DataExchangeGovernance:1.0"
434+
- leftOperand: "cx-policy:Membership"
435+
operator: "odrl:eq"
436+
rightOperand: "active"
437+
- leftOperand: "cx-policy:UsagePurpose"
438+
operator: "odrl:eq"
439+
rightOperand: "cx.core.digitalTwinRegistry:1"
440+
prohibition: []
441+
obligation: []
442+
governanceStrictMode: false
443+
444+
# Feature flags
445+
enableAdvancedLogging: false
446+
enablePerformanceMonitoring: false
447+
enableDevTools: false
448+
449+
# UI configuration
450+
uiTheme: "auto"
451+
uiLocale: "en"
452+
uiCompactMode: false
453+
454+
# Legacy configuration (deprecated - use config section above)
378455
env:
379456
# -- industry-core-hub backend base URL
380457
backendUrl: "https://<backend-hostname>"

ichub-frontend/index.html

Lines changed: 73 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,82 @@
3535
<body>
3636
<div id="root"></div>
3737
<script>
38-
// Do NOT change ENV attributes without changing them in scripts/inject-dynamic-env.sh as well
38+
// Enhanced runtime configuration injection
39+
// This will be replaced by Helm chart values during deployment
3940
const ENV = {
40-
VITE_REQUIRE_HTTPS_URL_PATTERN: "false",
41-
VITE_ICHUB_BACKEND_URL: "http://localhost:9000/v1",
42-
VITE_PARTICIPANT_ID: "BPNL0000000093Q7",
43-
VITE_GOVERNANCE_CONFIG: "[]",
44-
VITE_DTR_POLICIES_CONFIG: "[]"
41+
// Core application
42+
APP_ENVIRONMENT: "development",
43+
APP_VERSION: "1.0.0",
44+
45+
// API configuration
46+
ICHUB_BACKEND_URL: "http://localhost:9000/v1",
47+
API_TIMEOUT: "30000",
48+
API_RETRY_ATTEMPTS: "3",
49+
REQUIRE_HTTPS_URL_PATTERN: "false",
50+
51+
// API key configuration
52+
API_KEY: "",
53+
API_KEY_HEADER: "X-API-Key",
54+
ENABLE_API_KEY_ROTATION: "false",
55+
API_KEY_EXPIRY_WARNING_DAYS: "7",
56+
57+
// Authentication configuration
58+
AUTH_ENABLED: "false",
59+
AUTH_PROVIDER: "none",
60+
61+
// Keycloak configuration
62+
KEYCLOAK_URL: "",
63+
KEYCLOAK_REALM: "",
64+
KEYCLOAK_CLIENT_ID: "",
65+
KEYCLOAK_ON_LOAD: "check-sso",
66+
KEYCLOAK_CHECK_LOGIN_IFRAME: "true",
67+
KEYCLOAK_SILENT_CHECK_SSO_REDIRECT_URI: "",
68+
KEYCLOAK_PKCE_METHOD: "S256",
69+
KEYCLOAK_ENABLE_LOGGING: "false",
70+
KEYCLOAK_MIN_VALIDITY: "30",
71+
KEYCLOAK_CHECK_LOGIN_IFRAME_INTERVAL: "5",
72+
KEYCLOAK_FLOW: "standard",
73+
74+
// Session management
75+
AUTH_SESSION_TIMEOUT: "3600000",
76+
AUTH_RENEW_TOKEN_MIN_VALIDITY: "300",
77+
AUTH_LOGOUT_REDIRECT_URI: "",
78+
79+
// Participant configuration
80+
PARTICIPANT_ID: "BPNL0000000093Q7",
81+
BPN_VALIDATION_PATTERN: "",
82+
83+
// Governance and policies
84+
GOVERNANCE_CONFIG: "[]",
85+
DTR_POLICIES_CONFIG: '[{"strict":false,"permission":{"action":"odrl:use","LogicalConstraint":"odrl:and","constraints":[{"leftOperand":"cx-policy:FrameworkAgreement","operator":"odrl:eq","rightOperand":"DataExchangeGovernance:1.0"},{"leftOperand":"cx-policy:Membership","operator":"odrl:eq","rightOperand":"active"},{"leftOperand":"cx-policy:UsagePurpose","operator":"odrl:eq","rightOperand":"cx.core.digitalTwinRegistry:1"}]},"prohibition":[],"obligation":[]}]',
86+
GOVERNANCE_STRICT_MODE: "false",
87+
88+
// Feature flags
89+
ENABLE_ADVANCED_LOGGING: "true",
90+
ENABLE_PERFORMANCE_MONITORING: "false",
91+
ENABLE_DEV_TOOLS: "true",
92+
93+
// UI configuration
94+
UI_THEME: "auto",
95+
UI_LOCALE: "en",
96+
UI_COMPACT_MODE: "false"
4597
}
98+
99+
// Validate and sanitize environment
100+
Object.keys(ENV).forEach(key => {
101+
if (ENV[key] === 'undefined' || ENV[key] === '') {
102+
delete ENV[key];
103+
}
104+
});
105+
46106
window.ENV = ENV;
107+
108+
// Performance monitoring (development only)
109+
if (ENV.ENABLE_PERFORMANCE_MONITORING === 'true') {
110+
window.addEventListener('load', () => {
111+
console.info('App loaded in:', performance.now(), 'ms');
112+
});
113+
}
47114
</script>
48115
<script type="module" src="/src/main.tsx"></script>
49116
</body>

0 commit comments

Comments
 (0)