face

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2022 License: GPL-3.0 Imports: 3 Imported by: 12

README

face

Auth

ACL

Rule Engine

Store

  • Redis

Bridge

  • Nats

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultAuthRequestOptions

func DefaultAuthRequestOptions() authRequestOptions

Types

type ACL

type ACL interface {
	SubcribeAble(userName string, topicPattern string)
	PublishAble(userName string, topicPattern string)
}

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")
)

Jump to

Keyboard shortcuts

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