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

Commit

Permalink
Add flag in /versions for whether clients should send id_server params (
Browse files Browse the repository at this point in the history
#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.
  • Loading branch information
anoadragon453 authored Aug 28, 2019
1 parent 7739f23 commit 8cd8124
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
1 change: 1 addition & 0 deletions changelog.d/5868.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add `m.require_identity_server` key to `/versions`'s `unstable_features` section.
2 changes: 1 addition & 1 deletion synapse/app/client_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})

Expand Down
2 changes: 1 addition & 1 deletion synapse/rest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
24 changes: 21 additions & 3 deletions synapse/rest/client/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -44,10 +48,24 @@ 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)

0 comments on commit 8cd8124

Please sign in to comment.