From 89631573676c809ed709cbc83a0335f3c099c5f4 Mon Sep 17 00:00:00 2001 From: Leif Battermann Date: Tue, 15 Nov 2022 13:43:06 +0000 Subject: [PATCH 1/5] replacing legacy swagger with 2.x --- charts/backoffice/templates/configmap.yaml | 153 +--- charts/backoffice/templates/deployment.yaml | 8 - charts/backoffice/values.yaml | 5 +- .../integration-test/conf/nginz/nginx.conf | 20 +- .../backoffice/api-docs/resources.json | 13 - services/nginz/zwagger-ui/index.html | 4 - tools/stern/src/Stern/API.hs | 15 - tools/stern/src/Stern/API/Routes.hs | 12 +- tools/stern/src/Stern/API/RoutesLegacy.hs | 700 ------------------ tools/stern/stern.cabal | 1 - 10 files changed, 5 insertions(+), 926 deletions(-) delete mode 100644 services/nginz/zwagger-ui/backoffice/api-docs/resources.json delete mode 100644 tools/stern/src/Stern/API/RoutesLegacy.hs diff --git a/charts/backoffice/templates/configmap.yaml b/charts/backoffice/templates/configmap.yaml index a0a2b09e82..e43214497f 100644 --- a/charts/backoffice/templates/configmap.yaml +++ b/charts/backoffice/templates/configmap.yaml @@ -7,10 +7,10 @@ data: logNetStrings: True # log using netstrings encoding: # http://cr.yp.to/proto/netstrings.txt logLevel: {{ .Values.config.logLevel }} + logFormat: {{ .Values.config.logFormat }} stern: host: 0.0.0.0 - port: 8081 - # Cannot listen on the same port as the frontend + port: 8080 brig: host: brig port: 8080 @@ -28,152 +28,3 @@ data: ibis: host: {{ .Values.config.ibisHost }} port: 8080 - nginx.conf: | - worker_processes 1; - worker_rlimit_nofile 1024; - pid /tmp/nginx.pid; - - events { - worker_connections 1024; - multi_accept off; - } - - http { - # - # Sockets - # - - sendfile on; - tcp_nopush on; - tcp_nodelay on; - - # - # Timeouts - # - - client_body_timeout 60s; - client_header_timeout 60s; - keepalive_timeout 30s; - send_timeout 60s; - - # - # Mapping for websocket connections - # - - map $http_upgrade $connection_upgrade { - websocket upgrade; - default ''; - } - - # - # Body - # - - client_max_body_size 16M; - - # - # Headers - # - - ignore_invalid_headers off; - - server_tokens off; - server_names_hash_bucket_size 64; - server_name_in_redirect off; - types_hash_max_size 2048; - - large_client_header_buffers 4 8k; - - # - # MIME - # - - include /etc/nginx/mime.types; - default_type application/octet-stream; - - # - # Logging - # - - access_log /dev/stdout; - error_log stderr; - - # - # Gzip - # - - gzip on; - gzip_disable msie6; - gzip_vary on; - gzip_proxied any; - gzip_comp_level 6; - gzip_buffers 16 8k; - gzip_http_version 1.1; - gzip_min_length 1024; - gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; - - # - # SSL - # - - add_header Strict-Transport-Security max-age=31536000; - - map $scheme $server_https { - default off; - https on; - } - - ssl_session_cache builtin:1000 shared:SSL:10m; - ssl_session_timeout 5m; - ssl_prefer_server_ciphers on; - ssl_protocols TLSv1.2 TLSv1.3; - # NOTE: These are some sane defaults (compliant to TR-02102-2), you may want to overrride them on your own installation - # For TR-02102-2 see https://www.bsi.bund.de/SharedDocs/Downloads/EN/BSI/Publications/TechGuidelines/TG02102/BSI-TR-02102-2.html - # As a Wire employee, for Wire-internal discussions and context see - # * https://wearezeta.atlassian.net/browse/FS-33 - # * https://wearezeta.atlassian.net/browse/FS-444 - ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384'; # for TLS 1.2 - # FUTUREWORK: upgrade nginx used for the backoffice to support ssl_conf_command (i.e. build a new backoffice-frontend), then uncomment below - # ssl_conf_command Ciphersuites TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384; # for TLS 1.3 - server { - listen {{ .Values.service.internalPort }}; - - # Backoffice code at /var/www - location / { - # NOTE: nginx's root is defined at compile time! This means that these roots - # depend on the values at the time of compilation for nginx, namely --conf-path - # and --prefix. If you don't use _full_ paths as root, they get resolved depending - # those prefixes... they really need to fix this! So we just assume that these - # paths can be created on any filesystem... - root /var/www/swagger-ui; - index index.html; - } - - # resources.json is needed by the backoffice app - location /api-docs { - # This asssumes the default location for the backoffice! - root /var/www/swagger-ui; - index resources.json; - } - - # The liveness/healthiness depends on stern - location /i/status { - proxy_pass http://localhost:8081; - proxy_http_version 1.1; - } - - rewrite ^/api-docs/stern /stern/api-docs?base_url={{ .Values.baseUrl }}/api break; - - # This path is used by swagger to fetch the docs from the service - location /stern { - proxy_pass http://localhost:8081; - proxy_http_version 1.1; - } - - # All others requests get proxied to stern, without the api prefix (which was added in the base_url above) - location ~ ^/api/(.*)$ { - proxy_pass http://localhost:8081/$1$is_args$query_string; - proxy_http_version 1.1; - } - } - } diff --git a/charts/backoffice/templates/deployment.yaml b/charts/backoffice/templates/deployment.yaml index 172e3fc135..788cea3e67 100644 --- a/charts/backoffice/templates/deployment.yaml +++ b/charts/backoffice/templates/deployment.yaml @@ -38,14 +38,6 @@ spec: - name: "backoffice-config" mountPath: /etc/wire/stern/conf/stern.yaml subPath: stern.yaml - - name: backoffice-frontend - image: "{{ .Values.images.frontend.repository }}:{{ .Values.images.frontend.tag }}" - imagePullPolicy: {{ default "" .Values.images.frontend.pullPolicy | quote }} - volumeMounts: - - name: "backoffice-config" - # We don't want to override existing files under /etc/nginx except for nginx.conf - mountPath: "/etc/nginx/nginx.conf" - subPath: nginx.conf ports: - containerPort: {{ .Values.service.internalPort }} livenessProbe: diff --git a/charts/backoffice/values.yaml b/charts/backoffice/values.yaml index bbdb1e881e..49f27abd43 100644 --- a/charts/backoffice/values.yaml +++ b/charts/backoffice/values.yaml @@ -1,9 +1,5 @@ replicaCount: 1 images: - frontend: - repository: quay.io/wire/backoffice-frontend - tag: 2.87.0 - pullPolicy: IfNotPresent stern: repository: quay.io/wire/stern tag: do-not-use @@ -19,6 +15,7 @@ resources: memory: 50Mi config: logLevel: Info + logFormat: StructuredJSON galebHost: galeb.integrations ibisHost: ibis.integrations baseUrl: http://localhost:8080 diff --git a/services/nginz/integration-test/conf/nginz/nginx.conf b/services/nginz/integration-test/conf/nginz/nginx.conf index 10e7a546ab..24155e2bbd 100644 --- a/services/nginz/integration-test/conf/nginz/nginx.conf +++ b/services/nginz/integration-test/conf/nginz/nginx.conf @@ -497,25 +497,7 @@ http { include common_response_with_zauth.conf; proxy_pass http://spar; } - - # Stern Endpoints - - # We add a `/stern` suffix to the URL to resolve clashes with non-Stern endpoints. - rewrite ^/backoffice/api-docs/stern /stern/api-docs?base_url=http://127.0.0.1:8080/stern/ break; - - location /stern/api-docs { - include common_response_no_zauth.conf; - # We don't use an `upstream` for stern, since running stern is optional. - proxy_pass http://127.0.0.1:8091; - } - - location /stern { - include common_response_no_zauth.conf; - # We don't use an `upstream` for stern, since running stern is optional. - # The trailing slash matters, as it makes sure the `/stern` prefix is removed. - proxy_pass http://127.0.0.1:8091/; - } - + # # Swagger Resource Listing # diff --git a/services/nginz/zwagger-ui/backoffice/api-docs/resources.json b/services/nginz/zwagger-ui/backoffice/api-docs/resources.json deleted file mode 100644 index db64e09127..0000000000 --- a/services/nginz/zwagger-ui/backoffice/api-docs/resources.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "Version": "1.0", - "swaggerVersion": "1.2", - "apis": [ - { - "path": "/stern", - "description": "Back Office" - } - ], - "info": { - "description": "The Back Office can only be used if Stern is running. It usually shouldn't be running, and if it is, make sure it can only be reached by admins, as it allows unauthorized access to endpoints. For more details see `tools/stern/README.md` in the `wire-server` repository." - } -} diff --git a/services/nginz/zwagger-ui/index.html b/services/nginz/zwagger-ui/index.html index 921da15b8c..2409c26180 100644 --- a/services/nginz/zwagger-ui/index.html +++ b/services/nginz/zwagger-ui/index.html @@ -43,7 +43,6 @@
-
@@ -54,9 +53,6 @@ - -