Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
frontend well-known-in
bind *:8010

# same as http log, with %Th (handshake time)
log-format "%ci:%cp [%tr] %ft %b/%s %Th/%TR/%Tw/%Tc/%Tr/%Ta %ST %B %CC %CS %tsc %ac/%fc/%bc/%sc/%rc %sq/%bq %hr %hs %{+Q}r"


acl well-known path /.well-known/matrix/server
acl well-known path /.well-known/matrix/client
acl well-known path /.well-known/matrix/support
acl well-known path /.well-known/element/element.json

use_backend well-known-static if well-known
Expand All @@ -31,6 +36,7 @@ backend well-known-static

http-request return status 200 content-type "application/json" file "/well-known/server" if { path /.well-known/matrix/server }
http-request return status 200 content-type "application/json" file "/well-known/client" if { path /.well-known/matrix/client }
http-request return status 200 content-type "application/json" file "/well-known/support" if { path /.well-known/matrix/support }
http-request return status 200 content-type "application/json" file "/well-known/element.json" if { path /.well-known/element/element.json }

{{- end -}}
5 changes: 4 additions & 1 deletion charts/matrix-stack/source/wellKnownDelegation.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@
"client": {
"type": "string"
},
"element": {
"type": "string"
},
"server": {
"type": "string"
},
"element": {
"support": {
"type": "string"
}
}
Expand Down
1 change: 1 addition & 0 deletions charts/matrix-stack/source/wellKnownDelegation.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ additional:
client: "{}"
server: "{}"
element: "{}"
support: "{}"
9 changes: 9 additions & 0 deletions charts/matrix-stack/templates/well-known/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,12 @@ k8s.element.io/target-instance: {{ $root.Release.Name }}-haproxy
{{- tpl (toPrettyJson (merge $config $additional)) $root -}}
{{- end -}}
{{- end }}

{{- define "element-io.well-known-delegation.support" }}
{{- $root := .root -}}
{{- with required "element-io.well-known-delegation.support missing context" .context -}}
{{- $config := dict -}}
{{- $additional := .additional.support | fromJson -}}
{{- tpl (toPrettyJson (merge $config $additional)) $root -}}
{{- end -}}
{{- end }}
2 changes: 2 additions & 0 deletions charts/matrix-stack/templates/well-known/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ data:
{{ (tpl (include "element-io.well-known-delegation.client" (dict "root" $ "context" .)) $) | nindent 4 }}
server: |
{{ (tpl (include "element-io.well-known-delegation.server" (dict "root" $ "context" .)) $) | nindent 4 }}
support: |
{{ (tpl (include "element-io.well-known-delegation.support" (dict "root" $ "context" .)) $) | nindent 4 }}
element.json: |
{{ (tpl (include "element-io.well-known-delegation.element" (dict "root" $ "context" .)) $) | nindent 4 }}
{{- end -}}
Expand Down
5 changes: 4 additions & 1 deletion charts/matrix-stack/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3761,10 +3761,13 @@
"client": {
"type": "string"
},
"element": {
"type": "string"
},
"server": {
"type": "string"
},
"element": {
"support": {
"type": "string"
}
},
Expand Down
1 change: 1 addition & 0 deletions charts/matrix-stack/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1047,3 +1047,4 @@ wellKnownDelegation:
client: "{}"
server: "{}"
element: "{}"
support: "{}"
1 change: 1 addition & 0 deletions newsfragments/133.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add support for .well-known/matrix/support in Well Known Delegation.
5 changes: 5 additions & 0 deletions tests/integration/test_well_known_delegation.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ async def test_well_known_files_can_be_accessed(
else:
assert json_content == {}

json_content = await aiottp_get_json(
f"https://{generated_data.server_name}/.well-known/matrix/support", ssl_context
)
assert json_content == {}

json_content = await aiottp_get_json(
f"https://{generated_data.server_name}/.well-known/element/element.json", ssl_context
)
Expand Down
10 changes: 10 additions & 0 deletions tests/manifests/test_well_known_delegation.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ async def test_only_additional_if_all_disabled_in_well_known(values, make_templa
client_config = {"testclientkey": {"testsubket": "testvalue"}}
server_config = {"testserverkey": {"testsubket": "testvalue"}}
element_config = {"testelementkey": {"testsubket": "testvalue"}}
support_config = {"testsupportkey": {"testsubket": "testvalue"}}
values["wellKnownDelegation"].setdefault("additional", {})["client"] = json.dumps(client_config)
values["wellKnownDelegation"].setdefault("additional", {})["server"] = json.dumps(server_config)
values["wellKnownDelegation"].setdefault("additional", {})["element"] = json.dumps(element_config)
values["wellKnownDelegation"].setdefault("additional", {})["support"] = json.dumps(support_config)
for template in await make_templates(values):
if template["kind"] == "ConfigMap" and template["metadata"]["name"] == "pytest-well-known-haproxy":
client_from_json = json.loads(template["data"]["client"])
Expand All @@ -27,6 +29,9 @@ async def test_only_additional_if_all_disabled_in_well_known(values, make_templa
element_from_json = json.loads(template["data"]["element.json"])
assert element_from_json == element_config

support_config_from_json = json.loads(template["data"]["support"])
assert support_config == support_config_from_json

break
else:
raise AssertionError("Unable to find WellKnownDelegationConfigMap")
Expand All @@ -38,9 +43,11 @@ async def test_synapse_injected_in_server_and_client_well_known(values, make_tem
client_config = {"testclientkey": {"testsubket": "testvalue"}}
server_config = {"testserverkey": {"testsubket": "testvalue"}}
element_config = {"testelementkey": {"testsubket": "testvalue"}}
support_config = {"testsupportkey": {"testsubket": "testvalue"}}
values["wellKnownDelegation"].setdefault("additional", {})["client"] = json.dumps(client_config)
values["wellKnownDelegation"].setdefault("additional", {})["server"] = json.dumps(server_config)
values["wellKnownDelegation"].setdefault("additional", {})["element"] = json.dumps(element_config)
values["wellKnownDelegation"].setdefault("additional", {})["support"] = json.dumps(support_config)

synapse_federation = {"m.server": "synapse.ess.localhost:443"}
synapse_base_url = {"m.homeserver": {"base_url": "https://synapse.ess.localhost"}}
Expand All @@ -55,6 +62,9 @@ async def test_synapse_injected_in_server_and_client_well_known(values, make_tem
element_from_json = json.loads(template["data"]["element.json"])
assert element_from_json == element_config

support_from_json = json.loads(template["data"]["support"])
assert support_from_json == support_config

break
else:
raise AssertionError("Unable to find WellKnownDelegationConfigMap")