summary refs log tree commit diff
path: root/synapse/handlers/identity.py
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2016-01-29 14:12:26 +0000
committerMark Haines <mark.haines@matrix.org>2016-01-29 14:12:26 +0000
commit0fcafbece8258105fa4e81be4657ecc36359d258 (patch)
tree774931c05b22807215e18881b0973da1150c612e /synapse/handlers/identity.py
parentAllow three_pid_creds as well as threePidCreds in /account/3pid (diff)
downloadsynapse-0fcafbece8258105fa4e81be4657ecc36359d258.tar.xz
Add config option for setting the trusted id servers, disabling checking the ID server in integration tests
Diffstat (limited to '')
-rw-r--r--synapse/handlers/identity.py25
1 files changed, 17 insertions, 8 deletions
diff --git a/synapse/handlers/identity.py b/synapse/handlers/identity.py
index 819ec57c4f..77f133be8f 100644
--- a/synapse/handlers/identity.py
+++ b/synapse/handlers/identity.py
@@ -36,14 +36,15 @@ class IdentityHandler(BaseHandler):
 
         self.http_client = hs.get_simple_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
+        )
+
     @defer.inlineCallbacks
     def threepid_from_creds(self, creds):
         yield run_on_reactor()
 
-        # XXX: make this configurable!
-        # trustedIdServers = ['matrix.org', 'localhost:8090']
-        trustedIdServers = ['matrix.org', 'vector.im']
-
         if 'id_server' in creds:
             id_server = creds['id_server']
         elif 'idServer' in creds:
@@ -58,10 +59,18 @@ class IdentityHandler(BaseHandler):
         else:
             raise SynapseError(400, "No client_secret in creds")
 
-        if id_server not in trustedIdServers:
-            logger.warn('%s is not a trusted ID server: rejecting 3pid ' +
-                        'credentials', id_server)
-            defer.returnValue(None)
+        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"
+                )
+            else:
+                logger.warn('%s is not a trusted ID server: rejecting 3pid ' +
+                            'credentials', id_server)
+                defer.returnValue(None)
 
         data = {}
         try: