Documentation
¶
Index ¶
- Constants
- func AssertEqual(t *testing.T, expected, actual interface{})
- func AssertNil(t *testing.T, err error)
- func GetUidStr(uid uint32) string
- func Md5(str string) string
- type AccessToken
- func (accessToken *AccessToken) AddService(service IService)
- func (accessToken *AccessToken) Build() (res string, err error)
- func (accessToken *AccessToken) GetServices(serviceType uint16) []IService
- func (accessToken *AccessToken) Parse(token string) (res bool, err error)
- func (accessToken *AccessToken) VerifySignature(appCertificate string) (bool, error)
- type IService
- type Rtm2Permissions
- type Service
- type ServiceApaas
- type ServiceChat
- type ServiceFCdn
- type ServiceFpa
- type ServiceRtc
- type ServiceRtm
- type ServiceRtm2
- type ServiceStreaming
Constants ¶
const ( Version = "007" VersionLength = 3 // Service type ServiceTypeRtc = 1 ServiceTypeRtm = 2 ServiceTypeStreaming = 3 ServiceTypeFpa = 4 ServiceTypeChat = 5 ServiceTypeFCdn = 6 ServiceTypeApaas = 7 ServiceTypeRtm2 = 8 // Rtc PrivilegeJoinChannel = 1 PrivilegePublishAudioStream = 2 PrivilegePublishVideoStream = 3 PrivilegePublishDataStream = 4 // Rtm // Fpa PrivilegeLogin = 1 // Streaming PrivilegeStreamingPublishMixStream = 1 PrivilegeStreamingPublishRawStream = 2 // FCDN PrivilegeFCdnPublish = 1 PrivilegeFCdnPlay = 2 // Chat PrivilegeChatUser = 1 PrivilegeChatApp = 2 // Apaas PrivilegeApaasRoomUser = 1 PrivilegeApaasUser = 2 PrivilegeApaasApp = 3 // RTM2 resource types Rtm2ResourceMessageChannels = 0 Rtm2ResourceStreamChannels = 1 Rtm2ResourceGroupChannels = 2 Rtm2ResourceServerGroups = 3 Rtm2ResourceUsers = 4 // RTM2 permission types Rtm2PermissionRead = 0 Rtm2PermissionWrite = 1 )
Variables ¶
This section is empty.
Functions ¶
func AssertEqual ¶
AssertEqual reports a value mismatch and its caller location.
Types ¶
type AccessToken ¶
type AccessToken struct {
AppCert string
AppId string
Expire uint32
IssueTs uint32
Salt uint32
Services []IService
// contains filtered or unexported fields
}
func CreateAccessToken ¶
func CreateAccessToken() (accessToken *AccessToken)
CreateAccessToken creates an empty access token for parsing.
func NewAccessToken ¶
func NewAccessToken(appId string, appCert string, expire uint32) (accessToken *AccessToken)
NewAccessToken creates an access token with the current timestamp and a random salt.
func (*AccessToken) AddService ¶
func (accessToken *AccessToken) AddService(service IService)
AddService adds a service without replacing an existing service of the same type.
func (*AccessToken) Build ¶
func (accessToken *AccessToken) Build() (res string, err error)
Build serializes all services into a Token007 token and requires at least one service.
func (*AccessToken) GetServices ¶
func (accessToken *AccessToken) GetServices(serviceType uint16) []IService
GetServices returns all services of the requested type in insertion or token order.
func (*AccessToken) Parse ¶
func (accessToken *AccessToken) Parse(token string) (res bool, err error)
Parse parses known services and keeps the original signing bytes for independent verification.
func (*AccessToken) VerifySignature ¶
func (accessToken *AccessToken) VerifySignature(appCertificate string) (bool, error)
VerifySignature verifies the parsed token without rebuilding its service payload.
type Rtm2Permissions ¶
func NewRtm2Permissions ¶
func NewRtm2Permissions() *Rtm2Permissions
NewRtm2Permissions creates an empty RTM2 permission set.
type Service ¶
func NewService ¶
NewService creates a service with the specified type and an empty privilege map.
func (*Service) AddPrivilege ¶
AddPrivilege sets the expiration time for a service privilege.
type ServiceApaas ¶
func NewServiceApaas ¶
func NewServiceApaas(roomUuid string, userUuid string, role int16) (serviceApaas *ServiceApaas)
NewServiceApaas creates an APaaS service for a room, user, and role.
type ServiceChat ¶
func NewServiceChat ¶
func NewServiceChat(userId string) (serviceChat *ServiceChat)
NewServiceChat creates a Chat service for a user ID.
type ServiceFCdn ¶
func NewServiceFCdn ¶
func NewServiceFCdn(channelName string, account string) *ServiceFCdn
NewServiceFCdn creates an FCDN service for a channel and user account.
func NewServiceFCdnWithUid ¶
func NewServiceFCdnWithUid(channelName string, uid uint32) *ServiceFCdn
NewServiceFCdnWithUid creates an FCDN service with a numeric user ID.
type ServiceFpa ¶
type ServiceFpa struct {
*Service
}
func NewServiceFpa ¶
func NewServiceFpa() (serviceFpa *ServiceFpa)
NewServiceFpa creates an FPA service.
type ServiceRtc ¶
func NewServiceRtc ¶
func NewServiceRtc(channelName string, uid string) (serviceRtc *ServiceRtc)
NewServiceRtc creates an RTC service for a channel and user ID.
type ServiceRtm ¶
func NewServiceRtm ¶
func NewServiceRtm(userId string) (serviceRtm *ServiceRtm)
NewServiceRtm creates an RTM service for a user ID.
type ServiceRtm2 ¶
type ServiceRtm2 struct {
*Service
UserId string
Permissions *Rtm2Permissions
}
func NewServiceRtm2 ¶
func NewServiceRtm2(userId string, permissions *Rtm2Permissions) *ServiceRtm2
NewServiceRtm2 creates an RTM2 service with resource-level permissions.
type ServiceStreaming ¶
func NewServiceStreaming ¶
func NewServiceStreaming(channelName string, account string) *ServiceStreaming
NewServiceStreaming creates a Streaming service for a channel and user account.
func NewServiceStreamingWithUid ¶
func NewServiceStreamingWithUid(channelName string, uid uint32) *ServiceStreaming
NewServiceStreamingWithUid creates a Streaming service with a numeric user ID.