mirror of
https://github.com/livekit/livekit.git
synced 2026-12-04 20:28:09 +00:00
* feat: add token revocation * token revocation: match LiveKit Cloud API, make it optional - add token_revocation config section (enabled: false by default, ttl) - RemoveParticipant: cutoff defaults to now, revoke_token_ts must be within 60s and is stored with the validation leeway, revoke absent participants, keep not found unless revoke_token_ts is given - UpdateParticipant revokes older tokens on permission updates and the participant gets a refreshed token - share the RoomService logic with Cloud through RevokeTokenClient - revocations merge to the later cutoff and expiry Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * token revocation: clean up expired revocations lazily Drop the cleanup goroutine of LocalStore. Revocations are kept in a queue ordered by expiry, and expired ones are removed from its front when revoking or checking, at most once per minute. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * token revocation: request context for redis, own lock for LocalStore - RedisStore revocation calls use the request context - LocalStore revocations use their own lock instead of the store lock - remove TestRTCValidateRoomlessTokenAfterRevocation, which passes without revocation Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * token revocation: length checks before auth, test all auth chains Check lengths before the admin permission check, as LiveKit Cloud does, and test that the API, agent endpoint and WebTransport chains reject revoked tokens. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * token revocation: do not return store errors to clients Log the error of a failed revocation lookup and respond with a fixed message, as the store error may contain internal addresses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: cnderrauber <zengjie9004@gmail.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
54 lines
4.0 KiB
Go
54 lines
4.0 KiB
Go
// Copyright 2023 LiveKit, Inc.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
package service
|
|
|
|
import (
|
|
"github.com/livekit/psrpc"
|
|
)
|
|
|
|
var (
|
|
ErrEgressNotFound = psrpc.NewErrorf(psrpc.NotFound, "egress does not exist")
|
|
ErrEgressNotConnected = psrpc.NewErrorf(psrpc.Internal, "egress not connected (redis required)")
|
|
ErrIdentityEmpty = psrpc.NewErrorf(psrpc.InvalidArgument, "identity cannot be empty")
|
|
ErrParticipantSidEmpty = psrpc.NewErrorf(psrpc.InvalidArgument, "participant sid cannot be empty")
|
|
ErrIngressNotConnected = psrpc.NewErrorf(psrpc.Internal, "ingress not connected (redis required)")
|
|
ErrIngressNotFound = psrpc.NewErrorf(psrpc.NotFound, "ingress does not exist")
|
|
ErrIngressNonReusable = psrpc.NewErrorf(psrpc.InvalidArgument, "ingress is not reusable and cannot be modified")
|
|
ErrNameExceedsLimits = psrpc.NewErrorf(psrpc.InvalidArgument, "name length exceeds limits")
|
|
ErrMetadataExceedsLimits = psrpc.NewErrorf(psrpc.InvalidArgument, "metadata size exceeds limits")
|
|
ErrAttributeExceedsLimits = psrpc.NewErrorf(psrpc.InvalidArgument, "attribute size exceeds limits")
|
|
ErrNoRoomName = psrpc.NewErrorf(psrpc.InvalidArgument, "no room name")
|
|
ErrRoomNameExceedsLimits = psrpc.NewErrorf(psrpc.InvalidArgument, "room name length exceeds limits")
|
|
ErrParticipantIdentityExceedsLimits = psrpc.NewErrorf(psrpc.InvalidArgument, "participant identity length exceeds limits")
|
|
ErrDestinationSameAsSourceRoom = psrpc.NewErrorf(psrpc.InvalidArgument, "destination room cannot be the same as source room")
|
|
ErrOperationFailed = psrpc.NewErrorf(psrpc.Internal, "operation cannot be completed")
|
|
ErrParticipantNotFound = psrpc.NewErrorf(psrpc.NotFound, "participant does not exist")
|
|
ErrInvalidRevokeTokenTs = psrpc.NewErrorf(psrpc.InvalidArgument, "revoke_token_ts must be within 60 seconds of current time")
|
|
ErrRoomNotFound = psrpc.NewErrorf(psrpc.NotFound, "requested room does not exist")
|
|
ErrRoomLockFailed = psrpc.NewErrorf(psrpc.Internal, "could not lock room")
|
|
ErrRoomUnlockFailed = psrpc.NewErrorf(psrpc.Internal, "could not unlock room, lock token does not match")
|
|
ErrRemoteUnmuteNoteEnabled = psrpc.NewErrorf(psrpc.FailedPrecondition, "remote unmute not enabled")
|
|
ErrTrackNotFound = psrpc.NewErrorf(psrpc.NotFound, "track is not found")
|
|
ErrWebHookMissingAPIKey = psrpc.NewErrorf(psrpc.InvalidArgument, "api_key is required to use webhooks")
|
|
ErrSIPNotConnected = psrpc.NewErrorf(psrpc.Internal, "sip not connected (redis required)")
|
|
ErrSIPTrunkNotFound = psrpc.NewErrorf(psrpc.NotFound, "requested sip trunk does not exist")
|
|
ErrSIPDispatchRuleNotFound = psrpc.NewErrorf(psrpc.NotFound, "requested sip dispatch rule does not exist")
|
|
ErrSIPParticipantNotFound = psrpc.NewErrorf(psrpc.NotFound, "requested sip participant does not exist")
|
|
ErrInvalidMessageType = psrpc.NewErrorf(psrpc.Internal, "invalid message type")
|
|
ErrNoConnectRequest = psrpc.NewErrorf(psrpc.InvalidArgument, "no connect request")
|
|
ErrNoConnectResponse = psrpc.NewErrorf(psrpc.InvalidArgument, "no connect response")
|
|
ErrDestinationIdentityRequired = psrpc.NewErrorf(psrpc.InvalidArgument, "destination identity is required")
|
|
)
|