From 450ef8591cf0c6a2ae14d640b354fb82502654af Mon Sep 17 00:00:00 2001 From: Alexander Olofsson Date: Wed, 3 Aug 2022 17:52:01 +0200 Subject: [PATCH] matrix-synapse: Support MSC1929/extra .well-known --- charts/matrix-synapse/templates/ingress.yaml | 20 ++++--------------- .../templates/well-known-config.yaml | 15 ++++++++++++-- .../matrix-synapse/templates/well-known.yaml | 10 +++++----- charts/matrix-synapse/values.yaml | 12 +++++++++++ 4 files changed, 34 insertions(+), 23 deletions(-) diff --git a/charts/matrix-synapse/templates/ingress.yaml b/charts/matrix-synapse/templates/ingress.yaml index f786a9d..036a787 100644 --- a/charts/matrix-synapse/templates/ingress.yaml +++ b/charts/matrix-synapse/templates/ingress.yaml @@ -164,39 +164,27 @@ spec: {{- if has . $wkHosts }} {{- if $.Values.wellknown.enabled }} - - path: /.well-known/matrix/client + - path: /.well-known/matrix backend: {{- if $v1Ingress }} service: name: {{ $wkName }} port: number: 80 - pathType: Exact - {{- else }} - serviceName: {{ $wkName }} - servicePort: 80 - {{- end }} - - path: /.well-known/matrix/server - backend: - {{- if $v1Ingress }} - service: - name: {{ $wkName }} - port: - number: 80 - pathType: Exact + pathType: Prefix {{- else }} serviceName: {{ $wkName }} servicePort: 80 {{- end }} {{- else }} - - path: /.well-known/matrix/client + - path: /.well-known/matrix backend: {{- if $v1Ingress }} service: name: {{ $fullName }} port: number: {{ $.Values.service.port }} - pathType: Exact + pathType: Prefix {{- else }} serviceName: {{ $fullName }} servicePort: {{ $.Values.service.port }} diff --git a/charts/matrix-synapse/templates/well-known-config.yaml b/charts/matrix-synapse/templates/well-known-config.yaml index bd2274e..30f00c6 100644 --- a/charts/matrix-synapse/templates/well-known-config.yaml +++ b/charts/matrix-synapse/templates/well-known-config.yaml @@ -27,8 +27,11 @@ data: server.document-root = {{ .Values.wellknown.htdocsPath | quote }} server.pid-file = "/run/lighttpd.pid" url.rewrite-once = ( - "^/\.well-known/matrix/client" => "/client.json", - "^/\.well-known/matrix/server" => "/server.json" +{{- $keys := concat (list "client" "server") (keys .Values.wellknown.extraData) }} +{{- range $key := initial $keys }} + "^/\.well-known/matrix/{{ $key }}" => "/{{ $key }}.json", +{{- end }} + "^/\.well-known/matrix/{{ last $keys }}" => "/{{ last $keys }}.json" ) status.status-url = "/server-status" extforward.forwarder = ( "all" => "trust") @@ -52,4 +55,12 @@ data: {{- else }} {{ dict "m.homeserver" (dict "base_url" (printf "https://%s/" (.Values.publicServerName | default .Values.serverName))) | toJson | indent 4 }} {{- end }} +{{- range $key, $value := .Values.wellknown.extraData }} + {{ $key }}.json: |- +{{- if $value | kindIs "string" -}} + {{ $value | nindent 4 }} +{{- else -}} + {{ $value | toJson | nindent 4 }} +{{- end -}} +{{- end -}} {{- end -}} diff --git a/charts/matrix-synapse/templates/well-known.yaml b/charts/matrix-synapse/templates/well-known.yaml index d00c0eb..cac0050 100644 --- a/charts/matrix-synapse/templates/well-known.yaml +++ b/charts/matrix-synapse/templates/well-known.yaml @@ -64,12 +64,12 @@ spec: - mountPath: /etc/lighttpd/lighttpd.conf name: files subPath: lighttpd.conf - - mountPath: {{ .Values.wellknown.htdocsPath }}/client.json +{{- $keys := concat (list "client" "server") (keys .Values.wellknown.extraData) }} +{{- range $key := $keys }} + - mountPath: {{ $.Values.wellknown.htdocsPath }}/{{ $key }}.json name: files - subPath: client.json - - mountPath: {{ .Values.wellknown.htdocsPath }}/server.json - name: files - subPath: server.json + subPath: {{ $key }}.json +{{- end }} - mountPath: /run name: run resources: diff --git a/charts/matrix-synapse/values.yaml b/charts/matrix-synapse/values.yaml index 08a5496..f0bfa0e 100644 --- a/charts/matrix-synapse/values.yaml +++ b/charts/matrix-synapse/values.yaml @@ -578,6 +578,18 @@ wellknown: # m.homeserver: # base_url: https://matrix.example.com + ## Extra data objects to serve under .well-known/matrix/ + ## Dictionaries will be JSON converted, plain strings will be served as they are + ## + extraData: {} + ## MSC1929 example; + # support: + # admins: + # - matrix_id: '@admin:example.com' + # email_address: 'admin@example.com' + # role: 'admin' + # support_page: 'https://example.com/support' + ## A custom htdocs path, useful when running another image. ## htdocsPath: /var/www/localhost/htdocs