Get participant by authed identity in WHIP participant service. (#4861)
Addresses - https://github.com/livekit/livekit/security/advisories/GHSA-gfh2-98qv-ggmw
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
|||||||
"google.golang.org/protobuf/types/known/emptypb"
|
"google.golang.org/protobuf/types/known/emptypb"
|
||||||
|
|
||||||
"github.com/livekit/livekit-server/pkg/routing"
|
"github.com/livekit/livekit-server/pkg/routing"
|
||||||
|
"github.com/livekit/livekit-server/pkg/rtc"
|
||||||
"github.com/livekit/livekit-server/pkg/rtc/types"
|
"github.com/livekit/livekit-server/pkg/rtc/types"
|
||||||
"github.com/livekit/livekit-server/pkg/sfu/rtpstats"
|
"github.com/livekit/livekit-server/pkg/sfu/rtpstats"
|
||||||
"github.com/livekit/livekit-server/pkg/telemetry/prometheus"
|
"github.com/livekit/livekit-server/pkg/telemetry/prometheus"
|
||||||
@@ -281,13 +282,25 @@ type whipParticipantService struct {
|
|||||||
*RoomManager
|
*RoomManager
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getWHIPParticipant(
|
||||||
|
room *rtc.Room,
|
||||||
|
identity livekit.ParticipantIdentity,
|
||||||
|
participantID livekit.ParticipantID,
|
||||||
|
) types.LocalParticipant {
|
||||||
|
lp := room.GetParticipant(identity)
|
||||||
|
if lp == nil || lp.ID() != participantID {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return lp
|
||||||
|
}
|
||||||
|
|
||||||
func (r whipParticipantService) ICETrickle(ctx context.Context, req *rpc.WHIPParticipantICETrickleRequest) (*emptypb.Empty, error) {
|
func (r whipParticipantService) ICETrickle(ctx context.Context, req *rpc.WHIPParticipantICETrickleRequest) (*emptypb.Empty, error) {
|
||||||
room := r.RoomManager.GetRoom(ctx, livekit.RoomName(req.Room))
|
room := r.RoomManager.GetRoom(ctx, livekit.RoomName(req.Room))
|
||||||
if room == nil {
|
if room == nil {
|
||||||
return nil, ErrRoomNotFound
|
return nil, ErrRoomNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
lp := room.GetParticipantByID(livekit.ParticipantID(req.ParticipantId))
|
lp := getWHIPParticipant(room, livekit.ParticipantIdentity(req.GetParticipantIdentity()), livekit.ParticipantID(req.GetParticipantId()))
|
||||||
if lp == nil {
|
if lp == nil {
|
||||||
return nil, ErrParticipantNotFound
|
return nil, ErrParticipantNotFound
|
||||||
}
|
}
|
||||||
@@ -318,7 +331,7 @@ func (r whipParticipantService) ICERestart(ctx context.Context, req *rpc.WHIPPar
|
|||||||
return nil, ErrRoomNotFound
|
return nil, ErrRoomNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
lp := room.GetParticipantByID(livekit.ParticipantID(req.ParticipantId))
|
lp := getWHIPParticipant(room, livekit.ParticipantIdentity(req.GetParticipantIdentity()), livekit.ParticipantID(req.GetParticipantId()))
|
||||||
if lp == nil {
|
if lp == nil {
|
||||||
return nil, ErrParticipantNotFound
|
return nil, ErrParticipantNotFound
|
||||||
}
|
}
|
||||||
@@ -346,7 +359,7 @@ func (r whipParticipantService) DeleteSession(ctx context.Context, req *rpc.WHIP
|
|||||||
return nil, ErrRoomNotFound
|
return nil, ErrRoomNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
lp := room.GetParticipantByID(livekit.ParticipantID(req.ParticipantId))
|
lp := getWHIPParticipant(room, livekit.ParticipantIdentity(req.GetParticipantIdentity()), livekit.ParticipantID(req.GetParticipantId()))
|
||||||
if lp != nil {
|
if lp != nil {
|
||||||
room.RemoveParticipant(
|
room.RemoveParticipant(
|
||||||
lp.Identity(),
|
lp.Identity(),
|
||||||
|
|||||||
Reference in New Issue
Block a user