Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultAuthRequestOptions ¶
func DefaultAuthRequestOptions() authRequestOptions
Types ¶
type Auth ¶
type Auth interface { // call the function in your application,ttl -1: loginout Update(ctx context.Context, req *AuthRequest, options ...AuthRequestOption) error Check(ctx context.Context, req *AuthRequest, options ...AuthRequestOption) (bool, error) MotionExpired(fc func(userName, clientId string) error) error }
Auth interface default public mqtt account is mqtt:public
type AuthDiscardPolicy ¶
type AuthDiscardPolicy int
const ( // DiscardOld will remove older user expired // the default. AuthDiscardOld AuthDiscardPolicy = iota //DiscardNew will fail to accept new auth AuthDiscardNew )
type AuthRequest ¶
type AuthRequest struct { ClientId string `json:"clientId"` // reCommended to use deviceID UserName string `json:"userName"` // reCommended to use userID `uint64` PassWord string `json:"passWord"` // reCommended to use temporary password or http sessionID token TlsServerName string `json:"tlsServerName"` // tls ShakeHande ServerName TlsSubjectName string `json:"tlsSubjectName"` // tls PeerCertificates subject.CommonName ClientIp string `json:"clientIp"` // real clientip }
type AuthRequestOption ¶
type AuthRequestOption func(*authRequestOptions) error
func WithAuthRequestDiscardPolicy ¶
func WithAuthRequestDiscardPolicy(val AuthDiscardPolicy) AuthRequestOption
func WithAuthRequestMaxTokens ¶
func WithAuthRequestMaxTokens(val uint64) AuthRequestOption
func WithAuthRequestTtl ¶
func WithAuthRequestTtl(ttl time.Duration) AuthRequestOption
type ErrAuthInvalid ¶
type ErrAuthInvalid error
var ( ErrAuthInvalidClientId ErrAuthInvalid = errors.New("mqx: auth failed, Invalid clientID") ErrAuthInvalidUserNamePassword ErrAuthInvalid = errors.New("mqx: auth failed, Invalid username or password") ErrAuthServiceUnviable ErrAuthInvalid = errors.New("mqx: auth faild, Service unavailable") ErrAuthInvalidClientIP ErrAuthInvalid = errors.New("mqx: auth failed, Invalid clientIP") ErrAuthInvalidExpired ErrAuthInvalid = errors.New("mqx: auth failed, Token expired") ErrAuthInvalidTooManyTokens ErrAuthInvalid = errors.New("mqx: auth failed, too many tokens") )
Click to show internal directories.
Click to hide internal directories.