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

Add code to rewrite Tchap Sygnal URL #69

Open
wants to merge 2 commits into
base: dinsic
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
3 changes: 3 additions & 0 deletions synapse/push/httppusher.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ def __init__(self, hs: "HomeServer", pusher_config: PusherConfig):
"'url' must have a path of '/_matrix/push/v1/notify'"
)

if pusher_config.app_id.startswith("fr.gouv"):
url = url.replace("https://matrix.org", "http://sygnal.tchap.gouv.fr")

self.url = url
self.http_client = hs.get_proxied_blacklisted_http_client()
self.data_minus_url = {}
Expand Down