Skip to content

Commit 21a67b0

Browse files
Add support for .well-known/matrix/support in Well Known Delegation
- Add new support configuration to well-known delegation - Modify schema to accommodate support configuration - Update templates to include support file - Update tests to verify support configuration handling
1 parent c797143 commit 21a67b0

File tree

10 files changed

+43
-2
lines changed

10 files changed

+43
-2
lines changed

charts/matrix-stack/configs/well-known/partial-haproxy.cfg.tpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,13 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
1010
frontend well-known-in
1111
bind *:8010
1212

13+
# same as http log, with %Th (handshake time)
14+
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"
15+
16+
1317
acl well-known path /.well-known/matrix/server
1418
acl well-known path /.well-known/matrix/client
19+
acl well-known path /.well-known/matrix/support
1520
acl well-known path /.well-known/element/element.json
1621

1722
use_backend well-known-static if well-known
@@ -31,6 +36,7 @@ backend well-known-static
3136

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

3642
{{- end -}}

charts/matrix-stack/source/wellKnownDelegation.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@
1818
"client": {
1919
"type": "string"
2020
},
21+
"element": {
22+
"type": "string"
23+
},
2124
"server": {
2225
"type": "string"
2326
},
24-
"element": {
27+
"support": {
2528
"type": "string"
2629
}
2730
}

charts/matrix-stack/source/wellKnownDelegation.yaml.j2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ additional:
1616
client: "{}"
1717
server: "{}"
1818
element: "{}"
19+
support: "{}"

charts/matrix-stack/templates/well-known/_helpers.tpl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,12 @@ k8s.element.io/target-instance: {{ $root.Release.Name }}-haproxy
6666
{{- tpl (toPrettyJson (merge $config $additional)) $root -}}
6767
{{- end -}}
6868
{{- end }}
69+
70+
{{- define "element-io.well-known-delegation.support" }}
71+
{{- $root := .root -}}
72+
{{- with required "element-io.well-known-delegation.support missing context" .context -}}
73+
{{- $config := dict -}}
74+
{{- $additional := .additional.support | fromJson -}}
75+
{{- tpl (toPrettyJson (merge $config $additional)) $root -}}
76+
{{- end -}}
77+
{{- end }}

charts/matrix-stack/templates/well-known/configmap.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ data:
1818
{{ (tpl (include "element-io.well-known-delegation.client" (dict "root" $ "context" .)) $) | nindent 4 }}
1919
server: |
2020
{{ (tpl (include "element-io.well-known-delegation.server" (dict "root" $ "context" .)) $) | nindent 4 }}
21+
support: |
22+
{{ (tpl (include "element-io.well-known-delegation.support" (dict "root" $ "context" .)) $) | nindent 4 }}
2123
element.json: |
2224
{{ (tpl (include "element-io.well-known-delegation.element" (dict "root" $ "context" .)) $) | nindent 4 }}
2325
{{- end -}}

charts/matrix-stack/values.schema.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3761,10 +3761,13 @@
37613761
"client": {
37623762
"type": "string"
37633763
},
3764+
"element": {
3765+
"type": "string"
3766+
},
37643767
"server": {
37653768
"type": "string"
37663769
},
3767-
"element": {
3770+
"support": {
37683771
"type": "string"
37693772
}
37703773
},

charts/matrix-stack/values.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,3 +1047,4 @@ wellKnownDelegation:
10471047
client: "{}"
10481048
server: "{}"
10491049
element: "{}"
1050+
support: "{}"

newsfragments/133.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add support for .well-known/matrix/support in Well Known Delegation.

tests/integration/test_well_known_delegation.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ async def test_well_known_files_can_be_accessed(
2929
else:
3030
assert json_content == {}
3131

32+
json_content = await aiottp_get_json(
33+
f"https://{generated_data.server_name}/.well-known/matrix/support", ssl_context
34+
)
35+
assert json_content == {}
36+
3237
json_content = await aiottp_get_json(
3338
f"https://{generated_data.server_name}/.well-known/element/element.json", ssl_context
3439
)

tests/manifests/test_well_known_delegation.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ async def test_only_additional_if_all_disabled_in_well_known(values, make_templa
1313
client_config = {"testclientkey": {"testsubket": "testvalue"}}
1414
server_config = {"testserverkey": {"testsubket": "testvalue"}}
1515
element_config = {"testelementkey": {"testsubket": "testvalue"}}
16+
support_config = {"testsupportkey": {"testsubket": "testvalue"}}
1617
values["wellKnownDelegation"].setdefault("additional", {})["client"] = json.dumps(client_config)
1718
values["wellKnownDelegation"].setdefault("additional", {})["server"] = json.dumps(server_config)
1819
values["wellKnownDelegation"].setdefault("additional", {})["element"] = json.dumps(element_config)
20+
values["wellKnownDelegation"].setdefault("additional", {})["support"] = json.dumps(support_config)
1921
for template in await make_templates(values):
2022
if template["kind"] == "ConfigMap" and template["metadata"]["name"] == "pytest-well-known-haproxy":
2123
client_from_json = json.loads(template["data"]["client"])
@@ -27,6 +29,9 @@ async def test_only_additional_if_all_disabled_in_well_known(values, make_templa
2729
element_from_json = json.loads(template["data"]["element.json"])
2830
assert element_from_json == element_config
2931

32+
support_config_from_json = json.loads(template["data"]["support"])
33+
assert support_config == support_config_from_json
34+
3035
break
3136
else:
3237
raise AssertionError("Unable to find WellKnownDelegationConfigMap")
@@ -38,9 +43,11 @@ async def test_synapse_injected_in_server_and_client_well_known(values, make_tem
3843
client_config = {"testclientkey": {"testsubket": "testvalue"}}
3944
server_config = {"testserverkey": {"testsubket": "testvalue"}}
4045
element_config = {"testelementkey": {"testsubket": "testvalue"}}
46+
support_config = {"testsupportkey": {"testsubket": "testvalue"}}
4147
values["wellKnownDelegation"].setdefault("additional", {})["client"] = json.dumps(client_config)
4248
values["wellKnownDelegation"].setdefault("additional", {})["server"] = json.dumps(server_config)
4349
values["wellKnownDelegation"].setdefault("additional", {})["element"] = json.dumps(element_config)
50+
values["wellKnownDelegation"].setdefault("additional", {})["support"] = json.dumps(support_config)
4451

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

65+
support_from_json = json.loads(template["data"]["support"])
66+
assert support_from_json == support_config
67+
5868
break
5969
else:
6070
raise AssertionError("Unable to find WellKnownDelegationConfigMap")

0 commit comments

Comments
 (0)