element-hq / element-hq/synapse
Enabling `session_lifetime` in the configuration prevents registration of guest users
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 600
- Avg merge
- 5d 22h
- Merged PRs (30d)
- 51
Description
This issue has been migrated from [#12440](https://github.com/matrix-org/synapse/issues/12440).
---
### 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](https://matrix.org/docs/projects/client/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](https://matrix.org/docs/projects/client/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':
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
- **Homeserver**: https://matrix.jacksonchen666.com
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](https://matrix-org.github.io/synapse/latest/reverse_proxy.html#nginx) & [delegation](https://matrix-org.github.io/synapse/latest/delegate.html))
- **Platform**: Linux, Fedora 35, Not within a container or VM
Contributor guide
Assessment
This issue has not been assessed yet.