This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit 'c9c544cda' into anoa/dinsic_release_1_21_x
* commit 'c9c544cda': Remove `ChainedIdGenerator`. (#8123) Switch the JSON byte producer from a pull to a push producer. (#8116) Updated docs: Added note about missing 308 redirect support. (#8120) Be stricter about JSON that is accepted by Synapse (#8106) Convert runWithConnection to async. (#8121) Remove the unused inlineCallbacks code-paths in the caching code (#8119) Separate `get_current_token` into two. (#8113) Convert events worker database to async/await. (#8071) Add a link to the matrix-synapse-rest-password-provider. (#8111)
- Loading branch information
Showing
60 changed files
with
409 additions
and
419 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Convert various parts of the codebase to async/await. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix a long-standing bug where invalid JSON would be accepted by Synapse. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Link to matrix-synapse-rest-password-provider in the password provider documentation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Separate `get_current_token` into two since there are two different use cases for it. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Iteratively encode JSON to avoid blocking the reactor. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Convert various parts of the codebase to async/await. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Updated documentation to note that Synapse does not follow `HTTP 308` redirects due to an upstream library not supporting them. Contributed by Ryan Cole. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Convert various parts of the codebase to async/await. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Remove `ChainedIdGenerator`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,9 +21,6 @@ | |
import urllib.parse | ||
from typing import Awaitable, Callable, Dict, List, Optional, Tuple | ||
|
||
from canonicaljson import json | ||
|
||
from twisted.internet import defer | ||
from twisted.internet.error import TimeoutError | ||
|
||
from synapse.api.errors import ( | ||
|
@@ -37,6 +34,7 @@ | |
from synapse.config.emailconfig import ThreepidBehaviour | ||
from synapse.http.client import SimpleHttpClient | ||
from synapse.types import JsonDict, Requester | ||
from synapse.util import json_decoder | ||
from synapse.util.hash import sha256_and_url_safe_base64 | ||
from synapse.util.stringutils import assert_valid_client_secret, random_string | ||
|
||
|
@@ -197,7 +195,7 @@ async def bind_threepid( | |
except TimeoutError: | ||
raise SynapseError(500, "Timed out contacting identity server") | ||
except CodeMessageException as e: | ||
data = json.loads(e.msg) # XXX WAT? | ||
data = json_decoder.decode(e.msg) # XXX WAT? | ||
return data | ||
|
||
logger.info("Got 404 when POSTing JSON %s, falling back to v1 URL", bind_url) | ||
|
@@ -620,18 +618,19 @@ async def proxy_msisdn_submit_token( | |
# the CS API. They should be consolidated with those in RoomMemberHandler | ||
# https://github.com/matrix-org/synapse-dinsic/issues/25 | ||
|
||
@defer.inlineCallbacks | ||
def proxy_lookup_3pid(self, id_server, medium, address): | ||
async def proxy_lookup_3pid( | ||
self, id_server: str, medium: str, address: str | ||
) -> JsonDict: | ||
"""Looks up a 3pid in the passed identity server. | ||
Args: | ||
id_server (str): The server name (including port, if required) | ||
id_server: The server name (including port, if required) | ||
of the identity server to use. | ||
medium (str): The type of the third party identifier (e.g. "email"). | ||
address (str): The third party identifier (e.g. "[email protected]"). | ||
medium: The type of the third party identifier (e.g. "email"). | ||
address: The third party identifier (e.g. "[email protected]"). | ||
Returns: | ||
Deferred[dict]: The result of the lookup. See | ||
The result of the lookup. See | ||
https://matrix.org/docs/spec/identity_service/r0.1.0.html#association-lookup | ||
for details | ||
""" | ||
|
@@ -643,16 +642,11 @@ def proxy_lookup_3pid(self, id_server, medium, address): | |
id_server_url = self.rewrite_id_server_url(id_server, add_https=True) | ||
|
||
try: | ||
data = yield self.http_client.get_json( | ||
data = await self.http_client.get_json( | ||
"%s/_matrix/identity/api/v1/lookup" % (id_server_url,), | ||
{"medium": medium, "address": address}, | ||
) | ||
|
||
if "mxid" in data: | ||
if "signatures" not in data: | ||
raise AuthError(401, "No signatures on 3pid binding") | ||
yield self._verify_any_signature(data, id_server) | ||
|
||
except HttpResponseException as e: | ||
logger.info("Proxied lookup failed: %r", e) | ||
raise e.to_synapse_error() | ||
|
@@ -662,18 +656,19 @@ def proxy_lookup_3pid(self, id_server, medium, address): | |
|
||
return data | ||
|
||
@defer.inlineCallbacks | ||
def proxy_bulk_lookup_3pid(self, id_server, threepids): | ||
async def proxy_bulk_lookup_3pid( | ||
self, id_server: str, threepids: List[List[str]] | ||
) -> JsonDict: | ||
"""Looks up given 3pids in the passed identity server. | ||
Args: | ||
id_server (str): The server name (including port, if required) | ||
id_server: The server name (including port, if required) | ||
of the identity server to use. | ||
threepids ([[str, str]]): The third party identifiers to lookup, as | ||
threepids: The third party identifiers to lookup, as | ||
a list of 2-string sized lists ([medium, address]). | ||
Returns: | ||
Deferred[dict]: The result of the lookup. See | ||
The result of the lookup. See | ||
https://matrix.org/docs/spec/identity_service/r0.1.0.html#association-lookup | ||
for details | ||
""" | ||
|
@@ -685,7 +680,7 @@ def proxy_bulk_lookup_3pid(self, id_server, threepids): | |
id_server_url = self.rewrite_id_server_url(id_server, add_https=True) | ||
|
||
try: | ||
data = yield self.http_client.post_json_get_json( | ||
data = await self.http_client.post_json_get_json( | ||
"%s/_matrix/identity/api/v1/bulk_lookup" % (id_server_url,), | ||
{"threepids": threepids}, | ||
) | ||
|
@@ -697,7 +692,7 @@ def proxy_bulk_lookup_3pid(self, id_server, threepids): | |
logger.info("Failed to contact %s: %s", id_server, e) | ||
raise ProxiedRequestError(503, "Failed to contact identity server") | ||
|
||
defer.returnValue(data) | ||
return data | ||
|
||
async def lookup_3pid( | ||
self, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.