Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accepting invites from federation fails #12

Closed
akoyaxd opened this issue Jul 4, 2022 · 5 comments · Fixed by #15
Closed

Accepting invites from federation fails #12

akoyaxd opened this issue Jul 4, 2022 · 5 comments · Fixed by #15
Assignees

Comments

@akoyaxd
Copy link

akoyaxd commented Jul 4, 2022

Describe the bug
If users on a synapse homeserver with this module get invited from a user via federation the invite is not automatically accepted.

To Reproduce
Steps to reproduce the behavior:

  1. Install synapse and this module
  2. Let an external Usere invite a user on your homeserver
  3. The invite is not automatically accepted.

Expected behaviour
The invite is automatically accepted.

Desktop (please complete the following information):
does not apply

Smartphone (please complete the following information):
does not apply

Additional context
The tested homeservers are synapse on version 1.61.1 in a dockerized environment. The module was installed in the container with pip. koyax.org is the federated homeserver and lippesola.de the one with the module installed. lippesola.de has federation whitelisting enabled with koyax.org beeing part of that list. koyax.org has unrestricted federation.

Logs

This is the log of the synaspe server with the module installed when a federated user invites a local user.

2022-07-04 11:51:09,750 - synapse.http.matrixfederationclient - 620 - INFO - PUT-167 - {GET-O-13} [koyax.org] Got response headers: 403 Forbidden
2022-07-04 11:51:09,751 - synapse.http.matrixfederationclient - 700 - WARNING - PUT-167 - {GET-O-13} [koyax.org] Request failed: GET matrix://koyax.org/_matrix/federation/v1/make_join/%21gmGAJbNDZtuUfEIJvo%3Akoyax.org/%40admin%3Alippesola.de?ver=1&ver=2&ver=3&ver=4&ver=5&ver=6&ver=org.matrix.msc2176&ver=7&ver=8&ver=9&ver=org.matrix.msc2716v3&ver=org.matrix.msc3787: HttpResponseException('403: Forbidden')
2022-07-04 11:51:09,752 - synapse.events.third_party_rules - 406 - ERROR - PUT-167 - Failed to run module API callback <bound method InviteAutoAccepter.on_new_event of <synapse_auto_accept_invite.InviteAutoAccepter object at 0x7fceb94152b0>>: 403: You are not invited to this room.
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/synapse/federation/federation_client.py", line 694, in _try_destination_list
    return await callback(destination)
  File "/usr/local/lib/python3.9/site-packages/synapse/federation/federation_client.py", line 791, in send_request
    ret = await self.transport_layer.make_membership_event(
  File "/usr/local/lib/python3.9/site-packages/synapse/federation/transport/client.py", line 322, in make_membership_event
    return await self.client.get_json(
  File "/usr/local/lib/python3.9/site-packages/synapse/http/matrixfederationclient.py", line 1066, in get_json
    response = await self._send_request_with_optional_trailing_slash(
  File "/usr/local/lib/python3.9/site-packages/synapse/http/matrixfederationclient.py", line 405, in _send_request_with_optional_trailing_slash
    response = await self._send_request(request, **send_request_args)
  File "/usr/local/lib/python3.9/site-packages/synapse/http/matrixfederationclient.py", line 659, in _send_request
    raise exc
synapse.api.errors.HttpResponseException: 403: Forbidden

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/synapse/events/third_party_rules.py", line 404, in on_new_event
    await callback(event, state_events)
  File "/usr/local/lib/python3.9/site-packages/synapse_auto_accept_invite/__init__.py", line 99, in on_new_event
    await self._api.update_room_membership(
  File "/usr/local/lib/python3.9/site-packages/synapse/module_api/__init__.py", line 999, in update_room_membership
    event_id, _ = await self._hs.get_room_member_handler().update_membership(
  File "/usr/local/lib/python3.9/site-packages/synapse/handlers/room_member.py", line 524, in update_membership
    result = await self.update_membership_locked(
  File "/usr/local/lib/python3.9/site-packages/synapse/handlers/room_member.py", line 860, in update_membership_locked
    remote_join_response = await self._remote_join(
  File "/usr/local/lib/python3.9/site-packages/synapse/handlers/room_member.py", line 1611, in _remote_join
    event_id, stream_id = await self.federation_handler.do_invite_join(
  File "/usr/local/lib/python3.9/site-packages/synapse/handlers/federation.py", line 487, in do_invite_join
    origin, event, room_version_obj = await self._make_and_verify_event(
  File "/usr/local/lib/python3.9/site-packages/synapse/handlers/federation.py", line 922, in _make_and_verify_event
    ) = await self.federation_client.make_membership_event(
  File "/usr/local/lib/python3.9/site-packages/synapse/federation/federation_client.py", line 842, in make_membership_event
    return await self._try_destination_list(
  File "/usr/local/lib/python3.9/site-packages/synapse/federation/federation_client.py", line 724, in _try_destination_list
    raise synapse_error from e
synapse.api.errors.ProxiedRequestError: 403: You are not invited to this room.
2022-07-04 11:51:09,756 - synapse.access.http.8008 - 450 - INFO - PUT-167 - 193.42.11.42 - 8008 - {koyax.org} Processed request: 0.646sec/0.001sec (0.019sec, 0.003sec) (0.015sec/0.122sec/12) 1485B 200 "PUT /_matrix/federation/v2/invite/%21gmGAJbNDZtuUfEIJvo%3Akoyax.org/%24GW-iHVMj0_tgK01fK0PeIOafb--4uYL9GwN_qHv9f6U HTTP/1.0" "Synapse/1.61.1" [0 dbevts]
@csuriano23
Copy link

Same here. It seems that the module doesn't support federation

@csuriano23
Copy link

Any clues on the cause of that or possible workarounds?

@bbissm
Copy link

bbissm commented Mar 14, 2023

I'm getting the same error here. Any updates on this?

@H-Shay
Copy link
Contributor

H-Shay commented May 1, 2023

Taking a look at this I think the issue is caused by a race condition where the make_join event emanating from the invited server is arriving before the invite event has been persisted in the inviting server and is thus not in the current state when the inviting server attempts to authenticate the make_join.

To figure this out I used the demo script to run two servers in a private federation, added the module to one of them and added a bunch of logging.

Here is a diagram of what I believe is happening:
image

@H-Shay
Copy link
Contributor

H-Shay commented May 23, 2023

This has been fixed in v1.1.3 -> you can get the new version on pypi or github. I should note that while the releases say that the minimum compatible Synapse version for 1.1.3 of the module is Synapse 1.84.0, it should work with older versions of Synapse (but will break some of the tests/dev tooling.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants