From ab23b4cca38118769165c91b2a68354dd77438a2 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Fri, 16 Aug 2019 13:57:36 +0100 Subject: [PATCH 1/5] Add flag in /versions for whether clients should send id_server params --- synapse/rest/client/versions.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/synapse/rest/client/versions.py b/synapse/rest/client/versions.py index 0e0919163267..ca762a0b6b7b 100644 --- a/synapse/rest/client/versions.py +++ b/synapse/rest/client/versions.py @@ -24,6 +24,10 @@ class VersionsRestServlet(RestServlet): PATTERNS = [re.compile("^/_matrix/client/versions$")] + def __init__(self, hs): + super(VersionsRestServlet, self).__init__() + self.config = hs.config + def on_GET(self, request): return ( 200, @@ -44,10 +48,22 @@ def on_GET(self, request): "r0.5.0", ], # as per MSC1497: - "unstable_features": {"m.lazy_load_members": True}, + "unstable_features": { + "m.lazy_load_members": True, + # Advertise to clients whether they need not include an `id_server` + # parameter during registration or password reset, as Synapse now decides + # itself which identity server to use (or none at all). + # + # This is also used by a client when they wish to bind a 3PID to their + # account, but not bind it to an identity server, the endpoint for which + # also requires `id_server`. If the homeserver is handling 3PID + # verification itself, there is no need to ask the user for `id_server` to + # be supplied. + "m.require_identity_server": self.config.account_threepid_delegate is None + }, }, ) -def register_servlets(http_server): - VersionsRestServlet().register(http_server) +def register_servlets(hs, http_server): + VersionsRestServlet(hs).register(http_server) From 6b8496d431a3712058b8cf855fd78283f99663c2 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Fri, 16 Aug 2019 14:54:18 +0100 Subject: [PATCH 2/5] Changelog --- changelog.d/5868.feature | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/5868.feature diff --git a/changelog.d/5868.feature b/changelog.d/5868.feature new file mode 100644 index 000000000000..69605c1ae134 --- /dev/null +++ b/changelog.d/5868.feature @@ -0,0 +1 @@ +Add `m.require_identity_server` key to `/versions`'s `unstable_features` section. \ No newline at end of file From 64d2235236df7d368ea25744fac8ce1d379d3e8d Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Fri, 16 Aug 2019 15:00:28 +0100 Subject: [PATCH 3/5] lint --- synapse/rest/client/versions.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/synapse/rest/client/versions.py b/synapse/rest/client/versions.py index ca762a0b6b7b..335ef690beb6 100644 --- a/synapse/rest/client/versions.py +++ b/synapse/rest/client/versions.py @@ -59,7 +59,8 @@ def on_GET(self, request): # also requires `id_server`. If the homeserver is handling 3PID # verification itself, there is no need to ask the user for `id_server` to # be supplied. - "m.require_identity_server": self.config.account_threepid_delegate is None + "m.require_identity_server": self.config.account_threepid_delegate + is None, }, }, ) From f0d57d71f7f9fc939bef8f4f757939ff39fa3e16 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Fri, 16 Aug 2019 15:20:33 +0100 Subject: [PATCH 4/5] linting made something gross happen --- synapse/rest/client/versions.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/synapse/rest/client/versions.py b/synapse/rest/client/versions.py index 335ef690beb6..e7f488376f35 100644 --- a/synapse/rest/client/versions.py +++ b/synapse/rest/client/versions.py @@ -59,8 +59,9 @@ def on_GET(self, request): # also requires `id_server`. If the homeserver is handling 3PID # verification itself, there is no need to ask the user for `id_server` to # be supplied. - "m.require_identity_server": self.config.account_threepid_delegate - is None, + "m.require_identity_server": ( + self.config.account_threepid_delegate is None + ), }, }, ) From 24000faadff91081f6cabc4a82a01495010b1af7 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Wed, 28 Aug 2019 11:45:45 +0100 Subject: [PATCH 5/5] Register servlets correctly --- synapse/app/client_reader.py | 2 +- synapse/rest/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/synapse/app/client_reader.py b/synapse/app/client_reader.py index 721bb5b119f3..7427620d1609 100644 --- a/synapse/app/client_reader.py +++ b/synapse/app/client_reader.py @@ -119,7 +119,7 @@ def _listen_http(self, listener_config): KeyChangesServlet(self).register(resource) VoipRestServlet(self).register(resource) PushRuleRestServlet(self).register(resource) - VersionsRestServlet().register(resource) + VersionsRestServlet(self).register(resource) resources.update({"/_matrix/client": resource}) diff --git a/synapse/rest/__init__.py b/synapse/rest/__init__.py index 1d20b96d0354..4a1fc2ec2bfe 100644 --- a/synapse/rest/__init__.py +++ b/synapse/rest/__init__.py @@ -73,7 +73,7 @@ def __init__(self, hs): @staticmethod def register_servlets(client_resource, hs): - versions.register_servlets(client_resource) + versions.register_servlets(hs, client_resource) # Deprecated in r0 initial_sync.register_servlets(hs, client_resource)