auth

package
v1.30.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 25, 2024 License: Apache-2.0 Imports: 14 Imported by: 76

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrKeysMissing = errors.New("missing API key or secret key")
)

Functions

This section is empty.

Types

type APIKeyTokenVerifier

type APIKeyTokenVerifier struct {
	// contains filtered or unexported fields
}

func ParseAPIToken

func ParseAPIToken(raw string) (*APIKeyTokenVerifier, error)

ParseAPIToken parses an encoded JWT token and

func (*APIKeyTokenVerifier) APIKey

func (v *APIKeyTokenVerifier) APIKey() string

APIKey returns the API key this token was signed with

func (*APIKeyTokenVerifier) Identity

func (v *APIKeyTokenVerifier) Identity() string

func (*APIKeyTokenVerifier) Verify

func (v *APIKeyTokenVerifier) Verify(key interface{}) (*ClaimGrants, error)

type AccessToken

type AccessToken struct {
	// contains filtered or unexported fields
}

AccessToken produces token signed with API key and secret

func NewAccessToken

func NewAccessToken(key string, secret string) *AccessToken

func (*AccessToken) AddGrant deprecated

func (t *AccessToken) AddGrant(grant *VideoGrant) *AccessToken

Deprecated: use SetVideoGrant instead

func (*AccessToken) AddSIPGrant deprecated added in v1.19.0

func (t *AccessToken) AddSIPGrant(grant *SIPGrant) *AccessToken

Deprecated: use SetSIPGrant instead

func (*AccessToken) GetGrants added in v1.27.0

func (t *AccessToken) GetGrants() *ClaimGrants

func (*AccessToken) SetAgents added in v1.27.0

func (t *AccessToken) SetAgents(agents ...*livekit.RoomAgentDispatch) *AccessToken

SetAgents is a shortcut for setting agents in room configuration

func (*AccessToken) SetAttributes added in v1.18.0

func (t *AccessToken) SetAttributes(attrs map[string]string) *AccessToken

func (*AccessToken) SetIdentity

func (t *AccessToken) SetIdentity(identity string) *AccessToken

func (*AccessToken) SetKind added in v1.9.4

func (*AccessToken) SetMetadata

func (t *AccessToken) SetMetadata(md string) *AccessToken

func (*AccessToken) SetName added in v0.11.5

func (t *AccessToken) SetName(name string) *AccessToken

func (*AccessToken) SetRoomConfig added in v1.27.0

func (t *AccessToken) SetRoomConfig(config *livekit.RoomConfiguration) *AccessToken

func (*AccessToken) SetRoomPreset added in v1.27.0

func (t *AccessToken) SetRoomPreset(preset string) *AccessToken

func (*AccessToken) SetSIPGrant added in v1.27.0

func (t *AccessToken) SetSIPGrant(grant *SIPGrant) *AccessToken

func (*AccessToken) SetSha256 added in v0.7.2

func (t *AccessToken) SetSha256(sha string) *AccessToken

func (*AccessToken) SetValidFor

func (t *AccessToken) SetValidFor(duration time.Duration) *AccessToken

func (*AccessToken) SetVideoGrant added in v1.27.0

func (t *AccessToken) SetVideoGrant(grant *VideoGrant) *AccessToken

func (*AccessToken) ToJWT

func (t *AccessToken) ToJWT() (string, error)

type ClaimGrants

type ClaimGrants struct {
	Identity string      `json:"-"`
	Name     string      `json:"name,omitempty"`
	Kind     string      `json:"kind,omitempty"`
	Video    *VideoGrant `json:"video,omitempty"`
	SIP      *SIPGrant   `json:"sip,omitempty"`
	// Room configuration to use if this participant initiates the room
	RoomConfig *RoomConfiguration `json:"roomConfig,omitempty"`
	// Cloud-only, config preset to use
	// when both room and roomPreset are set, parameters in room overrides the preset
	RoomPreset string `json:"roomPreset,omitempty"`
	// for verifying integrity of the message body
	Sha256   string `json:"sha256,omitempty"`
	Metadata string `json:"metadata,omitempty"`
	// Key/value attributes to attach to the participant
	Attributes map[string]string `json:"attributes,omitempty"`
}

