Allow specifying room configuration in token (#2853)
This commit is contained in:
@@ -172,6 +172,16 @@ func EnsureCreatePermission(ctx context.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetRoomConfiguration(ctx context.Context) string {
|
||||||
|
|
||||||
|
claims := GetGrants(ctx)
|
||||||
|
|
||||||
|
if claims == nil || claims.Video == nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return claims.Video.RoomConfiguration
|
||||||
|
}
|
||||||
|
|
||||||
func EnsureListPermission(ctx context.Context) error {
|
func EnsureListPermission(ctx context.Context) error {
|
||||||
claims := GetGrants(ctx)
|
claims := GetGrants(ctx)
|
||||||
if claims == nil || claims.Video == nil || !claims.Video.RoomList {
|
if claims == nil || claims.Video == nil || !claims.Video.RoomList {
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ func (r *StandardRoomAllocator) applyNamedRoomConfiguration(req *livekit.CreateR
|
|||||||
|
|
||||||
conf, ok := r.config.Room.RoomConfigurations[req.ConfigName]
|
conf, ok := r.config.Room.RoomConfigurations[req.ConfigName]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, psrpc.NewErrorf(psrpc.InvalidArgument, "unknown roomc confguration in create room request")
|
return req, psrpc.NewErrorf(psrpc.InvalidArgument, "unknown room confguration in create room request")
|
||||||
}
|
}
|
||||||
|
|
||||||
clone := proto.Clone(req).(*livekit.CreateRoomRequest)
|
clone := proto.Clone(req).(*livekit.CreateRoomRequest)
|
||||||
|
|||||||
@@ -515,7 +515,8 @@ func (s *RTCService) startConnection(
|
|||||||
var cr connectionResult
|
var cr connectionResult
|
||||||
var created bool
|
var created bool
|
||||||
var err error
|
var err error
|
||||||
cr.Room, created, err = s.roomAllocator.CreateRoom(ctx, &livekit.CreateRoomRequest{Name: string(roomName)})
|
|
||||||
|
cr.Room, created, err = s.roomAllocator.CreateRoom(ctx, &livekit.CreateRoomRequest{Name: string(roomName), ConfigName: GetRoomConfiguration(ctx)})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cr, nil, err
|
return cr, nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user