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

/_matrix/client/(r0|v3|unstable)/refresh endpoint is not valid on workers #15426

Closed
dklimpel opened this issue Apr 12, 2023 · 1 comment · Fixed by #15428
Closed

/_matrix/client/(r0|v3|unstable)/refresh endpoint is not valid on workers #15426

dklimpel opened this issue Apr 12, 2023 · 1 comment · Fixed by #15428
Labels
A-Workers Problems related to running Synapse in Worker Mode (or replication) T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues.

Comments

@dklimpel
Copy link
Contributor

Description

I assumed that the endpoint /_matrix/client/(r0|v3|unstable)/refresh can be routed to workers.

Why?

login.register_servlets(hs, client_resource)

def register_servlets(hs: "HomeServer", http_server: HttpServer) -> None:
LoginRestServlet(hs).register(http_server)
if hs.config.registration.refreshable_access_token_lifetime is not None:
RefreshTokenServlet(hs).register(http_server)

But it cannot routed to workers.

add_refresh_token_to_user is part of RegistrationStore and not RegistrationWorkerStore.

Steps to reproduce

  • make a call to a generic worker with a valid refresh token

curl -X POST http://matrix.localhost/_matrix/client/v3/refresh -d '{"refresh_token": "syr_xxxx"}'

Homeserver

another homeserver

Synapse Version

1.78.0

Installation Method

Other (please mention below)

Database

PostgreSQL

Workers

Multiple workers

Platform

Kubernetes

Configuration

No response

Relevant log output

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/synapse/http/server.py", line 306, in _async_render_wrapper
    callback_return = await self._async_render(request)
  File "/usr/local/lib/python3.10/dist-packages/synapse/http/server.py", line 516, in _async_render
    callback_return = await raw_callback_return
  File "/usr/local/lib/python3.10/dist-packages/synapse/rest/client/login.py", line 569, in on_POST
    ) = await self._auth_handler.refresh_token(
  File "/usr/local/lib/python3.10/dist-packages/synapse/handlers/auth.py", line 853, in refresh_token
    ) = await self.create_refresh_token_for_user_id(
  File "/usr/local/lib/python3.10/dist-packages/synapse/handlers/auth.py", line 942, in create_refresh_token_for_user_id
    refresh_token_id = await self.store.add_refresh_token_to_user(
AttributeError: 'GenericWorkerSlavedStore' object has no attribute 'add_refresh_token_to_user'

Anything else that would be useful to know?

The documentation for workers is correct. The endpoint is not listed there.

I am not sure if add_refresh_token_to_user can be simply moved to RegistrationWorkerStore because there is an id generator

next_id = self._refresh_tokens_id_gen.get_next()
await self.db_pool.simple_insert(
"refresh_tokens",
{
"id": next_id,
"user_id": user_id,
"device_id": device_id,
"token": token,
"next_token_id": None,
"expiry_ts": expiry_ts,
"ultimate_session_expiry_ts": ultimate_session_expiry_ts,
},
desc="add_refresh_token_to_user",

@dklimpel dklimpel changed the title /_matrix/client/(r0|v3|unstable)/refresh endpoint is not valid on worker /_matrix/client/(r0|v3|unstable)/refresh endpoint is not valid on workers Apr 12, 2023
@reivilibre
Copy link
Contributor

Well spotted!

I am not sure if add_refresh_token_to_user can be simply moved to RegistrationWorkerStore because there is an id generator

I think that makes it tricky. For now, I suggest we disable it on workers until we can do the work needed to make it work on workers.

@reivilibre reivilibre added A-Workers Problems related to running Synapse in Worker Mode (or replication) T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues. labels Apr 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Workers Problems related to running Synapse in Worker Mode (or replication) T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants