Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 119edf5

Browse files
authored
Remove support for the webclient listener. (#11895)
Also remove support for non-HTTP(S) web_client_location.
1 parent 6b1c265 commit 119edf5

File tree

6 files changed

+29
-176
lines changed

6 files changed

+29
-176
lines changed

changelog.d/11895.removal

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Drop support for `webclient` listeners and configuring `web_client_location` to a non-HTTP(S) URL. Deprecated configurations are a configuration error.

docs/upgrade.md

+13
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,19 @@ process, for example:
8585
dpkg -i matrix-synapse-py3_1.3.0+stretch1_amd64.deb
8686
```
8787

88+
# Upgrading to v1.53.0
89+
90+
## Dropping support for `webclient` listeners and non-HTTP(S) `web_client_location`
91+
92+
Per the deprecation notice in Synapse v1.51.0, listeners of type `webclient`
93+
are no longer supported and configuring them is a now a configuration error.
94+
95+
Configuring a non-HTTP(S) `web_client_location` configuration is is now a
96+
configuration error. Since the `webclient` listener is no longer supported, this
97+
setting only applies to the root path `/` of Synapse's web server and no longer
98+
the `/_matrix/client/` path.
99+
100+
88101
# Upgrading to v1.51.0
89102
90103
## Deprecation of `webclient` listeners and non-HTTP(S) `web_client_location`

synapse/api/urls.py

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
FEDERATION_V2_PREFIX = FEDERATION_PREFIX + "/v2"
2929
FEDERATION_UNSTABLE_PREFIX = FEDERATION_PREFIX + "/unstable"
3030
STATIC_PREFIX = "/_matrix/static"
31-
WEB_CLIENT_PREFIX = "/_matrix/client"
3231
SERVER_KEY_V2_PREFIX = "/_matrix/key/v2"
3332
MEDIA_R0_PREFIX = "/_matrix/media/r0"
3433
MEDIA_V3_PREFIX = "/_matrix/media/v3"

synapse/app/homeserver.py

+3-31
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
from twisted.internet.tcp import Port
2222
from twisted.web.resource import EncodingResourceWrapper, Resource
2323
from twisted.web.server import GzipEncoderFactory
24-
from twisted.web.static import File
2524

2625
import synapse
2726
import synapse.config.logger
@@ -33,7 +32,6 @@
3332
MEDIA_V3_PREFIX,
3433
SERVER_KEY_V2_PREFIX,
3534
STATIC_PREFIX,
36-
WEB_CLIENT_PREFIX,
3735
)
3836
from synapse.app import _base
3937
from synapse.app._base import (
@@ -53,7 +51,6 @@
5351
from synapse.http.server import (
5452
OptionsResource,
5553
RootOptionsRedirectResource,
56-
RootRedirect,
5754
StaticResource,
5855
)
5956
from synapse.http.site import SynapseSite
@@ -134,15 +131,12 @@ def _listener_http(
134131
# Try to find something useful to serve at '/':
135132
#
136133
# 1. Redirect to the web client if it is an HTTP(S) URL.
137-
# 2. Redirect to the web client served via Synapse.
138-
# 3. Redirect to the static "Synapse is running" page.
139-
# 4. Do not redirect and use a blank resource.
140-
if self.config.server.web_client_location_is_redirect:
134+
# 2. Redirect to the static "Synapse is running" page.
135+
# 3. Do not redirect and use a blank resource.
136+
if self.config.server.web_client_location:
141137
root_resource: Resource = RootOptionsRedirectResource(
142138
self.config.server.web_client_location
143139
)
144-
elif WEB_CLIENT_PREFIX in resources:
145-
root_resource = RootOptionsRedirectResource(WEB_CLIENT_PREFIX)
146140
elif STATIC_PREFIX in resources:
147141
root_resource = RootOptionsRedirectResource(STATIC_PREFIX)
148142
else:
@@ -270,28 +264,6 @@ def _configure_named_resource(
270264
if name in ["keys", "federation"]:
271265
resources[SERVER_KEY_V2_PREFIX] = KeyApiV2Resource(self)
272266

273-
if name == "webclient":
274-
# webclient listeners are deprecated as of Synapse v1.51.0, remove it
275-
# in > v1.53.0.
276-
webclient_loc = self.config.server.web_client_location
277-
278-
if webclient_loc is None:
279-
logger.warning(
280-
"Not enabling webclient resource, as web_client_location is unset."
281-
)
282-
elif self.config.server.web_client_location_is_redirect:
283-
resources[WEB_CLIENT_PREFIX] = RootRedirect(webclient_loc)
284-
else:
285-
logger.warning(
286-
"Running webclient on the same domain is not recommended: "
287-
"https://github.com/matrix-org/synapse#security-note - "
288-
"after you move webclient to different host you can set "
289-
"web_client_location to its full URL to enable redirection."
290-
)
291-
# GZip is disabled here due to
292-
# https://twistedmatrix.com/trac/ticket/7678
293-
resources[WEB_CLIENT_PREFIX] = File(webclient_loc)
294-
295267
if name == "metrics" and self.config.metrics.enable_metrics:
296268
resources[METRICS_PREFIX] = MetricsResource(RegistryProxy)
297269

synapse/config/server.py

+12-36
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ def generate_ip_set(
179179
"openid",
180180
"replication",
181181
"static",
182-
"webclient",
183182
}
184183

185184

@@ -519,16 +518,12 @@ def read_config(self, config, **kwargs):
519518
self.listeners = l2
520519

521520
self.web_client_location = config.get("web_client_location", None)
522-
self.web_client_location_is_redirect = self.web_client_location and (
521+
# Non-HTTP(S) web client location is not supported.
522+
if self.web_client_location and not (
523523
self.web_client_location.startswith("http://")
524524
or self.web_client_location.startswith("https://")
525-
)
526-
# A non-HTTP(S) web client location is deprecated.
527-
if self.web_client_location and not self.web_client_location_is_redirect:
528-
logger.warning(NO_MORE_NONE_HTTP_WEB_CLIENT_LOCATION_WARNING)
529-
530-
# Warn if webclient is configured for a worker.
531-
_warn_if_webclient_configured(self.listeners)
525+
):
526+
raise ConfigError("web_client_location must point to a HTTP(S) URL.")
532527

533528
self.gc_thresholds = read_gc_thresholds(config.get("gc_thresholds", None))
534529
self.gc_seconds = self.read_gc_intervals(config.get("gc_min_interval", None))
@@ -1351,42 +1346,23 @@ def parse_listener_def(listener: Any) -> ListenerConfig:
13511346

13521347
http_config = None
13531348
if listener_type == "http":
1349+
try:
1350+
resources = [
1351+
HttpResourceConfig(**res) for res in listener.get("resources", [])
1352+
]
1353+
except ValueError as e:
1354+
raise ConfigError("Unknown listener resource") from e
1355+
13541356
http_config = HttpListenerConfig(
13551357
x_forwarded=listener.get("x_forwarded", False),
1356-
resources=[
1357-
HttpResourceConfig(**res) for res in listener.get("resources", [])
1358-
],
1358+
resources=resources,
13591359
additional_resources=listener.get("additional_resources", {}),
13601360
tag=listener.get("tag"),
13611361
)
13621362

13631363
return ListenerConfig(port, bind_addresses, listener_type, tls, http_config)
13641364

13651365

1366-
NO_MORE_NONE_HTTP_WEB_CLIENT_LOCATION_WARNING = """
1367-
Synapse no longer supports serving a web client. To remove this warning,
1368-
configure 'web_client_location' with an HTTP(S) URL.
1369-
"""
1370-
1371-
1372-
NO_MORE_WEB_CLIENT_WARNING = """
1373-
Synapse no longer includes a web client. To redirect the root resource to a web client, configure
1374-
'web_client_location'. To remove this warning, remove 'webclient' from the 'listeners'
1375-
configuration.
1376-
"""
1377-
1378-
1379-
def _warn_if_webclient_configured(listeners: Iterable[ListenerConfig]) -> None:
1380-
for listener in listeners:
1381-
if not listener.http_options:
1382-
continue
1383-
for res in listener.http_options.resources:
1384-
for name in res.names:
1385-
if name == "webclient":
1386-
logger.warning(NO_MORE_WEB_CLIENT_WARNING)
1387-
return
1388-
1389-
13901366
_MANHOLE_SETTINGS_SCHEMA = {
13911367
"type": "object",
13921368
"properties": {

tests/http/test_webclient.py

-108
This file was deleted.

0 commit comments

Comments
 (0)