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

Commit 8cd8124

Browse files
Add flag in /versions for whether clients should send id_server params (#5868)
When a client is registering an account, they need to know whether they should supply an `id_server` param (the contents being the domain of an identity server) to the server in order to specify which `id_server` to send their email from. Beginning from the branch this PR is getting merged into, the homeserver has the capability to send registration emails, as well as instead specify which identity server should send them. There's no longer any need for the client to specify an identity server here. This flag will also be used in other cases, such as password reset and binding 3PIDs, so it's preferable to not just put it in the registration parameters. We will remove this flag in the future when the spec drops support from needing `id_server` in `/register` and other endpoints, and Synapse drops support for older spec versions.
1 parent 7739f23 commit 8cd8124

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

changelog.d/5868.feature

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add `m.require_identity_server` key to `/versions`'s `unstable_features` section.

synapse/app/client_reader.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def _listen_http(self, listener_config):
119119
KeyChangesServlet(self).register(resource)
120120
VoipRestServlet(self).register(resource)
121121
PushRuleRestServlet(self).register(resource)
122-
VersionsRestServlet().register(resource)
122+
VersionsRestServlet(self).register(resource)
123123

124124
resources.update({"/_matrix/client": resource})
125125

synapse/rest/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def __init__(self, hs):
7373

7474
@staticmethod
7575
def register_servlets(client_resource, hs):
76-
versions.register_servlets(client_resource)
76+
versions.register_servlets(hs, client_resource)
7777

7878
# Deprecated in r0
7979
initial_sync.register_servlets(hs, client_resource)

synapse/rest/client/versions.py

+21-3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
class VersionsRestServlet(RestServlet):
2525
PATTERNS = [re.compile("^/_matrix/client/versions$")]
2626

27+
def __init__(self, hs):
28+
super(VersionsRestServlet, self).__init__()
29+
self.config = hs.config
30+
2731
def on_GET(self, request):
2832
return (
2933
200,
@@ -44,10 +48,24 @@ def on_GET(self, request):
4448
"r0.5.0",
4549
],
4650
# as per MSC1497:
47-
"unstable_features": {"m.lazy_load_members": True},
51+
"unstable_features": {
52+
"m.lazy_load_members": True,
53+
# Advertise to clients whether they need not include an `id_server`
54+
# parameter during registration or password reset, as Synapse now decides
55+
# itself which identity server to use (or none at all).
56+
#
57+
# This is also used by a client when they wish to bind a 3PID to their
58+
# account, but not bind it to an identity server, the endpoint for which
59+
# also requires `id_server`. If the homeserver is handling 3PID
60+
# verification itself, there is no need to ask the user for `id_server` to
61+
# be supplied.
62+
"m.require_identity_server": (
63+
self.config.account_threepid_delegate is None
64+
),
65+
},
4866
},
4967
)
5068

5169

52-
def register_servlets(http_server):
53-
VersionsRestServlet().register(http_server)
70+
def register_servlets(hs, http_server):
71+
VersionsRestServlet(hs).register(http_server)

0 commit comments

Comments
 (0)