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

Commit 0c0b82b

Browse files
Allow Synapse to send registration emails + choose Synapse or an external server to handle 3pid validation (#5987)
This is a combination of a few different PRs, finally all being merged into `develop`: * #5875 * #5876 * #5868 (This one added the `/versions` flag but the flag itself was actually [backed out](891afb5#diff-e591d42d30690ffb79f63bb726200891) in #5969. What's left is just giving /versions access to the config file, which could be useful in the future) * #5835 * #5969 * #5940 Clients should not actually use the new registration functionality until #5972 is merged. UPGRADE.rst, changelog entries and config file changes should all be reviewed closely before this PR is merged.
1 parent f7c873a commit 0c0b82b

29 files changed

+820
-302
lines changed

UPGRADE.rst

+63
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,56 @@ returned by the Client-Server API:
4949
# configured on port 443.
5050
curl -kv https://<host.name>/_matrix/client/versions 2>&1 | grep "Server:"
5151
52+
Upgrading to v1.4.0
53+
===================
54+
55+
Config options
56+
--------------
57+
58+
**Note: Registration by email address or phone number will not work in this release unless
59+
some config options are changed from their defaults.**
60+
61+
This is due to Synapse v1.4.0 now defaulting to sending registration and password reset tokens
62+
itself. This is for security reasons as well as putting less reliance on identity servers.
63+
However, currently Synapse only supports sending emails, and does not have support for
64+
phone-based password reset or account registration. If Synapse is configured to handle these on
65+
its own, phone-based password resets and registration will be disabled. For Synapse to send
66+
emails, the ``email`` block of the config must be filled out. If not, then password resets and
67+
registration via email will be disabled entirely.
68+
69+
This release also deprecates the ``email.trust_identity_server_for_password_resets`` option and
70+
replaces it with the ``account_threepid_delegates`` dictionary. This option defines whether the
71+
homeserver should delegate an external server (typically an `identity server
72+
<https://matrix.org/docs/spec/identity_service/r0.2.1>`_) to handle sending password reset or
73+
registration messages via email and SMS.
74+
75+
If ``email.trust_identity_server_for_password_resets`` is set to ``true``, and
76+
``account_threepid_delegates.email`` is not set, then the first entry in
77+
``trusted_third_party_id_servers`` will be used as the account threepid delegate for email.
78+
This is to ensure compatibility with existing Synapse installs that set up external server
79+
handling for these tasks before v1.4.0. If ``email.trust_identity_server_for_password_resets``
80+
is ``true`` and no trusted identity server domains are configured, Synapse will throw an error.
81+
82+
If ``email.trust_identity_server_for_password_resets`` is ``false`` or absent and a threepid
83+
type in ``account_threepid_delegates`` is not set to a domain, then Synapse will attempt to
84+
send password reset and registration messages for that type.
85+
86+
Email templates
87+
---------------
88+
89+
If you have configured a custom template directory with the ``email.template_dir`` option, be
90+
aware that there are new templates regarding registration. ``registration.html`` and
91+
``registration.txt`` have been added and contain the content that is sent to a client upon
92+
registering via an email address.
93+
94+
``registration_success.html`` and ``registration_failure.html`` are also new HTML templates
95+
that will be shown to the user when they click the link in their registration emai , either
96+
showing them a success or failure page (assuming a redirect URL is not configured).
97+
98+
Synapse will expect these files to exist inside the configured template directory. To view the
99+
default templates, see `synapse/res/templates
100+
<https://github.com/matrix-org/synapse/tree/master/synapse/res/templates>`_.
101+
52102
Upgrading to v1.2.0
53103
===================
54104

@@ -132,6 +182,19 @@ server for password resets, set ``trust_identity_server_for_password_resets`` to
132182
See the `sample configuration file <docs/sample_config.yaml>`_
133183
for more details on these settings.
134184

185+
New email templates
186+
---------------
187+
Some new templates have been added to the default template directory for the purpose of the
188+
homeserver sending its own password reset emails. If you have configured a custom
189+
``template_dir`` in your Synapse config, these files will need to be added.
190+
191+
``password_reset.html`` and ``password_reset.txt`` are HTML and plain text templates
192+
respectively that contain the contents of what will be emailed to the user upon attempting to
193+
reset their password via email. ``password_reset_success.html`` and
194+
``password_reset_failure.html`` are HTML files that the content of which (assuming no redirect
195+
URL is set) will be shown to the user after they attempt to click the link in the email sent
196+
to them.
197+
135198
Upgrading to v0.99.0
136199
====================
137200

changelog.d/5835.feature

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add the ability to send registration emails from the homeserver rather than delegating to an identity server.

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.

changelog.d/5875.misc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Deprecate the `trusted_third_party_id_servers` option.

changelog.d/5876.feature

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Replace `trust_identity_server_for_password_resets` config option with `account_threepid_delegates`.

changelog.d/5940.feature

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add the ability to send registration emails from the homeserver rather than delegating to an identity server.

changelog.d/5969.feature

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Replace `trust_identity_server_for_password_resets` config option with `account_threepid_delegates`.

contrib/cmdclient/console.py

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737

3838
CONFIG_JSON = "cmdclient_config.json"
3939

40+
# TODO: The concept of trusted identity servers has been deprecated. This option and checks
41+
# should be removed
4042
TRUSTED_ID_SERVERS = ["localhost:8001"]
4143

4244

docs/sample_config.yaml

+43-13
Original file line numberDiff line numberDiff line change
@@ -891,10 +891,42 @@ uploads_path: "DATADIR/uploads"
891891
# Also defines the ID server which will be called when an account is
892892
# deactivated (one will be picked arbitrarily).
893893
#
894+
# Note: This option is deprecated. Since v0.99.4, Synapse has tracked which identity
895+
# server a 3PID has been bound to. For 3PIDs bound before then, Synapse runs a
896+
# background migration script, informing itself that the identity server all of its
897+
# 3PIDs have been bound to is likely one of the below.
898+
#
899+
# As of Synapse v1.4.0, all other functionality of this option has been deprecated, and
900+
# it is now solely used for the purposes of the background migration script, and can be
901+
# removed once it has run.
894902
#trusted_third_party_id_servers:
895903
# - matrix.org
896904
# - vector.im
897905

906+
# Handle threepid (email/phone etc) registration and password resets through a set of
907+
# *trusted* identity servers. Note that this allows the configured identity server to
908+
# reset passwords for accounts!
909+
#
910+
# Be aware that if `email` is not set, and SMTP options have not been
911+
# configured in the email config block, registration and user password resets via
912+
# email will be globally disabled.
913+
#
914+
# Additionally, if `msisdn` is not set, registration and password resets via msisdn
915+
# will be disabled regardless. This is due to Synapse currently not supporting any
916+
# method of sending SMS messages on its own.
917+
#
918+
# To enable using an identity server for operations regarding a particular third-party
919+
# identifier type, set the value to the URL of that identity server as shown in the
920+
# examples below.
921+
#
922+
# Servers handling the these requests must answer the `/requestToken` endpoints defined
923+
# by the Matrix Identity Service API specification:
924+
# https://matrix.org/docs/spec/identity_service/latest
925+
#
926+
account_threepid_delegates:
927+
#email: https://example.com # Delegate email sending to matrix.org
928+
#msisdn: http://localhost:8090 # Delegate SMS sending to this local process
929+
898930
# Users who register on this homeserver will automatically be joined
899931
# to these rooms
900932
#
@@ -1164,19 +1196,6 @@ password_config:
11641196
# #
11651197
# riot_base_url: "http://localhost/riot"
11661198
#
1167-
# # Enable sending password reset emails via the configured, trusted
1168-
# # identity servers
1169-
# #
1170-
# # IMPORTANT! This will give a malicious or overtaken identity server
1171-
# # the ability to reset passwords for your users! Make absolutely sure
1172-
# # that you want to do this! It is strongly recommended that password
1173-
# # reset emails be sent by the homeserver instead
1174-
# #
1175-
# # If this option is set to false and SMTP options have not been
1176-
# # configured, resetting user passwords via email will be disabled
1177-
# #
1178-
# #trust_identity_server_for_password_resets: false
1179-
#
11801199
# # Configure the time that a validation email or text message code
11811200
# # will expire after sending
11821201
# #
@@ -1208,11 +1227,22 @@ password_config:
12081227
# #password_reset_template_html: password_reset.html
12091228
# #password_reset_template_text: password_reset.txt
12101229
#
1230+
# # Templates for registration emails sent by the homeserver
1231+
# #
1232+
# #registration_template_html: registration.html
1233+
# #registration_template_text: registration.txt
1234+
#
12111235
# # Templates for password reset success and failure pages that a user
12121236
# # will see after attempting to reset their password
12131237
# #
12141238
# #password_reset_template_success_html: password_reset_success.html
12151239
# #password_reset_template_failure_html: password_reset_failure.html
1240+
#
1241+
# # Templates for registration success and failure pages that a user
1242+
# # will see after attempting to register using an email or phone
1243+
# #
1244+
# #registration_template_success_html: registration_success.html
1245+
# #registration_template_failure_html: registration_failure.html
12161246

12171247

12181248
#password_providers:

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

0 commit comments

Comments
 (0)