Check size limits on metadata and name set from client. (#2850)

* Send error response when update metadata fails.

Keeping it simple for the first implementation.
- Send error response only if request_id != 0
- Two kinds of errors notified
  o does not have permissions - NOT_ALLOWED
  o attributes exceeds size limits -  INVALID_ARGUMENT

* Check size limits on metadata and name set from client.

Added a name length limit also.

* check name length in service update participant path also

* limit check in limit config

* update protocol

* longer keys
This commit is contained in:
Raja Subramanian
2024-07-12 09:57:17 +05:30
committed by GitHub
parent ff66b545b4
commit 09e3aef859
15 changed files with 208 additions and 206 deletions
+24 -6
View File
@@ -94,19 +94,37 @@ func HandleParticipantSignal(room types.Room, participant types.LocalParticipant
case *livekit.SignalRequest_UpdateMetadata:
var errorResponse *livekit.ErrorResponse
if participant.ClaimGrants().Video.GetCanUpdateOwnMetadata() {
err := room.UpdateParticipantMetadata(
participant,
if err := participant.CheckMetadataLimits(
msg.UpdateMetadata.Name,
msg.UpdateMetadata.Metadata,
msg.UpdateMetadata.Attributes,
)
if err != nil {
); err == nil {
if msg.UpdateMetadata.Name != "" {
participant.SetName(msg.UpdateMetadata.Name)
}
if msg.UpdateMetadata.Metadata != "" {
participant.SetMetadata(msg.UpdateMetadata.Metadata)
}
if msg.UpdateMetadata.Attributes != nil {
participant.SetAttributes(msg.UpdateMetadata.Attributes)
}
} else {
pLogger.Warnw("could not update metadata", err)
switch err {
case ErrAttributeExceedsLimits:
case ErrNameExceedsLimits:
errorResponse = &livekit.ErrorResponse{
Reason: livekit.ErrorResponse_INVALID_ARGUMENT,
Reason: livekit.ErrorResponse_LIMIT_EXCEEDED,
Message: "exceeds name length limit",
}
case ErrMetadataExceedsLimits:
errorResponse = &livekit.ErrorResponse{
Reason: livekit.ErrorResponse_LIMIT_EXCEEDED,
Message: "exceeds metadata size limit",
}
case ErrAttributesExceedsLimits:
errorResponse = &livekit.ErrorResponse{
Reason: livekit.ErrorResponse_LIMIT_EXCEEDED,
Message: "exceeds attributes size limit",
}
}