Serve the stable MatrixRTC LiveKit transport with Synapse

Synapse v1.165.0 deprecates the `livekit` MatrixRTC transport in favor of
the stable `m.livekit` one. Clients using the latter reach the LiveKit
authorization service through the homeserver, which needs the service
registered as an application service.

When Synapse is the homeserver, run LiveKit JWT Service as such:
register it with Synapse, enable MSC4502 and MSC4512 there, and advertise
`m.livekit` for the SFU the service issues tokens for. The `livekit`
transport stays advertised for clients which don't support `m.livekit`
yet. Other homeservers keep the legacy transport only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Slavi Pantaleev
2026-11-11 10:32:41 +02:00
co-authored by Claude Opus 5.5
parent 456e9bf419
commit ad31df64fb
2 changed files with 39 additions and 1 deletions
@@ -17,6 +17,22 @@ Take a look at:
- `roles/custom/matrix-livekit-jwt-service/defaults/main.yml` for some variables that you can customize via your `vars.yml` file
- `roles/custom/matrix-livekit-jwt-service/templates/env.j2` for the component's default configuration.
## Stable MatrixRTC transport (Synapse only)
When [Synapse](configuring-playbook-synapse.md) is your homeserver, the playbook also registers LiveKit JWT Service as a Synapse application service. This enables the stable MatrixRTC LiveKit transport (`m.livekit`): clients request call tokens through your homeserver, which forwards these requests to LiveKit JWT Service.
Synapse advertises both the stable transport and the deprecated `livekit` one, so older clients can keep talking to LiveKit JWT Service directly.
The application service covers all local users (non-exclusively). LiveKit JWT Service uses it to check that callers are joined to the room, and to manage delayed leave events on their behalf. Running as an application service also changes the existing endpoints: users who aren't joined to the room no longer get tokens, as long as `matrix_livekit_jwt_service_environment_variable_livekit_full_access_homeservers_list` only contains your own homeserver.
If you install services selectively (e.g. `just install-service synapse`), run a full installation (`just install-all` or `just setup-all`) the first time, so that both Synapse and LiveKit JWT Service pick up the registration.
To keep using only the deprecated transport, add the following configuration to your `inventory/host_vars/matrix.example.com/vars.yml` file:
```yaml
matrix_livekit_jwt_service_appservice_enabled: false
```
## Federated calls and trusted homeservers
Since LiveKit JWT Service 0.7.0, only users from homeservers listed in `matrix_livekit_jwt_service_environment_variable_livekit_full_access_homeservers_list` may publish audio, video, or screen shares on your SFU. The list defaults to your `matrix_domain`. Other federated users receive media here and publish on their own homeserver's SFU, using clients with multi-SFU support. See [upstream's explanation](https://github.com/element-hq/lk-jwt-service/issues/238#issuecomment-5709655222).
@@ -32,11 +48,14 @@ matrix_livekit_jwt_service_environment_variable_livekit_full_access_homeservers_
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.
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.
To temporarily retain the previous behavior while updating clients or arranging SFU access:
```yaml
matrix_livekit_jwt_service_version: 0.6.0
matrix_livekit_jwt_service_container_healthcheck_enabled: false
matrix_livekit_jwt_service_appservice_enabled: false
```
Remove both overrides when ready to upgrade. The healthcheck must remain disabled on 0.6.0 because it is broken in that image.
Remove these overrides when ready to upgrade. Version 0.6.0 cannot run as an application service, which disables the [stable transport](#stable-matrixrtc-transport-synapse-only). The healthcheck must remain disabled on 0.6.0 because it is broken in that image.
+19
View File
@@ -127,6 +127,8 @@ matrix_homeserver_container_extra_arguments_auto: |
+
(['--mount type=bind,src=' + matrix_appservice_double_puppet_config_path + '/registration.yaml,dst=/matrix-appservice-double-puppet-registration.yaml,ro'] if matrix_appservice_double_puppet_enabled else [])
+
(['--mount type=bind,src=' + matrix_livekit_jwt_service_appservice_registration_path + ',dst=/matrix-livekit-jwt-service-registration.yaml,ro'] if matrix_livekit_jwt_service_appservice_enabled else [])
+
(['--mount type=bind,src=' + matrix_bridge_appservice_irc_config_path + '/registration.yaml,dst=/matrix-appservice-irc-registration.yaml,ro'] if matrix_bridge_appservice_irc_enabled else [])
+
(['--mount type=bind,src=' + matrix_bridge_beeper_linkedin_config_path + '/registration.yaml,dst=/matrix-beeper-linkedin-registration.yaml,ro'] if matrix_bridge_beeper_linkedin_enabled else [])
@@ -192,6 +194,8 @@ matrix_homeserver_app_service_config_files_auto: |
+
(['/matrix-appservice-double-puppet-registration.yaml'] if matrix_appservice_double_puppet_enabled else [])
+
(['/matrix-livekit-jwt-service-registration.yaml'] if matrix_livekit_jwt_service_appservice_enabled else [])
+
(['/matrix-appservice-irc-registration.yaml'] if matrix_bridge_appservice_irc_enabled else [])
+
(['/matrix-beeper-linkedin-registration.yaml'] if matrix_bridge_beeper_linkedin_enabled else [])
@@ -263,6 +267,8 @@ matrix_homeserver_app_service_registration_changed: |
+
([matrix_appservice_double_puppet_registration_result | default({})] if matrix_appservice_double_puppet_enabled else [])
+
([matrix_livekit_jwt_service_appservice_registration_result | default({})] if matrix_livekit_jwt_service_appservice_enabled else [])
+
([matrix_bridge_appservice_irc_registration_result | default({})] if matrix_bridge_appservice_irc_enabled else [])
+
([matrix_bridge_beeper_linkedin_registration_result | default({})] if matrix_bridge_beeper_linkedin_enabled else [])
@@ -5301,6 +5307,12 @@ matrix_synapse_delayed_events_enabled: "{{ matrix_rtc_enabled }}"
matrix_synapse_matrix_rtc_transports_livekit_url: "{{ matrix_livekit_jwt_service_public_url if matrix_livekit_jwt_service_enabled else '' }}"
# The stable `m.livekit` transport needs the LiveKit JWT Service to run as an application service of Synapse.
# The advertised SFU URL must match the one the service issues tokens for, or it rejects token requests.
matrix_synapse_matrix_rtc_transports_livekit_sfu_url: "{{ matrix_livekit_jwt_service_environment_variable_livekit_url if matrix_livekit_jwt_service_appservice_enabled else '' }}"
matrix_synapse_experimental_features_msc4502_enabled: "{{ matrix_livekit_jwt_service_appservice_enabled }}"
matrix_synapse_experimental_features_msc4512_enabled: "{{ matrix_livekit_jwt_service_appservice_enabled }}"
matrix_synapse_experimental_features_msc4354_enabled: "{{ matrix_rtc_enabled }}"
# Disable password authentication when delegating authentication to Matrix Authentication Service.
@@ -6805,6 +6817,13 @@ matrix_livekit_jwt_service_environment_variable_livekit_key: "{{ (matrix_homeser
matrix_livekit_jwt_service_environment_variable_livekit_secret: "{{ (matrix_homeserver_generic_secret_key + ':lk.secret') | hash('sha512') | to_uuid }}"
# Running as an application service serves the stable MatrixRTC LiveKit transport (`m.livekit`).
# Only Synapse supports the homeserver side of this (MSC4502, MSC4512), so other homeservers keep using the legacy transport only.
matrix_livekit_jwt_service_appservice_enabled: "{{ matrix_livekit_jwt_service_enabled and matrix_homeserver_implementation == 'synapse' }}"
matrix_livekit_jwt_service_appservice_registration_as_token: "{{ (matrix_homeserver_generic_secret_key + ':lk.as.tok') | hash('sha512') | to_uuid }}"
matrix_livekit_jwt_service_appservice_registration_hs_token: "{{ (matrix_homeserver_generic_secret_key + ':lk.hs.tok') | hash('sha512') | to_uuid }}"
########################################################################
# #
# /matrix-livekit-jwt-service #