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

Commit 8a3175f

Browse files
Remove trusted_third_party_id_servers functionality (#5875)
Part of #5835 Removes the concept of a trusted identity server. The original concept of having the homeserver keep a list of trusted identity servers was to mitigate the danger of having a malicious IS handling password reset or registration emails. Since #5835 gives the homeserver the ability to do both of these things itself, as well as the requirement for it to choose an external, trusted identity server if it so chooses, the homeserver no longer needs to constrain which identity servers are chosen (which was traditionally a choice given to the client). Thus, we can safely the functionality of `trusted_third_party_id_servers`. It does need to stay in the config file for the foreseeable though, as it is currently used by a background job for old 3PIDs, which were bound before Synapse tracked which IS a 3PID was bound to. The identity servers in `trusted_third_party_id_servers` are likely candidates to be where a user registered their 3PID, so this is used during the background update. This background job was added in v0.99.4, so we're catering for those still updating from before v0.99.4.
1 parent d514dac commit 8a3175f

File tree

5 files changed

+20
-42
lines changed

5 files changed

+20
-42
lines changed

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.

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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,14 @@ uploads_path: "DATADIR/uploads"
890890
# Also defines the ID server which will be called when an account is
891891
# deactivated (one will be picked arbitrarily).
892892
#
893+
# Note: This option is deprecated. Since v0.99.4, Synapse has tracked which identity
894+
# server a 3PID has been bound to. For 3PIDs bound before then, Synapse runs a
895+
# background migration script, informing itself that the identity server all of its
896+
# 3PIDs have been bound to is likely one of the below.
897+
#
898+
# As of Synapse v1.4.0, all other functionality of this option has been deprecated, and
899+
# it is now solely used for the purposes of the background migration script, and can be
900+
# removed once it has run.
893901
#trusted_third_party_id_servers:
894902
# - matrix.org
895903
# - vector.im

synapse/config/registration.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,14 @@ def generate_config_section(self, generate_secrets=False, **kwargs):
257257
# Also defines the ID server which will be called when an account is
258258
# deactivated (one will be picked arbitrarily).
259259
#
260+
# Note: This option is deprecated. Since v0.99.4, Synapse has tracked which identity
261+
# server a 3PID has been bound to. For 3PIDs bound before then, Synapse runs a
262+
# background migration script, informing itself that the identity server all of its
263+
# 3PIDs have been bound to is likely one of the below.
264+
#
265+
# As of Synapse v1.4.0, all other functionality of this option has been deprecated, and
266+
# it is now solely used for the purposes of the background migration script, and can be
267+
# removed once it has run.
260268
#trusted_third_party_id_servers:
261269
# - matrix.org
262270
# - vector.im

synapse/handlers/identity.py

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,7 @@
2323

2424
from twisted.internet import defer
2525

26-
from synapse.api.errors import (
27-
CodeMessageException,
28-
Codes,
29-
HttpResponseException,
30-
SynapseError,
31-
)
26+
from synapse.api.errors import CodeMessageException, HttpResponseException, SynapseError
3227

3328
from ._base import BaseHandler
3429

@@ -42,25 +37,6 @@ def __init__(self, hs):
4237
self.http_client = hs.get_simple_http_client()
4338
self.federation_http_client = hs.get_http_client()
4439

45-
self.trusted_id_servers = set(hs.config.trusted_third_party_id_servers)
46-
self.trust_any_id_server_just_for_testing_do_not_use = (
47-
hs.config.use_insecure_ssl_client_just_for_testing_do_not_use
48-
)
49-
50-
def _should_trust_id_server(self, id_server):
51-
if id_server not in self.trusted_id_servers:
52-
if self.trust_any_id_server_just_for_testing_do_not_use:
53-
logger.warn(
54-
"Trusting untrustworthy ID server %r even though it isn't"
55-
" in the trusted id list for testing because"
56-
" 'use_insecure_ssl_client_just_for_testing_do_not_use'"
57-
" is set in the config",
58-
id_server,
59-
)
60-
else:
61-
return False
62-
return True
63-
6440
@defer.inlineCallbacks
6541
def threepid_from_creds(self, creds):
6642
if "id_server" in creds:
@@ -77,13 +53,6 @@ def threepid_from_creds(self, creds):
7753
else:
7854
raise SynapseError(400, "No client_secret in creds")
7955

80-
if not self._should_trust_id_server(id_server):
81-
logger.warn(
82-
"%s is not a trusted ID server: rejecting 3pid " + "credentials",
83-
id_server,
84-
)
85-
return None
86-
8756
try:
8857
data = yield self.http_client.get_json(
8958
"https://%s%s"
@@ -230,11 +199,6 @@ def try_unbind_threepid_with_id_server(self, mxid, threepid, id_server):
230199
def requestEmailToken(
231200
self, id_server, email, client_secret, send_attempt, next_link=None
232201
):
233-
if not self._should_trust_id_server(id_server):
234-
raise SynapseError(
235-
400, "Untrusted ID server '%s'" % id_server, Codes.SERVER_NOT_TRUSTED
236-
)
237-
238202
params = {
239203
"email": email,
240204
"client_secret": client_secret,
@@ -259,11 +223,6 @@ def requestEmailToken(
259223
def requestMsisdnToken(
260224
self, id_server, country, phone_number, client_secret, send_attempt, **kwargs
261225
):
262-
if not self._should_trust_id_server(id_server):
263-
raise SynapseError(
264-
400, "Untrusted ID server '%s'" % id_server, Codes.SERVER_NOT_TRUSTED
265-
)
266-
267226
params = {
268227
"country": country,
269228
"phone_number": phone_number,

0 commit comments

Comments
 (0)