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

Commit 3c9aa14

Browse files
committed
Allow Synapse to send registration emails + choose Synapse or an external server to handle 3pid validation (#5987)
2 parents 6f0aa97 + 0c0b82b commit 3c9aa14

29 files changed

+820
-305
lines changed

UPGRADE.rst

Lines changed: 63 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Deprecate the `trusted_third_party_id_servers` option.

changelog.d/5876.feature

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,6 +1024,14 @@ uploads_path: "DATADIR/uploads"
10241024
# Also defines the ID server which will be called when an account is
10251025
# deactivated (one will be picked arbitrarily).
10261026
#
1027+
# Note: This option is deprecated. Since v0.99.4, Synapse has tracked which identity
1028+
# server a 3PID has been bound to. For 3PIDs bound before then, Synapse runs a
1029+
# background migration script, informing itself that the identity server all of its
1030+
# 3PIDs have been bound to is likely one of the below.
1031+
#
1032+
# As of Synapse v1.4.0, all other functionality of this option has been deprecated, and
1033+
# it is now solely used for the purposes of the background migration script, and can be
1034+
# removed once it has run.
10271035
#trusted_third_party_id_servers:
10281036
# - matrix.org
10291037
# - vector.im
@@ -1052,6 +1060,30 @@ uploads_path: "DATADIR/uploads"
10521060
#disable_set_displayname: False
10531061
#disable_set_avatar_url: False
10541062

1063+
# Handle threepid (email/phone etc) registration and password resets through a set of
1064+
# *trusted* identity servers. Note that this allows the configured identity server to
1065+
# reset passwords for accounts!
1066+
#
1067+
# Be aware that if `email` is not set, and SMTP options have not been
1068+
# configured in the email config block, registration and user password resets via
1069+
# email will be globally disabled.
1070+
#
1071+
# Additionally, if `msisdn` is not set, registration and password resets via msisdn
1072+
# will be disabled regardless. This is due to Synapse currently not supporting any
1073+
# method of sending SMS messages on its own.
1074+
#
1075+
# To enable using an identity server for operations regarding a particular third-party
1076+
# identifier type, set the value to the URL of that identity server as shown in the
1077+
# examples below.
1078+
#
1079+
# Servers handling the these requests must answer the `/requestToken` endpoints defined
1080+
# by the Matrix Identity Service API specification:
1081+
# https://matrix.org/docs/spec/identity_service/latest
1082+
#
1083+
account_threepid_delegates:
1084+
#email: https://example.com # Delegate email sending to matrix.org
1085+
#msisdn: http://localhost:8090 # Delegate SMS sending to this local process
1086+
10551087
# Users who register on this homeserver will automatically be joined
10561088
# to these rooms
10571089
#
@@ -1351,19 +1383,6 @@ password_config:
13511383
# #
13521384
# riot_base_url: "http://localhost/riot"
13531385
#
1354-
# # Enable sending password reset emails via the configured, trusted
1355-
# # identity servers
1356-
# #
1357-
# # IMPORTANT! This will give a malicious or overtaken identity server
1358-
# # the ability to reset passwords for your users! Make absolutely sure
1359-
# # that you want to do this! It is strongly recommended that password
1360-
# # reset emails be sent by the homeserver instead
1361-
# #
1362-
# # If this option is set to false and SMTP options have not been
1363-
# # configured, resetting user passwords via email will be disabled
1364-
# #
1365-
# #trust_identity_server_for_password_resets: false
1366-
#
13671386
# # Configure the time that a validation email or text message code
13681387
# # will expire after sending
13691388
# #
@@ -1395,11 +1414,22 @@ password_config:
13951414
# #password_reset_template_html: password_reset.html
13961415
# #password_reset_template_text: password_reset.txt
13971416
#
1417+
# # Templates for registration emails sent by the homeserver
1418+
# #
1419+
# #registration_template_html: registration.html
1420+
# #registration_template_text: registration.txt
1421+
#
13981422
# # Templates for password reset success and failure pages that a user
13991423
# # will see after attempting to reset their password
14001424
# #
14011425
# #password_reset_template_success_html: password_reset_success.html
14021426
# #password_reset_template_failure_html: password_reset_failure.html
1427+
#
1428+
# # Templates for registration success and failure pages that a user
1429+
# # will see after attempting to register using an email or phone
1430+
# #
1431+
# #registration_template_success_html: registration_success.html
1432+
# #registration_template_failure_html: registration_failure.html
14031433

14041434

14051435
#password_providers:

synapse/app/client_reader.py

Lines changed: 1 addition & 1 deletion
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)