jwt

package
v0.0.0-...-e041b52 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SignTokenWithHMAC

func SignTokenWithHMAC(headers, payload map[string]interface{}, secret string) (string, error)

Types

type AccessToken

type AccessToken struct {

	// List of permissions that the token grants
	Grants []BaseGrant `json:"grants,omitempty"`
	// Twilio Account SID
	AccountSid string `json:"account_sid,omitempty"`
	// API key
	SigningKeySid string `json:"signing_key_sid,omitempty"`
	// User's identity
	Identity string `json:"identity,omitempty"`
	// User's region
	Region interface{} `json:"region,omitempty"`
	// contains filtered or unexported fields
}

func CreateAccessToken

func CreateAccessToken(params AccessTokenParams) AccessToken

func (*AccessToken) AddGrant

func (token *AccessToken) AddGrant(grant BaseGrant)

func (*AccessToken) FromJwt

func (token *AccessToken) FromJwt(jwtStr string, key string) (*AccessToken, error)

Decode a JWT string into a Jwt struct. jwt - JWT string key - string key used to verify the JWT signature; if not provided, then validation is skipped

func (*AccessToken) GeneratePayload

func (token *AccessToken) GeneratePayload() map[string]interface{}

func (*AccessToken) Headers

func (token *AccessToken) Headers() map[string]interface{}

func (*AccessToken) Payload

func (token *AccessToken) Payload() map[string]interface{}

func (*AccessToken) ToJwt

func (token *AccessToken) ToJwt() (string, error)

Encode this JWT struct into a string. algorithm - algorithm used to encode the JWT that overrides the default ttl - specify ttl to override the default

type AccessTokenParams

type AccessTokenParams struct {
	// Twilio Account sid
	AccountSid string
	// The issuer of the token
	SigningKeySid string
	// The secret used to sign the token
	Secret string
	// Identity of the token issuer
	Identity string
	// User's Region
	Region string
	// Time in secs since epoch before which this JWT is invalid, defaults to now
	Nbf float64
	// Time to live of the JWT in seconds, defaults to 1 hour
	Ttl float64
	// Time in secs since epoch this JWT is valid for. Overrides ttl if provided.
	ValidUntil float64
	// Access permissions granted to this token
	Grants []BaseGrant
}

type BaseGrant

type BaseGrant interface {
	Key() string
	ToPayload() map[string]interface{}
	ToString() string
}

type ChatGrant

type ChatGrant struct {
	ServiceSid        string `json:"service_sid"`
	EndpointID        string `json:"endpoint_id"`
	DeploymentRoleSid string `json:"deployment_role_sid"`
	PushCredentialSid string `json:"push_credential_sid"`
}

func (*ChatGrant) Key

func (chatGrant *ChatGrant) Key() string

func (*ChatGrant) ToPayload

func (chatGrant *ChatGrant) ToPayload() map[string]interface{}

func (*ChatGrant) ToString

func (chatGrant *ChatGrant) ToString() string

type ConversationsGrant

type ConversationsGrant struct {
	ConfigurationProfileSid string `json:"configuration_profile_sid"`
}

func (*ConversationsGrant) Key

func (conversationsGrant *ConversationsGrant) Key() string

func (*ConversationsGrant) ToPayload

func (conversationsGrant *ConversationsGrant) ToPayload() map[string]interface{}

func (*ConversationsGrant) ToString

func (conversationsGrant *ConversationsGrant) ToString() string

type Incoming

type Incoming struct {
	Allow bool `json:"allow"`
}

type IpMessagingGrant

type IpMessagingGrant struct {
	ServiceSid        string `json:"service_sid"`
	EndpointID        string `json:"endpoint_id"`
	DeploymentRoleSid string `json:"deployment_role_sid"`
	PushCredentialSid string `json:"push_credential_sid"`
}

func (*IpMessagingGrant) Key

func (ipMessagingGrant *IpMessagingGrant) Key() string

func (*IpMessagingGrant) ToPayload

