29 Commits

Author SHA1 Message Date
fkwp
fa226031ac Update room alias handling in token generation for LegacySfuRequest (#147)
* Update room alias handling in token generation for LegacySfuRequest

* update test for room alias handling in token generation for LegacySfuRequest

* Update main.go

Co-authored-by: Timo <16718859+toger5@users.noreply.github.com>

* doc update

* rephrase doc

---------

Co-authored-by: Timo <16718859+toger5@users.noreply.github.com>
2026-01-14 13:29:18 +01:00
Robin
7576f52bdc Use base64 encoded hashes for room alias and participant ID (minimize identifying metadata sent to SFU) (#144)
* Encode room alias as unpadded base64

As recommended by the latest version of MSC4195.

* Set participant ID to SHA-256 of user ID, device ID, and member ID

To match the latest version of MSC4195.
2026-01-09 17:24:31 +01:00
fkwp
82c1bf4cce bug fix: add expires_in field to OpenIDTokenType (#130)
As we recently enforcing `DisallowUnknownFields()` while checking JSON input we need to add all required fields to `OpenIDTokenType` such as `expires_in`
2025-11-13 08:55:23 +01:00
fkwp
6573de0d93 Implementation of MSC4195: MatrixRTC Transport using LiveKit Backend (#128)
* Add writeMatrixError function to unify error handling

* Refactor POST request handling in preparation to allow different request types:
- split out into two functions
  - processSFURequest: main request handling
  - createLiveKitRoom: utility function which will be used by all different request types
- applying previously added writeMatrixError func

* rename SFURequest into LegacySFURequest

* add Matrix2 SFURequest type

* Add interface as well as implementation of it to SFURequest data types for data validation

* linting

* Add process function for Matrix2 SFURequest type

* refactor /sfu/get "POST" handling:
- cache body request for later processing
- add mapSFURequest function to map the request into LegacySFURequest or Matrix2 SFURequest. Including request field validation

* comment about request validation validation

* add test for MapSFURequest

* license header upddate

* add test to check json parsing and processing wrt. memory leaks

* convert exchangeOpenIdUserInfo and createLiveKitRoom into function variables for better testability

* reorder tests in main_test.go

* Add test for ProcessSFURequest

* Add test for ProcessLegacySFURequest

* according the the MSC the request endpoint is `/get_token`. For smooth transition:
- Allow for a transition period the old endpoint `/get/sfu`
- This old endpoint does auto map according to request type (LegacySFURequest, SFURequest)
- Define related function to 'legacy` and add TODO to remove them in future
- implement the new endpoint `/get_token`

* add type to errCode

* add logline in case of error while getJoinToken

* Check if validated userInfo.Sub matches req.Member.ClaimedUserID in processSFURequest and adapt test case.

* Update main.go

Co-authored-by: Will Hunt <2072976+Half-Shot@users.noreply.github.com>

* Use correct err code M_INVALID_PARAM -> M_BAD_JSON

* renamed TestHandlePost -> TestLegacyHandlePost and readded TestHandlePost

* review comments

---------

Co-authored-by: Will Hunt <2072976+Half-Shot@users.noreply.github.com>
2025-11-10 14:50:56 +01:00
fkwp
0861d7b1d6 Refactor config parsing (#125)
* README.md: add new default value column.

* refactor: split out config parsing in own function

* add tests for parseConfig

* more ideomatic order of functions in main.go

* fix(deps): update github.com/matrix-org/gomatrixserverlib digest to 6697d93 (#120)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update dependency go to v1.25.3 (#121)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix espace pipe character

* add logging to indicate where the LiveKit API key and secrets are loaded from.

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-10-27 12:15:51 +01:00
Matthieu Pignolet
8554a0a12c feat: allow binding of arbitrary addresses (#118)
* feat: allow binding of arbitrary addresses

This generally helps when the user wants to listen to [::1] or 127.0.0.0/8

Signed-off-by: Matthieu Pignolet <matthieu@puffer.fish>

* fix: update the documentation to reflect the environment variables changes

Signed-off-by: Matthieu Pignolet <matthieu@puffer.fish>

* feat: added `LIVEKIT_JWT_PORT` back for backwards-compatiblity (mutually exclusive with the `LIVEKIT_JWT_BIND` environment variable)

Signed-off-by: Matthieu Pignolet <matthieu@puffer.fish>

* feat: add a warning when using `LIVEKIT_JWT_PORT`

* feat: disallow using `LIVEKIT_JWT_BIND` and `LIVEKIT_JWT_PORT` together as they are mutually exclusive

---------

Signed-off-by: Matthieu Pignolet <matthieu@puffer.fish>
2025-10-27 10:18:57 +01:00
fkwp
114f0f4560 Restrict access to LiveKit SFU by differentiating full-access and restricted Matrix users for room creation (#67)
* add new ENV variable LIVEKIT_FULL_ACCESS_HOMESERVERS to allow different handling between full-access and restricted users

* full-access / restricted user detection

* Create LiveKit room on the SFU in case of a full-acceess user prior to issuing the JWT token

* Support full-access for all users via wildcard `*`for all homeservers

* make the wildcard '*' the default of LIVEKIT_FULL_ACCESS_HOMESERVERS to mimic the previous behaviour

* more idomatic variable nameing

* More ideomatic order for of functions in main.go
2025-07-29 10:34:19 +02:00
renovate[bot]
e6d8cfe671 Update golangci/golangci-lint-action action to v8 (#103)
* Update golangci/golangci-lint-action action to v8

* fix ST1005: error strings should not be capitalized

* fix : QF1003: could use tagged switch on r.Method

* fix: QF1012: Use fmt.Fprintf(...) instead of Write([]byte(fmt.Sprintf(...)))

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: fkwp <github-fkwp@w4ve.de>
2025-05-14 18:54:08 +02:00
fkwp
78801242ec Fkwp/add license header (#94)
* changed license header

* add commerical license file
2025-04-08 19:15:53 +02:00
Gaël Goinvic
eee9ca263d Add LIVEKIT_KEY_FILE, rename env vars to _FROM_FILE and trim keys&secrets (#93)
* Add LIVEKIT_KEY_SECRET_FILE and trim keys&secrets

* Rename env vars for consistency with livekit

* Add LIVEKIT_KEY_FILE variable in README

* comment readKeySecret logic

* reformat var names
2025-04-04 16:36:19 +02:00
Gaël Goinvic
e10a9fd256 Fix DNS resolution with host aliases + Fix TLS Verifiy on default transport (#92)
* Fix DNS resolution with host aliases

* Disable TLS on the default transport if required
2025-04-04 16:09:19 +02:00
Gaël Goinvic
738d55fafa Allow to read secrets and keys from files (#88)
* Allow to read secrets and keys from files

* add tests
2025-04-02 16:41:39 +02:00
fkwp
d24adff44a removed key and secret from startup logs (#78) 2025-03-17 23:03:48 +01:00
fkwp
0c0297247a Rename LK_JWT_PORT to LIVEKIT_JWT_PORT (#69) 2025-02-26 18:05:26 +00:00
Hugh Nimmo-Smith
09f0023b30 Log the Origin header for HTTP requests (#65) 2025-02-07 15:53:51 +00:00
Hugh Nimmo-Smith
4d9574bc62 A few simple test case to get us started and run them in CI (#52) 2025-01-20 18:39:11 +00:00
renovate[bot]
96cb277615 Update module github.com/livekit/server-sdk-go/v2 to v2.4.0 (#41)
* Update module github.com/livekit/server-sdk-go/v2 to v2.4.0

* use SetVideoGrant instead of deprecated AddGrant

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: fkwp <fkwp@users.noreply.github.com>
2024-12-04 09:20:20 +01:00
fkwp
4a295044a4 add option to skip TLS verification for outgoing matrix client connections (#18)
* add option to skip TLS verification for outgoing matrix client connections

* linting

* cleanup log line

Co-authored-by: Andrew Ferrazzutti <af_0_af@hotmail.com>

* simplify branch

Co-authored-by: Andrew Ferrazzutti <af_0_af@hotmail.com>

---------

Co-authored-by: Andrew Ferrazzutti <af_0_af@hotmail.com>
2024-04-27 21:30:16 +02:00
Andrew
94fa50e45f Make server port configurable through environment variable LK_JWT_PORT, default 8080 (#17)
* Make server port configurable through environment variable LK_JWT_PORT, default 8080

* Update readme to reflect usage of LK_JWT_PORT environment variable
2024-03-19 09:32:16 +01:00
Rhea Danzey
35d902c7a7 Add a simple health check endpoint to satisfy k8s needs (#11) 2023-08-29 13:14:17 -05:00
David Baker
6d9c34f821 Really fix the JWT service lookup (#10)
The option to enable lookups was fine, but I forgot to remove the manual
lookup - aargh.
2023-07-11 22:16:54 +01:00
David Baker
4c5632add4 Hack federation resolver so TLS check passes (#7)
As per comment. I don't yet know what the right way of doing this is.
2023-07-11 18:28:04 +01:00
David Baker
9fe823ce49 Revert "Enable SRV/.well-known lookups (#8)" (#9)
This reverts commit 36723e7b5f.
2023-07-11 18:27:56 +01:00
David Baker
36723e7b5f Enable SRV/.well-known lookups (#8) 2023-07-11 17:09:24 +01:00
David Baker
0beabc1f84 Do server name lookup (#6)
So we actually support server with names that aren't the same as
the server name.
2023-07-11 16:03:12 +02:00
David Baker
4d19078112 AGPL-3 license 2023-07-10 17:00:49 +01:00
David Baker
15d8ab891f Switch to using openid lookup (#1)
* Start of support for openid tokens

* Perform the actual openid token lookup

* Make livekit url configurable

* Check json encode calls for errors (picked up by linter)

* Remove unused field
2023-07-03 14:15:49 +02:00
Daniel Abramov
7effbd6a35 Fix a typo in an error 2023-06-09 17:40:46 +02:00
Daniel Abramov
10843a1e83 Initial commit 2023-06-07 16:04:44 +02:00