Documentation
¶
Overview ¶
Package device 设备登录权限认证及对应clientID,userName的处理
Index ¶
- Constants
- func AccessAuth(in AuthInfo) error
- 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 GenSecretDeviceInfo ¶ added in v0.3.0
func GetInt64ProductID ¶
func GetStrProductID ¶
先将 10进制 转为 62进制 然后 因为字符串类型的产品id有11个字节,不够的需要在前面补0
Types ¶
type LoginDevice ¶
type LoginDevice struct { ProductID string //产品id DeviceName string //设备名称 SdkAppID int64 //appid 直接填 12010126 ConnID string //随机6字节字符串 帮助查bug Expiry int64 //过期时间 unix时间戳 }
func GetClientIDInfo ¶
func GetClientIDInfo(ClientID string) (*LoginDevice, error)
func GetLoginDevice ¶
func GetLoginDevice(userName string) (*LoginDevice, error)
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 ¶ added in v0.5.1
Click to show internal directories.
Click to hide internal directories.