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

Commit

Permalink
Correctly use Sydent internal unbind API
Browse files Browse the repository at this point in the history
  • Loading branch information
MatMaul committed Oct 5, 2021
1 parent 9691665 commit 435431a
Showing 1 changed file with 28 additions and 18 deletions.
46 changes: 28 additions & 18 deletions synapse/handlers/identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,23 +285,6 @@ async def try_unbind_threepid_with_id_server(
True on success, otherwise False if the identity
server doesn't support unbinding
"""
content = {
"mxid": mxid,
"threepid": {"medium": threepid["medium"], "address": threepid["address"]},
}

# we abuse the federation http client to sign the request, but we have to send it
# using the normal http client since we don't want the SRV lookup and want normal
# 'browser-like' HTTPS.
url_bytes = "/_matrix/identity/api/v1/3pid/unbind".encode("ascii")
auth_headers = self.federation_http_client.build_auth_headers(
destination=None,
method=b"POST",
url_bytes=url_bytes,
content=content,
destination_is=id_server.encode("ascii"),
)
headers = {b"Authorization": auth_headers}

# if we have a rewrite rule set for the identity server,
# apply it now.
Expand All @@ -312,8 +295,35 @@ async def try_unbind_threepid_with_id_server(

if self.hs.config.bind_new_user_emails_to_sydent:
id_server_url = self.hs.config.bind_new_user_emails_to_sydent
url = "%s/_matrix/identity/internal/unbind" % (id_server_url,)
content = {
"mxid": mxid,
"medium": threepid["medium"],
"address": threepid["address"],
}
headers = {}
else:
url_path = "/_matrix/identity/api/v1/3pid/unbind"
url = id_server_url + url_path
content = {
"mxid": mxid,
"threepid": {
"medium": threepid["medium"],
"address": threepid["address"],
},
}

url = "%s/_matrix/identity/api/v1/3pid/unbind" % (id_server_url,)
# we abuse the federation http client to sign the request, but we have to send it
# using the normal http client since we don't want the SRV lookup and want normal
# 'browser-like' HTTPS.
auth_headers = self.federation_http_client.build_auth_headers(
destination=None,
method=b"POST",
url_bytes=url_path.encode("ascii"),
content=content,
destination_is=id_server.encode("ascii"),
)
headers = {b"Authorization": auth_headers}

try:
# Use the blacklisting http client as this call is only to identity servers
Expand Down

0 comments on commit 435431a

Please sign in to comment.