func (*ClaimGrants) Clone added in v0.13.3

func (c *ClaimGrants) Clone() *ClaimGrants

func (*ClaimGrants) GetParticipantKind added in v1.9.4

func (c *ClaimGrants) GetParticipantKind() livekit.ParticipantInfo_Kind

func (*ClaimGrants) GetRoomConfiguration added in v1.27.0

func (c *ClaimGrants) GetRoomConfiguration() *livekit.RoomConfiguration

func (*ClaimGrants) MarshalLogObject added in v1.30.0

func (c *ClaimGrants) MarshalLogObject(e zapcore.ObjectEncoder) error

func (*ClaimGrants) SetParticipantKind added in v1.9.4

func (c *ClaimGrants) SetParticipantKind(kind livekit.ParticipantInfo_Kind)

type FileBasedKeyProvider

type FileBasedKeyProvider struct {
	// contains filtered or unexported fields
}

func NewFileBasedKeyProviderFromMap

func NewFileBasedKeyProviderFromMap(keys map[string]string) *FileBasedKeyProvider

func NewFileBasedKeyProviderFromReader

func NewFileBasedKeyProviderFromReader(r io.Reader) (p *FileBasedKeyProvider, err error)

func (*FileBasedKeyProvider) GetSecret

func (p *FileBasedKeyProvider) GetSecret(key string) string

func (*FileBasedKeyProvider) NumKeys

func (p *FileBasedKeyProvider) NumKeys() int

type KeyProvider

type KeyProvider interface {
	GetSecret(key string) string
	NumKeys() int
}

type RoomConfiguration added in v1.27.0

type RoomConfiguration livekit.RoomConfiguration

func (*RoomConfiguration) Clone added in v1.27.0

func (*RoomConfiguration) MarshalJSON added in v1.27.0

func (c *RoomConfiguration) MarshalJSON() ([]byte, error)

func (*RoomConfiguration) UnmarshalJSON added in v1.27.0

func (c *RoomConfiguration) UnmarshalJSON(data []byte) error

type SIPGrant added in v1.19.0

type SIPGrant struct {
	// Admin grants access to all SIP features.
	Admin bool `json:"admin,omitempty"`

	// Call allows making outbound SIP calls.
	Call bool `json:"call,omitempty"`
}

func (*SIPGrant) Clone added in v1.19.0

func (s *SIPGrant) Clone() *SIPGrant

func (*SIPGrant) MarshalLogObject added in v1.30.0

func (s *SIPGrant) MarshalLogObject(e zapcore.ObjectEncoder) error

type SimpleKeyProvider added in v0.13.0

type SimpleKeyProvider struct {
	// contains filtered or unexported fields
}

func NewSimpleKeyProvider added in v0.13.0

func NewSimpleKeyProvider(apiKey, apiSecret string) *SimpleKeyProvider

func (*SimpleKeyProvider) GetSecret added in v0.13.0

func (p *SimpleKeyProvider) GetSecret(key string) string

func (*SimpleKeyProvider) NumKeys added in v0.13.0

func (p *SimpleKeyProvider) NumKeys() int

type TokenVerifier

type TokenVerifier interface {
	Identity() string
	Verify(key interface{}) (*ClaimGrants, error)
}

type VideoGrant

