Skip to content

Commit f0cd214

Browse files
committed
ftr: add context route support for fe application
TRACEFOSS-565
1 parent 3a0c6e8 commit f0cd214

File tree

28 files changed

+120
-46
lines changed

28 files changed

+120
-46
lines changed

Dockerfile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,15 @@ COPY --from=builder /usr/local/bin /usr/local/bin
3737

3838
# Copy NGINX server configuration
3939
COPY ./build/security-headers.conf ./build/nginx.conf /etc/nginx/
40+
41+
# Copy custom script runner
42+
COPY scripts/custom-injector.sh /docker-entrypoint.d/00-custom-injector.sh
43+
4044
# Add env variables inject script
41-
COPY ./scripts/run-inject-dynamic-env.sh /docker-entrypoint.d/00-inject-dynamic-env.sh
4245
COPY ./scripts/inject-dynamic-env.js /docker-entrypoint.d/
46+
# Add replace base url script
47+
COPY ./scripts/replace-base-href.js /docker-entrypoint.d/
4348

44-
# Validate NGINX configuration
45-
RUN nginx -t
49+
USER root
50+
RUN chown nginx:nginx /etc/nginx/nginx.conf
51+
RUN chown nginx:nginx /etc/nginx/security-headers.conf

INSTALL.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const ENV_VARS_MAPPING = {
1818
CATENAX_PORTAL_REALM_LOGO: 'realmLogo',
1919
CATENAX_PORTAL_API_URL: 'apiUrl',
2020
CATENAX_PORTAL_BASE_URL: 'baseUrl',
21+
CATENAX_PORTAL_BACKEND_DOMAIN,
2122
};
2223
```
2324

@@ -39,10 +40,15 @@ This variable points to the desired api
3940
`CATENAX_PORTAL_BASE_URL`
4041
This variable is used to set the base path of the application. (Should be set if application runs as a subtopic)
4142

43+
`CATENAX_PORTAL_BACKEND_DOMAIN`
44+
This variable is needed for security, to be more explicit, for the security headers of a request.
45+
The domain of the corresponding backend should be used here.
46+
An example value could be: `catena-x.com`
47+
4248
### Example command:
4349

4450
```shell
45-
$ docker run -d -p 4200:8080 -e CATENAX_PORTAL_DEFAULT_REALM=TEST ${dockerImage}
51+
$ docker run -d -p 4200:8080 -e CATENAX_PORTAL_BASE_URL=/example -e CATENAX_PORTAL_BACKEND_DOMAIN=catena-x.net ${dockerImage}
4652
```
4753

4854
#### `Docker run`
@@ -57,7 +63,7 @@ To start a container in detached mode, you use `-d=true` or just `-d` option. By
5763

5864
To expose a container’s internal port, an operator can start the container with the `-P` or `-p` flag. The exposed port is accessible on the host and the ports are available to any client that can reach the host.
5965

60-
#### `-e CATENAX_PORTAL_DEFAULT_REALM=TEST`
66+
#### `-e ***`
6167

6268
The operator can set any environment variable in the container by using one or more `-e` flags, even overriding already defined flags by the developer with a Dockerfile `ENV`.
6369

build/nginx.conf

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,19 @@ http {
3535

3636
server_tokens off;
3737

38-
location ~ /index.html|.*\.json$ {
38+
location ~ /{baseHrefPlaceholder}/index.html|/{baseHrefPlaceholder}/*\.json$ {
3939
expires -1;
4040
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
4141
include /etc/nginx/security-headers.conf;
4242
}
4343

44-
location ~ .*\.css$|.*\.js$ {
44+
location ~ /{baseHrefPlaceholder}/*\.(css|js)$ {
4545
add_header Cache-Control 'max-age=31449600'; # one year
4646
include /etc/nginx/security-headers.conf;
4747
}
4848

49-
location / {
49+
location /{baseHrefPlaceholder}/ {
50+
alias /usr/share/nginx/html/;
5051
try_files $uri$args $uri$args/ /index.html;
5152

5253
add_header Cache-Control 'max-age=86400'; # one day

build/security-headers.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
add_header Strict-Transport-Security "max-age=31449600; includeSubDomains" always;
2-
add_header Content-Security-Policy "default-src 'self' https://*.mapbox.com https://*.catena-x.net; object-src 'none'; script-src 'self' 'unsafe-inline' https://cdnjs.cloudflare.com https://api.mapbox.com 'self' blob:; script-src-elem 'self'; base-uri 'self'; style-src 'self' 'unsafe-inline' fonts.googleapis.com; block-all-mixed-content; font-src 'self' https: data:; frame-ancestors 'self'; img-src 'self' data:; upgrade-insecure-requests;" always;
2+
add_header Content-Security-Policy "default-src 'self' https://*.mapbox.com https://*.{backendDomain}; object-src 'none'; script-src 'self' 'unsafe-inline' https://cdnjs.cloudflare.com https://api.mapbox.com 'self' blob:; script-src-elem 'self'; base-uri 'self'; style-src 'self' 'unsafe-inline' fonts.googleapis.com; block-all-mixed-content; font-src 'self' https: data:; frame-ancestors 'self'; img-src 'self' data:; upgrade-insecure-requests;" always;
33
add_header X-Frame-Options "DENY" always;
44
add_header X-Content-Type-Options "nosniff" always;
55
add_header Referrer-Policy "strict-origin" always;

charts/product-traceability-foss-frontend/templates/deployment.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ spec:
5151
value: "{{ .Values.image.CATENAX_PORTAL_CLIENT_ID }}"
5252
- name: CATENAX_PORTAL_DEFAULT_REALM
5353
value: "{{ .Values.image.CATENAX_PORTAL_DEFAULT_REALM }}"
54+
- name: CATENAX_PORTAL_BASE_URL
55+
value: "{{ .Values.image.CATENAX_PORTAL_BASE_URL }}"
56+
- name: CATENAX_PORTAL_REALM_LOGO
57+
value: "{{ .Values.image.CATENAX_PORTAL_REALM_LOGO }}"
58+
- name: CATENAX_PORTAL_BACKEND_DOMAIN
59+
value: "{{ .Values.image.CATENAX_PORTAL_BACKEND_DOMAIN }}"
5460
ports:
5561
- name: http
5662
containerPort: {{ .Values.service.port }}
@@ -76,4 +82,4 @@ spec:
7682
{{- with .Values.tolerations }}
7783
tolerations:
7884
{{- toYaml . | nindent 8 }}
79-
{{- end }}
85+
{{- end }}

charts/product-traceability-foss-frontend/values-dev-test.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ image:
55
CATENAX_PORTAL_KEYCLOAK_URL: 'https://centralidp.dev.demo.catena-x.net/auth'
66
CATENAX_PORTAL_CLIENT_ID: 'Cl17-CX-Part'
77
CATENAX_PORTAL_DEFAULT_REALM: 'CX-Central'
8+
CATENAX_PORTAL_BACKEND_DOMAIN: 'catena-x.com'
89

910
nameOverride: "product-traceability-foss-test-frontend"
1011
fullnameOverride: "product-traceability-foss-test-frontend"

charts/product-traceability-foss-frontend/values-dev.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ image:
44
CATENAX_PORTAL_KEYCLOAK_URL: 'https://centralidp.dev.demo.catena-x.net/auth'
55
CATENAX_PORTAL_CLIENT_ID: 'Cl17-CX-Part'
66
CATENAX_PORTAL_DEFAULT_REALM: 'CX-Central'
7+
CATENAX_PORTAL_BACKEND_DOMAIN: 'catena-x.com'
78

89
autoscaling:
910
enabled: false

charts/product-traceability-foss-frontend/values-int-test.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ image:
44
CATENAX_PORTAL_KEYCLOAK_URL: 'https://centralidp.int.demo.catena-x.net/auth'
55
CATENAX_PORTAL_CLIENT_ID: 'Cl17-CX-Part'
66
CATENAX_PORTAL_DEFAULT_REALM: 'CX-Central'
7+
CATENAX_PORTAL_BACKEND_DOMAIN: 'catena-x.com'
78

89
nameOverride: "product-traceability-foss-test-frontend"
910
fullnameOverride: "product-traceability-foss-test-frontend"

charts/product-traceability-foss-frontend/values-int.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ image:
44
CATENAX_PORTAL_KEYCLOAK_URL: 'https://centralidp.int.demo.catena-x.net/auth'
55
CATENAX_PORTAL_CLIENT_ID: 'Cl17-CX-Part'
66
CATENAX_PORTAL_DEFAULT_REALM: 'CX-Central'
7+
CATENAX_PORTAL_BACKEND_DOMAIN: 'catena-x.com'
78

89
autoscaling:
910
enabled: false

charts/product-traceability-foss-frontend/values-pen.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ image:
44
CATENAX_PORTAL_KEYCLOAK_URL: 'https://centralidp-pen.dev.demo.catena-x.net/auth'
55
CATENAX_PORTAL_CLIENT_ID: 'Cl17-CX-Part'
66
CATENAX_PORTAL_DEFAULT_REALM: 'CX-Central'
7+
CATENAX_PORTAL_BACKEND_DOMAIN: 'catena-x.com'
78

89
# important to not conflict with dev env (both use same ArgoCD instance)
910
namespace: product-traceability-foss-pen

0 commit comments

Comments
 (0)