mirror of
https://github.com/livekit/livekit.git
synced 2026-10-31 05:12:46 +00:00
service: export CheckConnectLimits (#5067)
Servers that embed pkg/service and run their own join paths need the same join limit check. Rename checkConnectLimits to CheckConnectLimits. No behavior change. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e01a473d04
commit
c82f28d6cd
3 files changed
+6
-5
No files matched your search
@@ -297,7 +297,7 @@ func (r *RoomManager) StartSession(
|
||||
sessionStartTime := time.Now()
|
||||
|
||||
if pi.Identity != "" && pi.Grants != nil {
|
||||
if err := checkConnectLimits(r.config.Limit, string(pi.Identity), livekit.RoomName(pi.CreateRoom.GetName()), pi.Grants); err != nil {
|
||||
if err := CheckConnectLimits(r.config.Limit, string(pi.Identity), livekit.RoomName(pi.CreateRoom.GetName()), pi.Grants); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -419,7 +419,7 @@ func ValidateConnectRequest(
|
||||
}
|
||||
|
||||
// after the publish suffix, so the identity checked is the one StartSession sees
|
||||
if err := checkConnectLimits(limitConfig, claims.Identity, res.roomName, claims); err != nil {
|
||||
if err := CheckConnectLimits(limitConfig, claims.Identity, res.roomName, claims); err != nil {
|
||||
return res, http.StatusBadRequest, err
|
||||
}
|
||||
|
||||
@@ -454,10 +454,11 @@ func ValidateConnectRequest(
|
||||
return res, http.StatusOK, nil
|
||||
}
|
||||
|
||||
// checkConnectLimits checks a join's identity, room name, participant name, metadata and
|
||||
// CheckConnectLimits checks a join's identity, room name, participant name, metadata and
|
||||
// attributes against the configured limits. Every join path runs it: the signal connection,
|
||||
// WHIP, and StartSession on the RTC node, which does not trust the caller's validation.
|
||||
func checkConnectLimits(limitConfig config.LimitConfig, identity string, roomName livekit.RoomName, grants *auth.ClaimGrants) error {
|
||||
// It is exported for servers that embed this package and run their own join paths.
|
||||
func CheckConnectLimits(limitConfig config.LimitConfig, identity string, roomName livekit.RoomName, grants *auth.ClaimGrants) error {
|
||||
if !limitConfig.CheckParticipantIdentityLength(identity) {
|
||||
return fmt.Errorf("%w: max length %d", ErrParticipantIdentityExceedsLimits, limitConfig.MaxParticipantIdentityLength)
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ func (s *WHIPService) validateCreate(w http.ResponseWriter, r *http.Request) (*c
|
||||
return nil, http.StatusBadRequest, ErrIdentityEmpty
|
||||
}
|
||||
|
||||
if err := checkConnectLimits(s.config.Limit, claims.Identity, roomName, claims); err != nil {
|
||||
if err := CheckConnectLimits(s.config.Limit, claims.Identity, roomName, claims); err != nil {
|
||||
return nil, http.StatusBadRequest, err
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user