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

Commit

Permalink
Remove trusted_third_party_id_servers functionality (#5875)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
anoadragon453 authored Aug 19, 2019
1 parent d514dac commit 8a3175f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 42 deletions.
1 change: 1 addition & 0 deletions changelog.d/5875.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Deprecate the `trusted_third_party_id_servers` option.
2 changes: 2 additions & 0 deletions contrib/cmdclient/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@

CONFIG_JSON = "cmdclient_config.json"

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


Expand Down
8 changes: 8 additions & 0 deletions docs/sample_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,14 @@ uploads_path: "DATADIR/uploads"
# Also defines the ID server which will be called when an account is
# deactivated (one will be picked arbitrarily).
#
# Note: This option is deprecated. Since v0.99.4, Synapse has tracked which identity
# server a 3PID has been bound to. For 3PIDs bound before then, Synapse runs a
# background migration script, informing itself that the identity server all of its
# 3PIDs have been bound to is likely one of the below.
#
# As of Synapse v1.4.0, all other functionality of this option has been deprecated, and
# it is now solely used for the purposes of the background migration script, and can be
# removed once it has run.
#trusted_third_party_id_servers:
# - matrix.org
# - vector.im
Expand Down
8 changes: 8 additions & 0 deletions synapse/config/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,14 @@ def generate_config_section(self, generate_secrets=False, **kwargs):
# Also defines the ID server which will be called when an account is
# deactivated (one will be picked arbitrarily).
#
# Note: This option is deprecated. Since v0.99.4, Synapse has tracked which identity
# server a 3PID has been bound to. For 3PIDs bound before then, Synapse runs a
# background migration script, informing itself that the identity server all of its
# 3PIDs have been bound to is likely one of the below.
#
# As of Synapse v1.4.0, all other functionality of this option has been deprecated, and
# it is now solely used for the purposes of the background migration script, and can be
# removed once it has run.
#trusted_third_party_id_servers:
# - matrix.org
# - vector.im
Expand Down
43 changes: 1 addition & 42 deletions synapse/handlers/identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@

from twisted.internet import defer

from synapse.api.errors import (
CodeMessageException,
Codes,
HttpResponseException,
SynapseError,
)
from synapse.api.errors import CodeMessageException, HttpResponseException, SynapseError

from ._base import BaseHandler

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

self.trusted_id_servers = set(hs.config.trusted_third_party_id_servers)
self.trust_any_id_server_just_for_testing_do_not_use = (
hs.config.use_insecure_ssl_client_just_for_testing_do_not_use
)

def _should_trust_id_server(self, id_server):
if id_server not in self.trusted_id_servers:
if self.trust_any_id_server_just_for_testing_do_not_use:
logger.warn(
"Trusting untrustworthy ID server %r even though it isn't"
" in the trusted id list for testing because"
" 'use_insecure_ssl_client_just_for_testing_do_not_use'"
" is set in the config",
id_server,
)
else:
return False
return True

@defer.inlineCallbacks
def threepid_from_creds(self, creds):
if "id_server" in creds:
Expand All @@ -77,13 +53,6 @@ def threepid_from_creds(self, creds):
else:
raise SynapseError(400, "No client_secret in creds")

if not self._should_trust_id_server(id_server):
logger.warn(
"%s is not a trusted ID server: rejecting 3pid " + "credentials",
id_server,
)
return None

try:
data = yield self.http_client.get_json(
"https://%s%s"
Expand Down Expand Up @@ -230,11 +199,6 @@ def try_unbind_threepid_with_id_server(self, mxid, threepid, id_server):
def requestEmailToken(
self, id_server, email, client_secret, send_attempt, next_link=None
):
if not self._should_trust_id_server(id_server):
raise SynapseError(
400, "Untrusted ID server '%s'" % id_server, Codes.SERVER_NOT_TRUSTED
)

params = {
"email": email,
"client_secret": client_secret,
Expand All @@ -259,11 +223,6 @@ def requestEmailToken(
def requestMsisdnToken(
self, id_server, country, phone_number, client_secret, send_attempt, **kwargs
):
if not self._should_trust_id_server(id_server):
raise SynapseError(
400, "Untrusted ID server '%s'" % id_server, Codes.SERVER_NOT_TRUSTED
)

params = {
"country": country,
"phone_number": phone_number,
Expand Down

0 comments on commit 8a3175f

Please sign in to comment.