Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
This repository was 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

@dklimpel

Description

@dklimpel

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",

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-WorkersProblems related to running Synapse in Worker Mode (or replication)T-DefectBugs, crashes, hangs, security vulnerabilities, or other reported issues.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions