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

Commit 91221b6

Browse files
authored
Add deprecation warnings for webclient listener and non-HTTP(S) web_client_location. (#11774)
This changes the behaviour of the root endpoint to redirect directly to the configuration of `web_client_location` if it is given an HTTP(S) URL.
1 parent f160fe1 commit 91221b6

File tree

5 files changed

+40
-28
lines changed

5 files changed

+40
-28
lines changed

changelog.d/11774.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Deprecate support for `webclient` listeners and non-HTTP(S) `web_client_location` configuration.

docs/sample_config.yaml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,7 @@ server_name: "SERVERNAME"
7474
#
7575
pid_file: DATADIR/homeserver.pid
7676

77-
# The absolute URL to the web client which /_matrix/client will redirect
78-
# to if 'webclient' is configured under the 'listeners' configuration.
79-
#
80-
# This option can be also set to the filesystem path to the web client
81-
# which will be served at /_matrix/client/ if 'webclient' is configured
82-
# under the 'listeners' configuration, however this is a security risk:
83-
# https://github.com/matrix-org/synapse#security-note
77+
# The absolute URL to the web client which / will redirect to.
8478
#
8579
#web_client_location: https://riot.example.com/
8680

@@ -310,8 +304,6 @@ presence:
310304
# static: static resources under synapse/static (/_matrix/static). (Mostly
311305
# useful for 'fallback authentication'.)
312306
#
313-
# webclient: A web client. Requires web_client_location to be set.
314-
#
315307
listeners:
316308
# TLS-enabled listener: for when matrix traffic is sent directly to synapse.
317309
#

docs/upgrade.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,17 @@ process, for example:
8585
dpkg -i matrix-synapse-py3_1.3.0+stretch1_amd64.deb
8686
```
8787

88+
# Upgrading to v1.51.0
89+
90+
## Deprecation of `webclient` listeners and non-HTTP(S) `web_client_location`
91+
92+
Listeners of type `webclient` are deprecated and scheduled to be removed in
93+
Synapse v1.53.0.
94+
95+
Similarly, a non-HTTP(S) `web_client_location` configuration is deprecated and
96+
will become a configuration error in Synapse v1.53.0.
97+
98+
8899
# Upgrading to v1.50.0
89100

90101
## Dropping support for old Python and Postgres versions

synapse/app/homeserver.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,10 @@ def _listener_http(
132132
self._module_web_resources_consumed = True
133133

134134
# try to find something useful to redirect '/' to
135-
if WEB_CLIENT_PREFIX in resources:
136-
root_resource: Resource = RootOptionsRedirectResource(WEB_CLIENT_PREFIX)
135+
if self.config.server.web_client_location_is_redirect:
136+
root_resource: Resource = RootOptionsRedirectResource(
137+
self.config.server.web_client_location
138+
)
137139
elif STATIC_PREFIX in resources:
138140
root_resource = RootOptionsRedirectResource(STATIC_PREFIX)
139141
else:
@@ -262,15 +264,15 @@ def _configure_named_resource(
262264
resources[SERVER_KEY_V2_PREFIX] = KeyApiV2Resource(self)
263265

264266
if name == "webclient":
267+
# webclient listeners are deprecated as of Synapse v1.51.0, remove it
268+
# in > v1.53.0.
265269
webclient_loc = self.config.server.web_client_location
266270

267271
if webclient_loc is None:
268272
logger.warning(
269273
"Not enabling webclient resource, as web_client_location is unset."
270274
)
271-
elif webclient_loc.startswith("http://") or webclient_loc.startswith(
272-
"https://"
273-
):
275+
elif self.config.server.web_client_location_is_redirect:
274276
resources[WEB_CLIENT_PREFIX] = RootRedirect(webclient_loc)
275277
else:
276278
logger.warning(

synapse/config/server.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ def read_config(self, config, **kwargs):
259259
raise ConfigError(str(e))
260260

261261
self.pid_file = self.abspath(config.get("pid_file"))
262-
self.web_client_location = config.get("web_client_location", None)
263262
self.soft_file_limit = config.get("soft_file_limit", 0)
264263
self.daemonize = config.get("daemonize")
265264
self.print_pidfile = config.get("print_pidfile")
@@ -506,8 +505,17 @@ def read_config(self, config, **kwargs):
506505
l2.append(listener)
507506
self.listeners = l2
508507

509-
if not self.web_client_location:
510-
_warn_if_webclient_configured(self.listeners)
508+
self.web_client_location = config.get("web_client_location", None)
509+
self.web_client_location_is_redirect = self.web_client_location and (
510+
self.web_client_location.startswith("http://")
511+
or self.web_client_location.startswith("https://")
512+
)
513+
# A non-HTTP(S) web client location is deprecated.
514+
if self.web_client_location and not self.web_client_location_is_redirect:
515+
logger.warning(NO_MORE_NONE_HTTP_WEB_CLIENT_LOCATION_WARNING)
516+
517+
# Warn if webclient is configured for a worker.
518+
_warn_if_webclient_configured(self.listeners)
511519

512520
self.gc_thresholds = read_gc_thresholds(config.get("gc_thresholds", None))
513521
self.gc_seconds = self.read_gc_intervals(config.get("gc_min_interval", None))
@@ -793,13 +801,7 @@ def generate_config_section(
793801
#
794802
pid_file: %(pid_file)s
795803
796-
# The absolute URL to the web client which /_matrix/client will redirect
797-
# to if 'webclient' is configured under the 'listeners' configuration.
798-
#
799-
# This option can be also set to the filesystem path to the web client
800-
# which will be served at /_matrix/client/ if 'webclient' is configured
801-
# under the 'listeners' configuration, however this is a security risk:
802-
# https://github.com/matrix-org/synapse#security-note
804+
# The absolute URL to the web client which / will redirect to.
803805
#
804806
#web_client_location: https://riot.example.com/
805807
@@ -1011,8 +1013,6 @@ def generate_config_section(
10111013
# static: static resources under synapse/static (/_matrix/static). (Mostly
10121014
# useful for 'fallback authentication'.)
10131015
#
1014-
# webclient: A web client. Requires web_client_location to be set.
1015-
#
10161016
listeners:
10171017
# TLS-enabled listener: for when matrix traffic is sent directly to synapse.
10181018
#
@@ -1349,9 +1349,15 @@ def parse_listener_def(listener: Any) -> ListenerConfig:
13491349
return ListenerConfig(port, bind_addresses, listener_type, tls, http_config)
13501350

13511351

1352+
NO_MORE_NONE_HTTP_WEB_CLIENT_LOCATION_WARNING = """
1353+
Synapse no longer supports serving a web client. To remove this warning,
1354+
configure 'web_client_location' with an HTTP(S) URL.
1355+
"""
1356+
1357+
13521358
NO_MORE_WEB_CLIENT_WARNING = """
1353-
Synapse no longer includes a web client. To enable a web client, configure
1354-
web_client_location. To remove this warning, remove 'webclient' from the 'listeners'
1359+
Synapse no longer includes a web client. To redirect the root resource to a web client, configure
1360+
'web_client_location'. To remove this warning, remove 'webclient' from the 'listeners'
13551361
configuration.
13561362
"""
13571363

0 commit comments

Comments
 (0)