From 296e7ea9dc7070f5414dffa192ded3ab73fb5818 Mon Sep 17 00:00:00 2001 From: ArtiDezi Date: Thu, 12 Nov 2026 03:53:11 +0000 Subject: [PATCH] Migrate LiveKit guidance and API probes to supported federation paths --- ...onfiguring-playbook-livekit-jwt-service.md | 10 ++++--- .../defaults/main.yml | 7 ++--- .../molecule/default/files/openid-fixture.py | 18 ++++++++++--- .../molecule/default/molecule.yml | 10 +++---- .../molecule/default/verify.yml | 26 +++++++++---------- 5 files changed, 43 insertions(+), 28 deletions(-) diff --git a/docs/configuring-playbook-livekit-jwt-service.md b/docs/configuring-playbook-livekit-jwt-service.md index c04896809..446ec2d68 100644 --- a/docs/configuring-playbook-livekit-jwt-service.md +++ b/docs/configuring-playbook-livekit-jwt-service.md @@ -39,16 +39,18 @@ Since LiveKit JWT Service 0.7.0, only users from homeservers listed in `matrix_l Current Element Call supports this in its `compatibility` mode using the existing JWT endpoint. Older clients, clients configured to use a single SFU, and callers without their own SFU may join but be unable to publish media. -If you intentionally provide SFU access to another trusted homeserver, add its Matrix server name to your `inventory/host_vars/matrix.example.com/vars.yml` file: +With the [stable transport](#stable-matrixrtc-transport-synapse-only), requests arrive through your homeserver: your own users get full access. Remote users receive media here by default. To allow joined users from another trusted homeserver to publish on your SFU, add the following configuration to your `inventory/host_vars/matrix.example.com/vars.yml` file: ```yaml -matrix_livekit_jwt_service_environment_variable_livekit_full_access_homeservers_list_custom: +matrix_livekit_jwt_service_environment_variable_livekit_remote_can_publish_homeservers_list_custom: - example.org ``` -This lets all users of that homeserver publish and trigger room creation on your SFU, including outside your calls. Using `'*'` grants these permissions to every homeserver. +Use `'*'` to allow all joined remote users to publish. Room membership is checked for every relayed request, including subscribers. Any joined user can cause an SFU room to be created. The playbook keeps remote publishing opt-in; upstream otherwise enables it for everyone by default. -This list only applies to clients talking to LiveKit JWT Service directly (the deprecated `livekit` transport). With the [stable transport](#stable-matrixrtc-transport-synapse-only), requests arrive through your homeserver: your own users get full access, while users of other homeservers only receive media here by default. The playbook sets `LIVEKIT_REMOTE_CAN_PUBLISH_HOMESERVERS` to an empty list to preserve this policy; upstream 0.10.0 otherwise allows remote publishing by default. +Keep `matrix_livekit_jwt_service_environment_variable_livekit_full_access_homeservers_list` limited to your own homeserver. Fronting multiple homeservers through this legacy setting (including `'*'`) is deprecated upstream. If you previously added other homeservers there, migrate clients to the stable transport and move the trusted server names to the remote-can-publish list above, then remove the old list overrides. This enables room membership checks for legacy requests too. Remote homeservers need their own MatrixRTC integration to relay requests; changing the list alone does not migrate older clients. + +Standalone operation is also deprecated. Synapse installations use application-service mode by default. If you disabled it, remove that override when your clients are ready. Other homeserver implementations still need standalone mode until they support the application-service integration. Upstream has announced removal in a future version without a date or version number; plan that migration before upgrading to a release that removes it. See the [upstream deprecation notices](https://github.com/element-hq/lk-jwt-service/tree/v0.10.0#readme). To temporarily retain the previous behavior while updating clients or arranging SFU access: diff --git a/roles/custom/matrix-livekit-jwt-service/defaults/main.yml b/roles/custom/matrix-livekit-jwt-service/defaults/main.yml index 882fecc50..b942f2ce5 100644 --- a/roles/custom/matrix-livekit-jwt-service/defaults/main.yml +++ b/roles/custom/matrix-livekit-jwt-service/defaults/main.yml @@ -127,8 +127,8 @@ matrix_livekit_jwt_service_environment_variable_livekit_secret: "" # to media here; they publish on their own SFU using a client with multi-SFU support. # # This is a required setting and the service refuses to start without it. -# Setting it to `*` grants full access to any federated Matrix user, but listing only the homeserver(s) -# you intend to serve is strongly recommended. +# Only list the configured homeserver. Fronting several homeservers (including `*`) is deprecated. +# For federated publishing via the application service, use the remote-can-publish list below. # # To add additional homeservers, use `matrix_livekit_jwt_service_environment_variable_livekit_full_access_homeservers_list_custom`. matrix_livekit_jwt_service_environment_variable_livekit_full_access_homeservers: "{{ matrix_livekit_jwt_service_environment_variable_livekit_full_access_homeservers_list | join(',') }}" @@ -174,7 +174,8 @@ matrix_livekit_jwt_service_environment_variable_livekit_cs_api_url_overrides_map # # Enabling this only prepares this service and renders its registration file (`matrix_livekit_jwt_service_appservice_registration_path`). # The homeserver must also load that registration file and enable the MSC4502 and MSC4512 experimental features. -# A playbook may wire this up automatically. +# A playbook may wire this up automatically. Standalone operation is deprecated upstream; +# use application-service mode where the homeserver supports it. # # Note: `LIVEKIT_FULL_ACCESS_HOMESERVERS` does not apply to requests proxied by the homeserver. # When it only names the configured homeserver, the standalone endpoints also start checking that the requesting user is joined to the room. diff --git a/roles/custom/matrix-livekit-jwt-service/molecule/default/files/openid-fixture.py b/roles/custom/matrix-livekit-jwt-service/molecule/default/files/openid-fixture.py index b32f91556..15ea76ad4 100644 --- a/roles/custom/matrix-livekit-jwt-service/molecule/default/files/openid-fixture.py +++ b/roles/custom/matrix-livekit-jwt-service/molecule/default/files/openid-fixture.py @@ -25,7 +25,12 @@ IS_JOINED_REQUESTS = [] AS_TOKEN = os.environ["MOLECULE_AS_TOKEN"] IS_JOINED_PREFIX = "/_matrix/client/unstable/io.element.msc4502/rooms/" JOINED_MEMBERS = { - "!call-room:molecule.local": {"@carol:homeserver.molecule.local", "@alice:example.org"}, + "!call-room:molecule.local": { + "@carol:full-access.molecule.local:8443", + "@alice:example.org", + "@alice:matrix-openid-fixture:8443", + "@bob:full-access.molecule.local:8443", + }, } @@ -46,13 +51,20 @@ class OpenIDHandler(BaseHTTPRequestHandler): if parsed.path.startswith(IS_JOINED_PREFIX) and parsed.path.endswith("/is_joined"): room_id = unquote(parsed.path[len(IS_JOINED_PREFIX):-len("/is_joined")]) - mxid = parse_qs(parsed.query).get("mxid", [""])[0] + query = parse_qs(parsed.query) + mxid = query.get("mxid", [""])[0] + server_name = query.get("server_name", [""])[0] authorized = self.headers.get("Authorization", "") == "Bearer " + AS_TOKEN IS_JOINED_REQUESTS.append({"room_id": room_id, "mxid": mxid, "authorized": authorized}) if not authorized: self.send_json(401, {"errcode": "M_UNKNOWN_TOKEN"}) return - self.send_json(200, {"joined": mxid in JOINED_MEMBERS.get(room_id, set())}) + members = JOINED_MEMBERS.get(room_id, set()) + joined = ( + any(user.split(":", 1)[1] == server_name for user in members) + if server_name else mxid in members + ) + self.send_json(200, {"joined": joined}) return if parsed.path != "/_matrix/federation/v1/openid/userinfo": diff --git a/roles/custom/matrix-livekit-jwt-service/molecule/default/molecule.yml b/roles/custom/matrix-livekit-jwt-service/molecule/default/molecule.yml index 703e1d66b..fb2b75777 100644 --- a/roles/custom/matrix-livekit-jwt-service/molecule/default/molecule.yml +++ b/roles/custom/matrix-livekit-jwt-service/molecule/default/molecule.yml @@ -41,20 +41,20 @@ provisioner: matrix_livekit_jwt_service_environment_variable_livekit_url: ws://matrix-livekit-sfu-fixture:7880 # The OpenID fixture serves two origins: one restricted remote user and - # one trusted user who can publish and trigger room creation on the SFU. + # one local user who can publish and trigger room creation on the SFU. + # Keep only the configured homeserver in the full-access list, so even + # legacy clients use membership checks; multi-homeserver fronting is deprecated. matrix_livekit_jwt_service_environment_variable_livekit_full_access_homeservers_list_default: - full-access.molecule.local:8443 - matrix_livekit_jwt_service_environment_variable_livekit_full_access_homeservers_list_custom: - - second-full-access.molecule.local matrix_livekit_jwt_service_environment_variable_livekit_cs_api_url_overrides_map_custom: "matrix-openid-fixture:8443": https://client-api.override.molecule.invalid - "homeserver.molecule.local": https://matrix-openid-fixture:8443 + "full-access.molecule.local:8443": https://matrix-openid-fixture:8443 # Run as an application service. The OpenID fixture also plays the homeserver, # answering room membership lookups (MSC4502) for the server name above. matrix_livekit_jwt_service_appservice_enabled: true - matrix_livekit_jwt_service_appservice_homeserver_server_name: homeserver.molecule.local + matrix_livekit_jwt_service_appservice_homeserver_server_name: full-access.molecule.local:8443 matrix_livekit_jwt_service_appservice_registration_as_token: molecule-livekit-as-token-5d1e matrix_livekit_jwt_service_appservice_registration_hs_token: molecule-livekit-hs-token-8c7a diff --git a/roles/custom/matrix-livekit-jwt-service/molecule/default/verify.yml b/roles/custom/matrix-livekit-jwt-service/molecule/default/verify.yml index 83e1034ce..f476c3199 100644 --- a/roles/custom/matrix-livekit-jwt-service/molecule/default/verify.yml +++ b/roles/custom/matrix-livekit-jwt-service/molecule/default/verify.yml @@ -303,7 +303,7 @@ - matrix_livekit_jwt_service_registration.hs_token == 'molecule-livekit-hs-token-8c7a' - matrix_livekit_jwt_service_registration.sender_localpart == '_lk_jwt_service' - matrix_livekit_jwt_service_registration.namespaces.users | length == 1 - - matrix_livekit_jwt_service_registration.namespaces.users[0].regex == '@.*:homeserver\\.molecule\\.local$' + - matrix_livekit_jwt_service_registration.namespaces.users[0].regex == '@.*:full-access\\.molecule\\.local:8443$' - matrix_livekit_jwt_service_registration.namespaces.users[0].exclusive is sameas false - matrix_livekit_jwt_service_registration['io.element.msc4502.scopes'] == ['urn:matrix:client:io.element.msc4502:rooms:is_joined'] - matrix_livekit_jwt_service_registration['io.element.msc4512.proxy_prefix'] == 'rtc/livekit' @@ -365,13 +365,13 @@ - "{{ {'url': matrix_livekit_jwt_service_environment_variable_livekit_url, 'room_id': '!call-room:molecule.local', 'slot_id': 'molecule-cs-slot', 'member_id': 'member-molecule-cs'} | to_json }}" - --write-out - "\nHTTP_STATUS=%{http_code}" - - http://matrix-livekit-jwt-service:8097/_matrix/client/unstable/io.element.msc4195/rtc/livekit/get_token + - http://matrix-livekit-jwt-service:8097/_matrix/client/v1/rtc/livekit/get_token register: matrix_livekit_jwt_service_cs_tokens changed_when: false failed_when: false loop: - - {name: joined, user: '@carol:homeserver.molecule.local', status: '200'} - - {name: unjoined, user: '@dave:homeserver.molecule.local', status: '403'} + - {name: joined, user: '@carol:full-access.molecule.local:8443', status: '200'} + - {name: unjoined, user: '@dave:full-access.molecule.local:8443', status: '403'} loop_control: label: "{{ item.name }}" @@ -436,10 +436,10 @@ - name: Assert membership was looked up with the application service token ansible.builtin.assert: that: - - matrix_livekit_jwt_service_is_joined_requests | length == 2 + - matrix_livekit_jwt_service_is_joined_requests | length == 4 - matrix_livekit_jwt_service_is_joined_requests | map(attribute='authorized') | unique | list == [true] - matrix_livekit_jwt_service_is_joined_requests | map(attribute='room_id') | unique | list == ['!call-room:molecule.local'] - - matrix_livekit_jwt_service_is_joined_requests | map(attribute='mxid') | list == ['@carol:homeserver.molecule.local', '@dave:homeserver.molecule.local'] + - matrix_livekit_jwt_service_is_joined_requests | map(attribute='mxid') | list == ['@alice:matrix-openid-fixture:8443', '@bob:full-access.molecule.local:8443', '@carol:full-access.molecule.local:8443', '@dave:full-access.molecule.local:8443'] fail_msg: "The service did not look up membership at the configured homeserver with its application service token" success_msg: "The service looks up membership at the configured homeserver with its application service token" vars: @@ -465,7 +465,7 @@ - "{{ {'url': matrix_livekit_jwt_service_environment_variable_livekit_url, 'room_id': '!call-room:molecule.local', 'slot_id': 'molecule-ss-slot', 'member_id': 'member-molecule-ss', 'user_id': item.user} | to_json }}" - --write-out - "\nHTTP_STATUS=%{http_code}" - - http://matrix-livekit-jwt-service:8097/_matrix/federation/unstable/io.element.msc4195/rtc/livekit/get_token + - http://matrix-livekit-jwt-service:8097/_matrix/federation/v1/rtc/livekit/get_token register: matrix_livekit_jwt_service_ss_tokens changed_when: false failed_when: false @@ -543,12 +543,12 @@ - matrix_livekit_jwt_service_env_parsed.LIVEKIT_KEY == 'molecule-livekit-api-key' - matrix_livekit_jwt_service_env_parsed.LIVEKIT_SECRET == 'molecule-livekit-signing-secret-32-bytes-long' - matrix_livekit_jwt_service_env_parsed.LIVEKIT_URL == 'ws://matrix-livekit-sfu-fixture:7880' - - matrix_livekit_jwt_service_env_parsed.LIVEKIT_FULL_ACCESS_HOMESERVERS == 'full-access.molecule.local:8443,second-full-access.molecule.local' - - matrix_livekit_jwt_service_env_parsed.LIVEKIT_CS_API_URL_OVERRIDES.split(',') | sort == ['homeserver.molecule.local=https://matrix-openid-fixture:8443', 'matrix-openid-fixture:8443=https://client-api.override.molecule.invalid'] + - matrix_livekit_jwt_service_env_parsed.LIVEKIT_FULL_ACCESS_HOMESERVERS == 'full-access.molecule.local:8443' + - matrix_livekit_jwt_service_env_parsed.LIVEKIT_CS_API_URL_OVERRIDES.split(',') | sort == ['full-access.molecule.local:8443=https://matrix-openid-fixture:8443', 'matrix-openid-fixture:8443=https://client-api.override.molecule.invalid'] - matrix_livekit_jwt_service_env_parsed.LIVEKIT_AS_REGISTRATION_FILE == '/registration.yaml' - matrix_livekit_jwt_service_env_parsed.LIVEKIT_REMOTE_CAN_PUBLISH_HOMESERVERS == '' - matrix_livekit_jwt_service_env_parsed.LIVEKIT_CAN_UPDATE_OWN_METADATA == 'false' - - matrix_livekit_jwt_service_env_parsed.LIVEKIT_HS_SERVER_NAME == 'homeserver.molecule.local' + - matrix_livekit_jwt_service_env_parsed.LIVEKIT_HS_SERVER_NAME == 'full-access.molecule.local:8443' - matrix_livekit_jwt_service_env_parsed.LIVEKIT_INSECURE_SKIP_VERIFY_TLS == 'YES_I_KNOW_WHAT_I_AM_DOING' - matrix_livekit_jwt_service_env_parsed.LIVEKIT_LOG_LEVEL == 'debug' - matrix_livekit_jwt_service_env_parsed.MOLECULE_LIVEKIT_MARKER == 'environment-reached' @@ -603,10 +603,10 @@ ansible.builtin.assert: that: - "'LIVEKIT_JWT_BIND=:8097' in matrix_livekit_jwt_service_runtime.Config.Env" - - "'LIVEKIT_FULL_ACCESS_HOMESERVERS=full-access.molecule.local:8443,second-full-access.molecule.local' in matrix_livekit_jwt_service_runtime.Config.Env" - - (matrix_livekit_jwt_service_runtime.Config.Env | select('match', '^LIVEKIT_CS_API_URL_OVERRIDES=') | first).split('=', 1)[1].split(',') | sort == ['homeserver.molecule.local=https://matrix-openid-fixture:8443', 'matrix-openid-fixture:8443=https://client-api.override.molecule.invalid'] + - "'LIVEKIT_FULL_ACCESS_HOMESERVERS=full-access.molecule.local:8443' in matrix_livekit_jwt_service_runtime.Config.Env" + - (matrix_livekit_jwt_service_runtime.Config.Env | select('match', '^LIVEKIT_CS_API_URL_OVERRIDES=') | first).split('=', 1)[1].split(',') | sort == ['full-access.molecule.local:8443=https://matrix-openid-fixture:8443', 'matrix-openid-fixture:8443=https://client-api.override.molecule.invalid'] - "'LIVEKIT_AS_REGISTRATION_FILE=/registration.yaml' in matrix_livekit_jwt_service_runtime.Config.Env" - - "'LIVEKIT_HS_SERVER_NAME=homeserver.molecule.local' in matrix_livekit_jwt_service_runtime.Config.Env" + - "'LIVEKIT_HS_SERVER_NAME=full-access.molecule.local:8443' in matrix_livekit_jwt_service_runtime.Config.Env" - "'LIVEKIT_INSECURE_SKIP_VERIFY_TLS=YES_I_KNOW_WHAT_I_AM_DOING' in matrix_livekit_jwt_service_runtime.Config.Env" - "'MOLECULE_LIVEKIT_MARKER=environment-reached' in matrix_livekit_jwt_service_runtime.Config.Env" fail_msg: "The running container environment lost role-rendered settings"