This repository was 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
Consistently use room_id from federation request body #8776
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 bug in some federation APIs which could lead to unexpected behaviour if different parameters were set in the URI and the request body. |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -440,13 +440,13 @@ async def on_GET(self, origin, content, query, event_id): | |
|
|
||
|
|
||
| class FederationStateV1Servlet(BaseFederationServlet): | ||
| PATH = "/state/(?P<context>[^/]*)/?" | ||
| PATH = "/state/(?P<room_id>[^/]*)/?" | ||
|
|
||
| # This is when someone asks for all data for a given context. | ||
| async def on_GET(self, origin, content, query, context): | ||
| return await self.handler.on_context_state_request( | ||
| # This is when someone asks for all data for a given room. | ||
| async def on_GET(self, origin, content, query, room_id): | ||
| return await self.handler.on_room_state_request( | ||
| origin, | ||
| context, | ||
| room_id, | ||
| parse_string_from_args(query, "event_id", None, required=False), | ||
| ) | ||
|
|
||
|
|
@@ -463,16 +463,16 @@ async def on_GET(self, origin, content, query, room_id): | |
|
|
||
|
|
||
| class FederationBackfillServlet(BaseFederationServlet): | ||
| PATH = "/backfill/(?P<context>[^/]*)/?" | ||
| PATH = "/backfill/(?P<room_id>[^/]*)/?" | ||
|
|
||
| async def on_GET(self, origin, content, query, context): | ||
| async def on_GET(self, origin, content, query, room_id): | ||
| versions = [x.decode("ascii") for x in query[b"v"]] | ||
| limit = parse_integer_from_args(query, "limit", None) | ||
|
|
||
| if not limit: | ||
| return 400, {"error": "Did not include limit param"} | ||
|
|
||
| return await self.handler.on_backfill_request(origin, context, versions, limit) | ||
| return await self.handler.on_backfill_request(origin, room_id, versions, limit) | ||
|
|
||
|
|
||
| class FederationQueryServlet(BaseFederationServlet): | ||
|
|
@@ -487,9 +487,9 @@ async def on_GET(self, origin, content, query, query_type): | |
|
|
||
|
|
||
| class FederationMakeJoinServlet(BaseFederationServlet): | ||
| PATH = "/make_join/(?P<context>[^/]*)/(?P<user_id>[^/]*)" | ||
| PATH = "/make_join/(?P<room_id>[^/]*)/(?P<user_id>[^/]*)" | ||
|
|
||
| async def on_GET(self, origin, _content, query, context, user_id): | ||
| async def on_GET(self, origin, _content, query, room_id, user_id): | ||
| """ | ||
| Args: | ||
| origin (unicode): The authenticated server_name of the calling server | ||
|
|
@@ -511,24 +511,24 @@ async def on_GET(self, origin, _content, query, context, user_id): | |
| supported_versions = ["1"] | ||
|
|
||
| content = await self.handler.on_make_join_request( | ||
| origin, context, user_id, supported_versions=supported_versions | ||
| origin, room_id, user_id, supported_versions=supported_versions | ||
| ) | ||
| return 200, content | ||
|
|
||
|
|
||
| class FederationMakeLeaveServlet(BaseFederationServlet): | ||
| PATH = "/make_leave/(?P<context>[^/]*)/(?P<user_id>[^/]*)" | ||
| PATH = "/make_leave/(?P<room_id>[^/]*)/(?P<user_id>[^/]*)" | ||
|
|
||
| async def on_GET(self, origin, content, query, context, user_id): | ||
| content = await self.handler.on_make_leave_request(origin, context, user_id) | ||
| async def on_GET(self, origin, content, query, room_id, user_id): | ||
| content = await self.handler.on_make_leave_request(origin, room_id, user_id) | ||
| return 200, content | ||
|
|
||
|
|
||
| class FederationV1SendLeaveServlet(BaseFederationServlet): | ||
| PATH = "/send_leave/(?P<room_id>[^/]*)/(?P<event_id>[^/]*)" | ||
|
|
||
| async def on_PUT(self, origin, content, query, room_id, event_id): | ||
| content = await self.handler.on_send_leave_request(origin, content, room_id) | ||
| content = await self.handler.on_send_leave_request(origin, content) | ||
| return 200, (200, content) | ||
|
|
||
|
|
||
|
|
@@ -538,43 +538,43 @@ class FederationV2SendLeaveServlet(BaseFederationServlet): | |
| PREFIX = FEDERATION_V2_PREFIX | ||
|
|
||
| async def on_PUT(self, origin, content, query, room_id, event_id): | ||
| content = await self.handler.on_send_leave_request(origin, content, room_id) | ||
| content = await self.handler.on_send_leave_request(origin, content) | ||
| return 200, content | ||
|
|
||
|
|
||
| class FederationEventAuthServlet(BaseFederationServlet): | ||
| PATH = "/event_auth/(?P<context>[^/]*)/(?P<event_id>[^/]*)" | ||
| PATH = "/event_auth/(?P<room_id>[^/]*)/(?P<event_id>[^/]*)" | ||
|
|
||
| async def on_GET(self, origin, content, query, context, event_id): | ||
| return await self.handler.on_event_auth(origin, context, event_id) | ||
| async def on_GET(self, origin, content, query, room_id, event_id): | ||
| return await self.handler.on_event_auth(origin, room_id, event_id) | ||
|
|
||
|
|
||
| class FederationV1SendJoinServlet(BaseFederationServlet): | ||
| PATH = "/send_join/(?P<context>[^/]*)/(?P<event_id>[^/]*)" | ||
| PATH = "/send_join/(?P<room_id>[^/]*)/(?P<event_id>[^/]*)" | ||
|
|
||
| async def on_PUT(self, origin, content, query, context, event_id): | ||
| # TODO(paul): assert that context/event_id parsed from path actually | ||
| async def on_PUT(self, origin, content, query, room_id, event_id): | ||
| # TODO(paul): assert that room_id/event_id parsed from path actually | ||
| # match those given in content | ||
|
Comment on lines
+556
to
557
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like this comment is now obsolete since the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wellll, maybe. It depends what the answer to https://github.com/matrix-org/matrix-doc/issues/2330#issuecomment-728954062 is. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair enough. |
||
| content = await self.handler.on_send_join_request(origin, content, context) | ||
| content = await self.handler.on_send_join_request(origin, content) | ||
| return 200, (200, content) | ||
|
|
||
|
|
||
| class FederationV2SendJoinServlet(BaseFederationServlet): | ||
| PATH = "/send_join/(?P<context>[^/]*)/(?P<event_id>[^/]*)" | ||
| PATH = "/send_join/(?P<room_id>[^/]*)/(?P<event_id>[^/]*)" | ||
|
|
||
| PREFIX = FEDERATION_V2_PREFIX | ||
|
|
||
| async def on_PUT(self, origin, content, query, context, event_id): | ||
| # TODO(paul): assert that context/event_id parsed from path actually | ||
| async def on_PUT(self, origin, content, query, room_id, event_id): | ||
| # TODO(paul): assert that room_id/event_id parsed from path actually | ||
| # match those given in content | ||
| content = await self.handler.on_send_join_request(origin, content, context) | ||
| content = await self.handler.on_send_join_request(origin, content) | ||
| return 200, content | ||
|
|
||
|
|
||
| class FederationV1InviteServlet(BaseFederationServlet): | ||
| PATH = "/invite/(?P<context>[^/]*)/(?P<event_id>[^/]*)" | ||
| PATH = "/invite/(?P<room_id>[^/]*)/(?P<event_id>[^/]*)" | ||
|
|
||
| async def on_PUT(self, origin, content, query, context, event_id): | ||
| async def on_PUT(self, origin, content, query, room_id, event_id): | ||
| # We don't get a room version, so we have to assume its EITHER v1 or | ||
| # v2. This is "fine" as the only difference between V1 and V2 is the | ||
| # state resolution algorithm, and we don't use that for processing | ||
|
|
@@ -589,12 +589,12 @@ async def on_PUT(self, origin, content, query, context, event_id): | |
|
|
||
|
|
||
| class FederationV2InviteServlet(BaseFederationServlet): | ||
| PATH = "/invite/(?P<context>[^/]*)/(?P<event_id>[^/]*)" | ||
| PATH = "/invite/(?P<room_id>[^/]*)/(?P<event_id>[^/]*)" | ||
|
|
||
| PREFIX = FEDERATION_V2_PREFIX | ||
|
|
||
| async def on_PUT(self, origin, content, query, context, event_id): | ||
| # TODO(paul): assert that context/event_id parsed from path actually | ||
| async def on_PUT(self, origin, content, query, room_id, event_id): | ||
| # TODO(paul): assert that room_id/event_id parsed from path actually | ||
| # match those given in content | ||
|
|
||
| room_version = content["room_version"] | ||
|
|
@@ -616,9 +616,7 @@ class FederationThirdPartyInviteExchangeServlet(BaseFederationServlet): | |
| PATH = "/exchange_third_party_invite/(?P<room_id>[^/]*)" | ||
|
|
||
| async def on_PUT(self, origin, content, query, room_id): | ||
| content = await self.handler.on_exchange_third_party_invite_request( | ||
| room_id, content | ||
| ) | ||
| content = await self.handler.on_exchange_third_party_invite_request(content) | ||
| return 200, content | ||
|
|
||
|
|
||
|
|
||
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.