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

Commit

Permalink
Remove http_client from RoomMember, use blacklisting for IdentityHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
anoadragon453 committed Sep 26, 2019
1 parent 4898d65 commit 9c16e00
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
16 changes: 9 additions & 7 deletions synapse/handlers/identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ def proxy_msisdn_submit_token(self, id_server, client_secret, sid, token):
raise SynapseError(400, "Error contacting the identity server")

@defer.inlineCallbacks
def lookup_3pid(self, id_server, medium, address, id_access_token=None):
def _lookup_3pid(self, id_server, medium, address, id_access_token=None):
"""Looks up a 3pid in the passed identity server.
Args:
Expand Down Expand Up @@ -649,7 +649,7 @@ def _lookup_3pid_v2(self, id_server, id_access_token, medium, address):
"""
# Check what hashing details are supported by this identity server
try:
hash_details = yield self.http_client.get_json(
hash_details = yield self.blacklisting_http_client.get_json(
"%s%s/_matrix/identity/v2/hash_details" % (id_server_scheme, id_server),
{"access_token": id_access_token},
)
Expand Down Expand Up @@ -716,7 +716,7 @@ def _lookup_3pid_v2(self, id_server, id_access_token, medium, address):
headers = {"Authorization": create_id_access_token_header(id_access_token)}

try:
lookup_results = yield self.http_client.post_json_get_json(
lookup_results = yield self.blacklisting_http_client.post_json_get_json(
"%s%s/_matrix/identity/v2/lookup" % (id_server_scheme, id_server),
{
"addresses": [lookup_value],
Expand Down Expand Up @@ -750,7 +750,7 @@ def _verify_any_signature(self, data, server_hostname):
raise AuthError(401, "No signature from server %s" % (server_hostname,))
for key_name, signature in data["signatures"][server_hostname].items():
try:
key_data = yield self.http_client.get_json(
key_data = yield self.blacklisting_http_client.get_json(
"%s%s/_matrix/identity/api/v1/pubkey/%s"
% (id_server_scheme, server_hostname, key_name)
)
Expand Down Expand Up @@ -843,7 +843,7 @@ def ask_id_server_for_third_party_invite(
# Attempt a v2 lookup
url = base_url + "/v2/store-invite"
try:
data = yield self.http_client.post_json_get_json(
data = yield self.blacklisting_http_client.post_json_get_json(
url,
invite_config,
{"Authorization": create_id_access_token_header(id_access_token)},
Expand All @@ -863,7 +863,9 @@ def ask_id_server_for_third_party_invite(
url = base_url + "/api/v1/store-invite"

try:
data = yield self.http_client.post_json_get_json(url, invite_config)
data = yield self.blacklisting_http_client.post_json_get_json(
url, invite_config
)
except TimeoutError:
raise SynapseError(500, "Timed out contacting identity server")
except HttpResponseException as e:
Expand All @@ -879,7 +881,7 @@ def ask_id_server_for_third_party_invite(
# types. This is especially true with old instances of Sydent, see
# https://github.com/matrix-org/sydent/pull/170
try:
data = yield self.http_client.post_urlencoded_get_json(
data = yield self.blacklisting_http_client.post_urlencoded_get_json(
url, invite_config
)
except HttpResponseException as e:
Expand Down
6 changes: 0 additions & 6 deletions synapse/handlers/room_member.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from synapse import types
from synapse.api.constants import EventTypes, Membership
from synapse.api.errors import AuthError, Codes, SynapseError
from synapse.http.client import SimpleHttpClient
from synapse.types import RoomID, UserID
from synapse.util.async_helpers import Linearizer
from synapse.util.distributor import user_joined_room, user_left_room
Expand Down Expand Up @@ -54,11 +53,6 @@ def __init__(self, hs):
self.auth = hs.get_auth()
self.state_handler = hs.get_state_handler()
self.config = hs.config
# We create a blacklisting instance of SimpleHttpClient for contacting identity
# servers specified by clients
self.simple_http_client = SimpleHttpClient(
hs, ip_blacklist=hs.config.federation_ip_range_blacklist
)

self.federation_handler = hs.get_handlers().federation_handler
self.directory_handler = hs.get_handlers().directory_handler
Expand Down

0 comments on commit 9c16e00

Please sign in to comment.