Documentation
¶
Overview ¶
Package device 设备登录权限认证及对应clientID,userName的处理
Index ¶
- Constants
- func AccessAuth(in AuthInfo) error
- func GenClientID(productID string, deviceName string) string
- func GenSecretDeviceInfo(hmacType string, productID string, deviceName string, deviceSecret string) (clientID, userName, password string)
- func GetInt64ProductID(id string) int64
- func GetStrProductID(id int64) string
- type AuthInfo
- type LoginDevice
- type PwdInfo
Constants ¶
View Source
const ( ProductIDLen = 11 HmacSha256 = "hmacsha256" HmacSha1 = "hmacsha1" )
Variables ¶
This section is empty.
Functions ¶
func GenClientID ¶
func GenSecretDeviceInfo ¶
func GetInt64ProductID ¶
func GetStrProductID ¶
先将 10进制 转为 62进制 然后 因为字符串类型的产品id有11个字节,不够的需要在前面补0
Types ¶
type LoginDevice ¶
type LoginDevice struct { ClientID string ProductID string //产品id DeviceName string //设备名称 SdkAppID int64 //appid 直接填 12010126 ConnID string //随机6字节字符串 帮助查bug Expiry int64 //过期时间 unix时间戳 IsNeedRegister bool }
func GetClientIDInfo ¶
func GetClientIDInfo(ClientID string) (*LoginDevice, error)
func GetLoginDevice ¶
func GetLoginDevice(userName string) (*LoginDevice, error)
生成 MQTT 的 username 部分, 格式为 ${clientid};${sdkappid};${connid};${expiry}
type PwdInfo ¶
type PwdInfo struct { HmacHandle func(data string, secret []byte) string // contains filtered or unexported fields }
username 字段的格式为: ${productId}${deviceName};${sdkappid};${connid};${expiry} 注意:${} 表示变量,并非特定的拼接符号。
password 字段格式为: ${token};hmac 签名方法 其中 hmac 签名方法字段填写第三步用到的摘要算法,可选的值有 hmacsha256 和 hmacsha1。
func NewPwdInfoWithPwd ¶
Click to show internal directories.
Click to hide internal directories.