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

Enabling session_lifetime in the configuration prevents registration of guest users #12440

Open
JacksonChen666 opened this issue Apr 11, 2022 · 2 comments
Labels
A-Config Configuration, or the documentation thereof A-Guests S-Minor Blocks non-critical functionality, workarounds exist. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues.

Comments

@JacksonChen666
Copy link

JacksonChen666 commented Apr 11, 2022

Description

When the configuration option session_lifetime (used to log out users after sign in after a certain amount of time) is used, attempts to register as a guest user will fail due to a 500 Internal Server Error because of a python exception.

Steps to reproduce

  • Enable configuration option session_lifetime to something like 30d
  • Host the Element client which points to the homeserver by default (set within config.json for Element)
  • Observe the 'Explore Rooms' button not showing under the Sign In and Create Account button, and the POST request Element makes to register a Guest account fail with a response code of 500 Internal Server Error

I was trying to get the Explore Room button to work in Element.
After lots of digging around to, well, not much useful. I then found that the POST request to /_matrix/client/r0/register?kind=guest responds with a 500 Internal Server Error status code, shows an exception in homeserver.log, and which prevented the button from showing up.

Expectation: Even with the session_lifetime option, guest users can be registered (what happens with session_lifetime really depends)

homeserver.log:

2022-04-11 20:57:46,503 - synapse.access.http.8008 - 427 - INFO - GET-71697 - ***.***.***.*** - 8008 - {None} Processed request: 0.001sec/0.001sec (0.001sec, 0.000sec) (0.000sec/0.000sec/0) 558B 200 "GET /_matrix/client/versions HTTP/1.0" "***********************************************************************************************************" [0 dbevts]
2022-04-11 20:57:46,786 - synapse.handlers.register - 358 - INFO - POST-71699 - Skipping auto-join for @113:jacksonchen666.com because auto-join for guests is disabled
2022-04-11 20:57:46,787 - synapse.http.server - 100 - ERROR - POST-71699 - Failed handle request via 'RegisterRestServlet': <XForwardedForRequest at 0x7f81c6432350 method='POST' uri='/_matrix/client/r0/register?kind=guest' clientproto='HTTP/1.0' site='8008'>
Traceback (most recent call last):
  File "/home/matrix-synapse/synapse/env/lib/python3.10/site-packages/synapse/http/server.py", line 268, in _async_render_wrapper
    callback_return = await self._async_render(request)
  File "/home/matrix-synapse/synapse/env/lib/python3.10/site-packages/synapse/http/server.py", line 470, in _async_render
    callback_return = await raw_callback_return
  File "/home/matrix-synapse/synapse/env/lib/python3.10/site-packages/synapse/rest/client/_base.py", line 99, in wrapped
    return await orig(*args, **kwargs)
  File "/home/matrix-synapse/synapse/env/lib/python3.10/site-packages/synapse/rest/client/register.py", line 451, in on_POST
    ret = await self._do_guest_registration(body, address=client_addr)
  File "/home/matrix-synapse/synapse/env/lib/python3.10/site-packages/synapse/rest/client/register.py", line 849, in _do_guest_registration
    ) = await self.registration_handler.register_device(
  File "/home/matrix-synapse/synapse/env/lib/python3.10/site-packages/synapse/handlers/register.py", line 768, in register_device
    res = await self._register_device_client(
  File "/home/matrix-synapse/synapse/env/lib/python3.10/site-packages/synapse/handlers/register.py", line 812, in register_device_inner
    raise Exception(
Exception: session_lifetime is not currently implemented for guest access
2022-04-11 20:57:46,790 - synapse.access.http.8008 - 427 - INFO - POST-71699 - ***.***.***.*** - 8008 - {None} Processed request: 0.023sec/0.001sec (0.007sec, 0.000sec) (0.001sec/0.016sec/2) 55B 500 "POST /_matrix/client/r0/register?kind=guest HTTP/1.0" "*************************************************************************************************" [0 dbevts]

Version information

If not matrix.org:

  • Version: 1.55.2 updated to 1.56.0 since then (tested, issue persists)

  • Install method: pip install matrix-synapse[postgres] (with the python virtual environment located at /home/matrix-synapse/synapse/env/, with a nginx reverse proxy & delegation)

  • Platform: Linux, Fedora 35, Not within a container or VM
@erikjohnston erikjohnston added S-Minor Blocks non-critical functionality, workarounds exist. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues. labels Apr 13, 2022
@erikjohnston
Copy link
Member

Thanks for this, I agree that this is not ideal and it would be good to fix it, but I'm afraid that the team likely won't get to this issue any time soon. We will happily accept PRs for it though.

FTR this is documented in the config for the session_lifetime option: https://github.com/matrix-org/synapse/blob/develop/docs/sample_config.yaml#L1244:L1244

@paboum
Copy link

paboum commented Dec 2, 2022

This also breaks element web's room_directory feature, as it calls /_matrix/client/r0/register?kind=guest too. Why does it even need a guest account, as it is mostly only used to browse rooms as view-only, is a mystery to me. Difficult to investigate as well - I properly set up config.json and still don't get the "explore rooms" button, because my server's setting had session_lifetime enabled, this shouldn't be my responsibility as the admin to know the dependency, simply make that server setting blocking the allow_guest_access one.

@MadLittleMods MadLittleMods changed the title Enabling session_lifetime in the configuration prevents registration of guest users Enabling session_lifetime in the configuration prevents registration of guest users Apr 25, 2023
@MadLittleMods MadLittleMods added the A-Config Configuration, or the documentation thereof label Apr 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Config Configuration, or the documentation thereof A-Guests S-Minor Blocks non-critical functionality, workarounds exist. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues.
Projects
None yet
Development

No branches or pull requests

4 participants