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

Commit 435431a

Browse files
committed
Correctly use Sydent internal unbind API
1 parent 9691665 commit 435431a

File tree

1 file changed

+28
-18
lines changed

1 file changed

+28
-18
lines changed

synapse/handlers/identity.py

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -285,23 +285,6 @@ async def try_unbind_threepid_with_id_server(
285285
True on success, otherwise False if the identity
286286
server doesn't support unbinding
287287
"""
288-
content = {
289-
"mxid": mxid,
290-
"threepid": {"medium": threepid["medium"], "address": threepid["address"]},
291-
}
292-
293-
# we abuse the federation http client to sign the request, but we have to send it
294-
# using the normal http client since we don't want the SRV lookup and want normal
295-
# 'browser-like' HTTPS.
296-
url_bytes = "/_matrix/identity/api/v1/3pid/unbind".encode("ascii")
297-
auth_headers = self.federation_http_client.build_auth_headers(
298-
destination=None,
299-
method=b"POST",
300-
url_bytes=url_bytes,
301-
content=content,
302-
destination_is=id_server.encode("ascii"),
303-
)
304-
headers = {b"Authorization": auth_headers}
305288

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

313296
if self.hs.config.bind_new_user_emails_to_sydent:
314297
id_server_url = self.hs.config.bind_new_user_emails_to_sydent
298+
url = "%s/_matrix/identity/internal/unbind" % (id_server_url,)
299+
content = {
300+
"mxid": mxid,
301+
"medium": threepid["medium"],
302+
"address": threepid["address"],
303+
}
304+
headers = {}
305+
else:
306+
url_path = "/_matrix/identity/api/v1/3pid/unbind"
307+
url = id_server_url + url_path
308+
content = {
309+
"mxid": mxid,
310+
"threepid": {
311+
"medium": threepid["medium"],
312+
"address": threepid["address"],
313+
},
314+
}
315315

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

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

0 commit comments

Comments
 (0)