Allow participants to create new connection for publishing new tracks (#224)
* Allow participants to create new connection for publishing new tracks new param 'publish=<name>' enables publishing new connection with publish only grants. Also, identity is appended with '#<name>' * Add integration test to duplicate publish only connection Signed-off-by: shishir gowda <shishir@livekit.io> * Reuse token in test and set subscribeGrant to false on publish param Signed-off-by: shishir gowda <shishir@livekit.io> * create auth token with grants Signed-off-by: shishir gowda <shishir@livekit.io> * Signal ice on negotiate in test client Signed-off-by: shishir gowda <shishir@livekit.io> * Update pkg/service/rtcservice.go Co-authored-by: David Zhao <david@davidzhao.com> Co-authored-by: David Zhao <david@davidzhao.com>
This commit is contained in:
@@ -72,11 +72,23 @@ func (s *RTCService) validate(r *http.Request) (string, routing.ParticipantInit,
|
||||
roomName := r.FormValue("room")
|
||||
reconnectParam := r.FormValue("reconnect")
|
||||
autoSubParam := r.FormValue("auto_subscribe")
|
||||
publishParam := r.FormValue("publish")
|
||||
|
||||
if onlyName != "" {
|
||||
roomName = onlyName
|
||||
}
|
||||
|
||||
// this is new connection for existing participant - with publish only permissions
|
||||
if publishParam != "" {
|
||||
// Make sure grant has CanPublish set,
|
||||
if claims.Video.CanPublish != nil && *claims.Video.CanPublish == false {
|
||||
return "", routing.ParticipantInit{}, http.StatusUnauthorized, rtc.ErrPermissionDenied
|
||||
}
|
||||
// Make sure by default subscribe is off
|
||||
claims.Video.SetCanSubscribe(false)
|
||||
claims.Identity += "#" + publishParam
|
||||
}
|
||||
|
||||
if router, ok := s.router.(routing.Router); ok {
|
||||
if foundNode, err := router.GetNodeForRoom(r.Context(), roomName); err == nil {
|
||||
if selector.LimitsReached(s.limits, foundNode.Stats) {
|
||||
|
||||
Reference in New Issue
Block a user