mirror of
https://github.com/element-hq/lk-jwt-service.git
synced 2026-03-29 08:39:55 +00:00
Rename LK_JWT_PORT to LIVEKIT_JWT_PORT (#69)
This commit is contained in:
@@ -54,7 +54,7 @@ Variable | Description | Required
|
||||
`LIVEKIT_URL` | The websocket URL of the LiveKit SFU | Yes
|
||||
`LIVEKIT_KEY` | The API key for the LiveKit SFU | Yes
|
||||
`LIVEKIT_SECRET` | The secret for the LiveKit SFU | Yes
|
||||
`LK_JWT_PORT` | The port the service listens on | No - defaults to 8080
|
||||
`LIVEKIT_JWT_PORT` | The port the service listens on | No - defaults to 8080
|
||||
|
||||
## Disable TLS verification
|
||||
|
||||
|
||||
14
main.go
14
main.go
@@ -102,8 +102,8 @@ func (h *Handler) handle(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
return
|
||||
} else if r.Method == "POST" {
|
||||
var body SFURequest
|
||||
err := json.NewDecoder(r.Body).Decode(&body)
|
||||
var sfu_access_request SFURequest
|
||||
err := json.NewDecoder(r.Body).Decode(&sfu_access_request)
|
||||
if err != nil {
|
||||
log.Printf("Error decoding JSON: %v", err)
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
@@ -117,7 +117,7 @@ func (h *Handler) handle(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if body.Room == "" {
|
||||
if sfu_access_request.Room == "" {
|
||||
log.Printf("Request missing room")
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
err = json.NewEncoder(w).Encode(gomatrix.RespError{
|
||||
@@ -132,7 +132,7 @@ func (h *Handler) handle(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// TODO: we should be sanitising the input here before using it
|
||||
// e.g. only allowing `https://` URL scheme
|
||||
userInfo, err := exchangeOIDCToken(r.Context(), body.OpenIDToken, h.skipVerifyTLS)
|
||||
userInfo, err := exchangeOIDCToken(r.Context(), sfu_access_request.OpenIDToken, h.skipVerifyTLS)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
err = json.NewEncoder(w).Encode(gomatrix.RespError{
|
||||
@@ -148,7 +148,7 @@ func (h *Handler) handle(w http.ResponseWriter, r *http.Request) {
|
||||
log.Printf("Got user info for %s", userInfo.Sub)
|
||||
|
||||
// TODO: is DeviceID required? If so then we should have validated at the start of the request processing
|
||||
token, err := getJoinToken(h.key, h.secret, body.Room, userInfo.Sub+":"+body.DeviceID)
|
||||
token, err := getJoinToken(h.key, h.secret, sfu_access_request.Room, userInfo.Sub+":"+sfu_access_request.DeviceID)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
err = json.NewEncoder(w).Encode(gomatrix.RespError{
|
||||
@@ -201,12 +201,12 @@ func main() {
|
||||
log.Fatal("LIVEKIT_KEY, LIVEKIT_SECRET and LIVEKIT_URL environment variables must be set")
|
||||
}
|
||||
|
||||
lk_jwt_port := os.Getenv("LK_JWT_PORT")
|
||||
lk_jwt_port := os.Getenv("LIVEKIT_JWT_PORT")
|
||||
if lk_jwt_port == "" {
|
||||
lk_jwt_port = "8080"
|
||||
}
|
||||
|
||||
log.Printf("LIVEKIT_KEY: %s, LIVEKIT_SECRET: %s, LIVEKIT_URL: %s, LK_JWT_PORT: %s", key, secret, lk_url, lk_jwt_port)
|
||||
log.Printf("LIVEKIT_KEY: %s, LIVEKIT_SECRET: %s, LIVEKIT_URL: %s, LIVEKIT_JWT_PORT: %s", key, secret, lk_url, lk_jwt_port)
|
||||
|
||||
handler := &Handler{
|
||||
key: key,
|
||||
|
||||
Reference in New Issue
Block a user