matrix-synapse: Support MSC1929/extra .well-known

This commit is contained in:
Alexander Olofsson 2022-08-03 17:52:01 +02:00
parent 47dd79bec1
commit 450ef8591c
No known key found for this signature in database
GPG key ID: D439C9470CB04C73
4 changed files with 34 additions and 23 deletions

View file

@ -164,39 +164,27 @@ spec:
{{- if has . $wkHosts }} {{- if has . $wkHosts }}
{{- if $.Values.wellknown.enabled }} {{- if $.Values.wellknown.enabled }}
- path: /.well-known/matrix/client - path: /.well-known/matrix
backend: backend:
{{- if $v1Ingress }} {{- if $v1Ingress }}
service: service:
name: {{ $wkName }} name: {{ $wkName }}
port: port:
number: 80 number: 80
pathType: Exact pathType: Prefix
{{- else }}
serviceName: {{ $wkName }}
servicePort: 80
{{- end }}
- path: /.well-known/matrix/server
backend:
{{- if $v1Ingress }}
service:
name: {{ $wkName }}
port:
number: 80
pathType: Exact
{{- else }} {{- else }}
serviceName: {{ $wkName }} serviceName: {{ $wkName }}
servicePort: 80 servicePort: 80
{{- end }} {{- end }}
{{- else }} {{- else }}
- path: /.well-known/matrix/client - path: /.well-known/matrix
backend: backend:
{{- if $v1Ingress }} {{- if $v1Ingress }}
service: service:
name: {{ $fullName }} name: {{ $fullName }}
port: port:
number: {{ $.Values.service.port }} number: {{ $.Values.service.port }}
pathType: Exact pathType: Prefix
{{- else }} {{- else }}
serviceName: {{ $fullName }} serviceName: {{ $fullName }}
servicePort: {{ $.Values.service.port }} servicePort: {{ $.Values.service.port }}

View file

@ -27,8 +27,11 @@ data:
server.document-root = {{ .Values.wellknown.htdocsPath | quote }} server.document-root = {{ .Values.wellknown.htdocsPath | quote }}
server.pid-file = "/run/lighttpd.pid" server.pid-file = "/run/lighttpd.pid"
url.rewrite-once = ( url.rewrite-once = (
"^/\.well-known/matrix/client" => "/client.json", {{- $keys := concat (list "client" "server") (keys .Values.wellknown.extraData) }}
"^/\.well-known/matrix/server" => "/server.json" {{- range $key := initial $keys }}
"^/\.well-known/matrix/{{ $key }}" => "/{{ $key }}.json",
{{- end }}
"^/\.well-known/matrix/{{ last $keys }}" => "/{{ last $keys }}.json"
) )
status.status-url = "/server-status" status.status-url = "/server-status"
extforward.forwarder = ( "all" => "trust") extforward.forwarder = ( "all" => "trust")
@ -52,4 +55,12 @@ data:
{{- else }} {{- else }}
{{ dict "m.homeserver" (dict "base_url" (printf "https://%s/" (.Values.publicServerName | default .Values.serverName))) | toJson | indent 4 }} {{ dict "m.homeserver" (dict "base_url" (printf "https://%s/" (.Values.publicServerName | default .Values.serverName))) | toJson | indent 4 }}
{{- end }} {{- end }}
{{- range $key, $value := .Values.wellknown.extraData }}
{{ $key }}.json: |-
{{- if $value | kindIs "string" -}}
{{ $value | nindent 4 }}
{{- else -}}
{{ $value | toJson | nindent 4 }}
{{- end -}}
{{- end -}}
{{- end -}} {{- end -}}

View file

@ -64,12 +64,12 @@ spec:
- mountPath: /etc/lighttpd/lighttpd.conf - mountPath: /etc/lighttpd/lighttpd.conf
name: files name: files
subPath: lighttpd.conf 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 name: files
subPath: client.json subPath: {{ $key }}.json
- mountPath: {{ .Values.wellknown.htdocsPath }}/server.json {{- end }}
name: files
subPath: server.json
- mountPath: /run - mountPath: /run
name: run name: run
resources: resources:

View file

@ -578,6 +578,18 @@ wellknown:
# m.homeserver: # m.homeserver:
# base_url: https://matrix.example.com # base_url: https://matrix.example.com
## Extra data objects to serve under .well-known/matrix/<data>
## 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. ## A custom htdocs path, useful when running another image.
## ##
htdocsPath: /var/www/localhost/htdocs htdocsPath: /var/www/localhost/htdocs