type VideoGrant struct {
	// actions on rooms
	RoomCreate bool `json:"roomCreate,omitempty"`
	RoomList   bool `json:"roomList,omitempty"`
	RoomRecord bool `json:"roomRecord,omitempty"`

	// actions on a particular room
	RoomAdmin bool   `json:"roomAdmin,omitempty"`
	RoomJoin  bool   `json:"roomJoin,omitempty"`
	Room      string `json:"room,omitempty"`

	// permissions within a room, if none of the permissions are set explicitly
	// it will be granted with all publish and subscribe permissions
	CanPublish     *bool `json:"canPublish,omitempty"`
	CanSubscribe   *bool `json:"canSubscribe,omitempty"`
	CanPublishData *bool `json:"canPublishData,omitempty"`
	// TrackSource types that a participant may publish.
	// When set, it supersedes CanPublish. Only sources explicitly set here can be published
	CanPublishSources []string `json:"canPublishSources,omitempty"` // keys keep track of each source
	// by default, a participant is not allowed to update its own metadata
	CanUpdateOwnMetadata *bool `json:"canUpdateOwnMetadata,omitempty"`

	// actions on ingresses
	IngressAdmin bool `json:"ingressAdmin,omitempty"` // applies to all ingress

	// participant is not visible to other participants
	Hidden bool `json:"hidden,omitempty"`
	// indicates to the room that current participant is a recorder
	Recorder bool `json:"recorder,omitempty"`
	// indicates that the holder can register as an Agent framework worker
	Agent bool `json:"agent,omitempty"`

	// if a participant can subscribe to metrics
	CanSubscribeMetrics *bool `json:"canSubscribeMetrics,omitempty"`
}

func (*VideoGrant) Clone added in v0.13.3

func (v *VideoGrant) Clone() *VideoGrant

func (*VideoGrant) GetCanPublish added in v0.12.0

func (v *VideoGrant) GetCanPublish() bool

func (*VideoGrant) GetCanPublishData added in v0.12.0

func (v *VideoGrant) GetCanPublishData() bool

func (*VideoGrant) GetCanPublishSource added in v1.4.0

func (v *VideoGrant) GetCanPublishSource(source livekit.TrackSource) bool

func (*VideoGrant) GetCanPublishSources added in v1.5.2

func (v *VideoGrant) GetCanPublishSources() []livekit.TrackSource

func (*VideoGrant) GetCanSubscribe added in v0.12.0

func (v *VideoGrant) GetCanSubscribe() bool

func (*VideoGrant) GetCanSubscribeMetrics added in v1.20.1

func (v *VideoGrant) GetCanSubscribeMetrics() bool

func (*VideoGrant) GetCanUpdateOwnMetadata added in v1.4.0

func (v *VideoGrant) GetCanUpdateOwnMetadata() bool

func (*VideoGrant) MarshalLogObject added in v1.30.0

func (v *VideoGrant) MarshalLogObject(e zapcore.ObjectEncoder) error

func (*VideoGrant) MatchesPermission added in v1.5.2

func (v *VideoGrant) MatchesPermission(permission *livekit.ParticipantPermission) bool

func (*VideoGrant) SetCanPublish added in v0.7.3

func (v *VideoGrant) SetCanPublish(val bool)

func (*VideoGrant) SetCanPublishData added in v0.7.3

func (v *VideoGrant) SetCanPublishData(val bool)

func (*VideoGrant) SetCanPublishSources added in v1.4.0

func (v *VideoGrant) SetCanPublishSources(sources []livekit.TrackSource)

func (*VideoGrant) SetCanSubscribe added in v0.7.3

func (v *VideoGrant) SetCanSubscribe(val bool)

func (*VideoGrant) SetCanSubscribeMetrics added in v1.20.1

func (v *VideoGrant) SetCanSubscribeMetrics(val bool)

func (*VideoGrant) SetCanUpdateOwnMetadata added in v1.4.0

func (v *VideoGrant) SetCanUpdateOwnMetadata(val bool)

func (*VideoGrant) ToPermission added in v0.12.0

func (v *VideoGrant) ToPermission() *livekit.ParticipantPermission

func (*VideoGrant) UpdateFromPermission added in v1.5.2

func (v *VideoGrant) UpdateFromPermission(permission *livekit.ParticipantPermission)

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL