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

Drop support for calling /_matrix/client/v3/rooms/{roomId}/invite without an id_access_token #13241

Merged
merged 33 commits into from
Aug 31, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
0f6487e
Drop v1 lookup
Vetchu Jul 11, 2022
ef1c794
Add changelog
Vetchu Jul 11, 2022
e9c789a
Address code review
Vetchu Jul 11, 2022
e354ec6
Repair tests PoC.
Vetchu Jul 11, 2022
eb5ba09
Update changelog.d/13241.removal
Vetchu Jul 12, 2022
72313f6
merge develop
Vetchu Jul 21, 2022
779e78c
Add tests, address concerns
Vetchu Jul 21, 2022
5668dcd
minify test
Vetchu Jul 22, 2022
6e908e4
missing comma
Vetchu Jul 25, 2022
242fa48
Merge branch 'develop' into misc/drop-v1-lookup
Vetchu Jul 25, 2022
6698279
Address comments
Vetchu Jul 25, 2022
48d88f0
Merge branch 'misc/drop-v1-lookup' of github.com:Vetchu/synapse into …
Vetchu Jul 25, 2022
6b1413b
Merge branch 'develop' into misc/drop-v1-lookup
Vetchu Jul 25, 2022
dacd33d
Merge branch 'matrix-org:develop' into misc/drop-v1-lookup
Vetchu Aug 11, 2022
9a04234
Update tests/rest/client/test_rooms.py
Vetchu Aug 15, 2022
e115f60
addressed the comments
Vetchu Aug 15, 2022
c535ea8
Merge branch 'develop' into misc/drop-v1-lookup
Vetchu Aug 15, 2022
f2a74b2
add missing check
Vetchu Aug 15, 2022
bb84fe4
Merge branch 'develop' into misc/drop-v1-lookup
Vetchu Aug 15, 2022
8ab4b35
Merge branch 'develop' into misc/drop-v1-lookup
Vetchu Aug 15, 2022
f9600bb
fixed test
Vetchu Aug 15, 2022
0073118
catch missing param for 3pid
Vetchu Aug 15, 2022
ebcdbba
synapseerror
Vetchu Aug 15, 2022
b97b27f
validate earlier
Vetchu Aug 15, 2022
23be3b9
merge develop
Vetchu Aug 23, 2022
d1b6ae8
Merge remote-tracking branch 'origin' into misc/drop-v1-lookup
Vetchu Aug 23, 2022
21d9be1
Next iteration
Vetchu Aug 23, 2022
caeee4d
allow exception to go up
Vetchu Aug 23, 2022
3792e8c
Merge branch 'develop' into misc/drop-v1-lookup
Vetchu Aug 24, 2022
3dfd8fb
beautify code
Vetchu Aug 25, 2022
5b237aa
hopefully addresses the comments
Vetchu Aug 26, 2022
27951c5
Update synapse/handlers/room.py
richvdh Aug 31, 2022
c6aa582
Merge branch 'develop' into misc/drop-v1-lookup
richvdh Aug 31, 2022
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
1 change: 1 addition & 0 deletions changelog.d/13241.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Drop v1 3PID lookup.
richvdh marked this conversation as resolved.
Show resolved Hide resolved
63 changes: 11 additions & 52 deletions synapse/handlers/identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,62 +629,21 @@ async def lookup_3pid(
Returns:
the matrix ID of the 3pid, or None if it is not recognized.
"""
if id_access_token is not None:
try:
results = await self._lookup_3pid_v2(
id_server, id_access_token, medium, address
)
return results

except Exception as e:
# Catch HttpResponseExcept for a non-200 response code
# Check if this identity server does not know about v2 lookups
if isinstance(e, HttpResponseException) and e.code == 404:
# This is an old identity server that does not yet support v2 lookups
logger.warning(
"Attempted v2 lookup on v1 identity server %s. Falling "
"back to v1",
id_server,
)
else:
logger.warning("Error when looking up hashing details: %s", e)
return None

return await self._lookup_3pid_v1(id_server, medium, address)

async def _lookup_3pid_v1(
self, id_server: str, medium: str, address: str
) -> Optional[str]:
"""Looks up a 3pid in the passed identity server using v1 lookup.

Args:
id_server: The server name (including port, if required)
of the identity server to use.
medium: The type of the third party identifier (e.g. "email").
address: The third party identifier (e.g. "foo@example.com").
if id_access_token is None:
raise SynapseError(
400, "id_access_token is required", errcode=Codes.MISSING_PARAM
)
richvdh marked this conversation as resolved.
Show resolved Hide resolved

Returns:
the matrix ID of the 3pid, or None if it is not recognized.
"""
try:
data = await self.blacklisting_http_client.get_json(
"%s%s/_matrix/identity/api/v1/lookup" % (id_server_scheme, id_server),
{"medium": medium, "address": address},
results = await self._lookup_3pid(
id_server, id_access_token, medium, address
)
return results
except Exception as e:
logger.warning("Error when looking up hashing details: %s", e)
return None

if "mxid" in data:
# note: we used to verify the identity server's signature here, but no longer
# require or validate it. See the following for context:
# https://github.com/matrix-org/synapse/issues/5253#issuecomment-666246950
return data["mxid"]
except RequestTimedOutError:
raise SynapseError(500, "Timed out contacting identity server")
except OSError as e:
logger.warning("Error from v1 identity server lookup: %s" % (e,))

return None

async def _lookup_3pid_v2(
async def _lookup_3pid(
richvdh marked this conversation as resolved.
Show resolved Hide resolved
self, id_server: str, id_access_token: str, medium: str, address: str
) -> Optional[str]:
"""Looks up a 3pid in the passed identity server using v2 lookup.
Expand Down