rtc: log the API key that issued the join token (#5050)

Thread the issuing API key from the /rtc join path to the media node via
StartSession, and include it in the "starting RTC session" log and the
twirp API-request log, so participant activity can be correlated with the
key. Logs the key id only, never the secret.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Raja SubramanianandClaude Opus 4.8 authored and GitHub committed 2026-10-23 23:35:15 +05:30
1 parent 704c3280fe
commit 9644b99247
7 files changed
+14 -4

No files matched your search

+2 -2
View File
@@ -21,7 +21,7 @@ require (
github.com/jxskiss/base62 v1.1.0
github.com/livekit/mageutil v0.0.0-20250511045019-0f1ff63f7731
github.com/livekit/mediatransportutil v0.0.0-20261014192331-dd8e31a0adc0
github.com/livekit/protocol v1.53.1-0.20261021070436-f09f87aab29b
github.com/livekit/protocol v1.53.1-0.20261023175527-46332a036e25
github.com/livekit/psrpc v0.8.2
github.com/mackerelio/go-osstat v0.2.8
github.com/magefile/mage v1.17.2
@@ -143,7 +143,7 @@ require (
github.com/pion/srtp/v3 v3.0.13 // indirect
github.com/pion/stun/v3 v3.1.7
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_model v0.6.3 // indirect
github.com/prometheus/client_model v0.6.3
github.com/prometheus/common v0.72.0 // indirect
github.com/prometheus/procfs v0.22.0 // indirect
github.com/urfave/cli/v3 v3.11.0
+2 -2
View File
@@ -166,8 +166,8 @@ github.com/livekit/mageutil v0.0.0-20250511045019-0f1ff63f7731 h1:9x+U2HGLrSw5AT
github.com/livekit/mageutil v0.0.0-20250511045019-0f1ff63f7731/go.mod h1:Rs3MhFwutWhGwmY1VQsygw28z5bWcnEYmS1OG9OxjOQ=
github.com/livekit/mediatransportutil v0.0.0-20261014192331-dd8e31a0adc0 h1:BSLyHr3Lsl71bHGHsfiYNmbohugR2yoaf9HjAZeFJnc=
github.com/livekit/mediatransportutil v0.0.0-20261014192331-dd8e31a0adc0/go.mod h1:o8CFmAdrVwzJNOCsQCLUzXRjokkufNshnQHOe4fRaqU=
github.com/livekit/protocol v1.53.1-0.20261021070436-f09f87aab29b h1:SrvXlVsWYxgdk6VRasJ9HCHFE+psFf17jQwriLBArgY=
github.com/livekit/protocol v1.53.1-0.20261021070436-f09f87aab29b/go.mod h1:kUTAI2TrTngGOiWP6MTAOkJpru6YYGd0MP9wzlDATy4=
github.com/livekit/protocol v1.53.1-0.20261023175527-46332a036e25 h1:v9UMGn8kGnrs0gja5795d8RBCQqKCVlXVeH14UDiuwc=
github.com/livekit/protocol v1.53.1-0.20261023175527-46332a036e25/go.mod h1:h9P4KCc3K715NCgCrkkFsb8/RRY1kKqOS1EIHUNRlCk=
github.com/livekit/psrpc v0.8.2 h1:7tbkhBJoYlK5Csfkdv1XYbZjyAQeaEZgupvIXNCv7Dc=
github.com/livekit/psrpc v0.8.2/go.mod h1:6KnU8vULoizX0Er9NNfeKJDV8ug87j3fuo19M0bhj6Q=
github.com/livekit/webrtc-pion/v4 v4.2.18-warp.7 h1:I1UkbeJI5V6slqLmef0JoaGF8wPnFsKzzXGUzz4KDvs=
+3
View File
@@ -193,6 +193,7 @@ type ParticipantInit struct {
AutoSubscribeDataTrack *bool
Client *livekit.ClientInfo
Grants *auth.ClaimGrants
APIKey string
TokenExpiresAt time.Time
Region string
AdaptiveStream bool
@@ -263,6 +264,7 @@ func (pi *ParticipantInit) ToStartSession(roomName livekit.RoomName, connectionI
AutoSubscribe: pi.AutoSubscribe,
Client: pi.Client,
GrantsJson: string(claims),
ApiKey: pi.APIKey,
TokenExpiresAt: tokenExpiresAt,
AdaptiveStream: pi.AdaptiveStream,
ParticipantId: string(pi.ID),
@@ -303,6 +305,7 @@ func ParticipantInitFromStartSession(ss *livekit.StartSession, region string) (*
Client: ss.Client,
AutoSubscribe: ss.AutoSubscribe,
Grants: claims,
APIKey: ss.ApiKey,
TokenExpiresAt: tokenExpiresAt,
Region: region,
AdaptiveStream: ss.AdaptiveStream,
+1
View File
@@ -439,6 +439,7 @@ func (r *RoomManager) StartSession(
"nodeID", r.currentNode.NodeID(),
"numParticipants", room.GetParticipantCount(),
"participantInit", &pi,
"apiKey", pi.APIKey,
)
clientConf := r.clientConfManager.GetConfiguration(pi.Client)
+1
View File
@@ -229,6 +229,7 @@ func (s *RTCService) validateInternal(
Identity: livekit.ParticipantIdentity(res.grants.Identity),
Name: livekit.ParticipantName(res.grants.Name),
Grants: res.grants,
APIKey: GetAPIKey(r.Context()),
TokenExpiresAt: res.tokenExpiresAt,
Region: res.region,
CreateRoom: res.createRoomRequest,
+4
View File
@@ -104,6 +104,10 @@ func loggerRequestReceived(ctx context.Context, twirpLoggerPool *sync.Pool) (con
r.fields = append(r.fields, "service", svc)
}
if apiKey := GetAPIKey(ctx); apiKey != "" {
r.fields = append(r.fields, "apiKey", apiKey)
}
return context.WithValue(ctx, twirpLoggerKey{}, r), nil
}
+1
View File
@@ -188,6 +188,7 @@ func (s *WHIPService) validateCreate(w http.ResponseWriter, r *http.Request) (*c
AutoSubscribe: true,
Client: ci,
Grants: claims,
APIKey: GetAPIKey(r.Context()),
CreateRoom: &livekit.CreateRoomRequest{
Name: string(roomName),
RoomPreset: claims.RoomPreset,