func (ipMessagingGrant *IpMessagingGrant) ToPayload() map[string]interface{}

func (*IpMessagingGrant) ToString

func (ipMessagingGrant *IpMessagingGrant) ToString() string

type Jwt

type Jwt struct {
	// The secret used to encode the JWT token.
	SecretKey string
	// The issuer of the JWT token.
	Issuer string
	// The subject of this JWT, omitted from the payload by default.
	Subject string
	// The algorithm used to encode the JWT token, defaults to 'HS256'.
	Algorithm string
	// Time in seconds before the JWT token is invalid. Defaults to now.
	Nbf float64
	// Time to live of the JWT in seconds; defaults to 1 hour.
	Ttl float64
	// Time in seconds since epoch this JWT is valid for. Override ttl if provided.
	ValidUntil float64

	DecodedHeaders map[string]interface{}
	DecodedPayload map[string]interface{}
}

func (*Jwt) FromJwt

func (token *Jwt) FromJwt(jwtStr string, key string) (*Jwt, error)

func (*Jwt) Headers

func (token *Jwt) Headers() map[string]interface{}

func (*Jwt) Payload

func (token *Jwt) Payload() map[string]interface{}

func (*Jwt) ToJwt

func (token *Jwt) ToJwt(generateHeaders, generatePayload func() map[string]interface{}) (string, error)

Encode this JWT struct into a string. algorithm - algorithm used to encode the JWT that overrides the default ttl - specify ttl to override the default

type Outgoing

type Outgoing struct {
	ApplicationSid    string                 `json:"application_sid"`
	ApplicationParams map[string]interface{} `json:"params"`
}

type PlaybackGrant

type PlaybackGrant map[string]interface{}

func (*PlaybackGrant) Key

func (playbackGrant *PlaybackGrant) Key() string

func (*PlaybackGrant) ToPayload

func (playbackGrant *PlaybackGrant) ToPayload() map[string]interface{}

func (*PlaybackGrant) ToString

func (playbackGrant *PlaybackGrant) ToString() string

type SyncGrant

type SyncGrant struct {
	ServiceSid string `json:"service_sid"`
	EndpointID string `json:"endpoint_id"`
}

func (*SyncGrant) Key

func (syncGrant *SyncGrant) Key() string

func (*SyncGrant) ToPayload

func (syncGrant *SyncGrant) ToPayload() map[string]interface{}

func (*SyncGrant) ToString

func (syncGrant *SyncGrant) ToString() string

type TaskRouterGrant

type TaskRouterGrant struct {
	WorkspaceSid string `json:"workspace_sid"`
	WorkerSid    string `json:"worker_sid"`
	Role         string `json:"role"`
}

func (*TaskRouterGrant) Key

func (taskRouterGrant *TaskRouterGrant) Key() string

func (*TaskRouterGrant) ToPayload

func (taskRouterGrant *TaskRouterGrant) ToPayload() map[string]interface{}

func (*TaskRouterGrant) ToString

func (taskRouterGrant *TaskRouterGrant) ToString() string

type TokenType

type TokenType string

type VideoGrant

type VideoGrant struct {
	Room string `json:"room"`
}

func (*VideoGrant) Key

func (videoGrant *VideoGrant) Key() string

func (*VideoGrant) ToPayload

func (videoGrant *VideoGrant) ToPayload() map[string]interface{}

func (*VideoGrant) ToString

func (videoGrant *VideoGrant) ToString() string

type VoiceGrant

type VoiceGrant struct {
	Incoming          Incoming `json:"incoming"`
	Outgoing          Outgoing `json:"outgoing"`
	PushCredentialSid string   `json:"push_credential_sid"`
	EndpointID        string   `json:"endpoint_id"`
}

func (*VoiceGrant) Key

func (voiceGrant *VoiceGrant) Key() string

func (*VoiceGrant) ToPayload

func (voiceGrant *VoiceGrant) ToPayload() map[string]interface{}

func (*VoiceGrant) ToString

func (voiceGrant *VoiceGrant) ToString() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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