Documentation ¶
Index ¶
- func NewFilesJWTChecker(authOpts map[string]string, logLevel log.Level, hasher hashing.HashComparer, ...) (jwtChecker, error)
- func NewJsJWTChecker(authOpts map[string]string, options tokenOptions) (jwtChecker, error)
- func NewLocalJWTChecker(authOpts map[string]string, logLevel log.Level, hasher hashing.HashComparer, ...) (jwtChecker, error)
- func NewRemoteJWTChecker(authOpts map[string]string, options tokenOptions, version string) (jwtChecker, error)
- func OpenDatabase(dsn, engine string, tries int, maxLifeTime int64) (*sqlx.DB, error)
- type Backend
- type Backends
- type CustomPlugin
- func (o *CustomPlugin) CheckAcl(username, topic, clientid string, acc int32) (bool, error)
- func (o *CustomPlugin) GetName() string
- func (o *CustomPlugin) GetSuperuser(username string) (bool, error)
- func (o *CustomPlugin) GetUser(username, password, clientid string) (bool, error)
- func (o *CustomPlugin) Halt()
- type Files
- type GRPC
- type HTTP
- type HTTPResponse
- type JWT
- type Javascript
- type Mongo
- type MongoAcl
- type MongoUser
- type Mysql
- type Postgres
- type Redis
- type RedisClient
- type Response
- type SingleRedisClient
- type Sqlite
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewFilesJWTChecker ¶
func NewJsJWTChecker ¶
func NewLocalJWTChecker ¶
func NewLocalJWTChecker(authOpts map[string]string, logLevel log.Level, hasher hashing.HashComparer, options tokenOptions) (jwtChecker, error)
NewLocalJWTChecker initializes a checker with a local DB.
func NewRemoteJWTChecker ¶
func OpenDatabase ¶
OpenDatabase opens the database and performs a ping to make sure the database is up. Taken from brocaar's lora-app-server: https://github.com/brocaar/lora-app-server
Types ¶
type Backends ¶
type Backends struct {
// contains filtered or unexported fields
}
func Initialize ¶
Initialize sets general options, tries to build the backends and register their checkers.
func (*Backends) AuthAclCheck ¶
AuthAclCheck checks user/topic/acc authorization.
func (*Backends) AuthUnpwdCheck ¶
AuthUnpwdCheck checks user authentication.
type CustomPlugin ¶
type CustomPlugin struct {
// contains filtered or unexported fields
}
func NewCustomPlugin ¶
func (*CustomPlugin) CheckAcl ¶
func (o *CustomPlugin) CheckAcl(username, topic, clientid string, acc int32) (bool, error)
func (*CustomPlugin) GetName ¶
func (o *CustomPlugin) GetName() string
func (*CustomPlugin) GetSuperuser ¶
func (o *CustomPlugin) GetSuperuser(username string) (bool, error)
func (*CustomPlugin) GetUser ¶
func (o *CustomPlugin) GetUser(username, password, clientid string) (bool, error)
func (*CustomPlugin) Halt ¶
func (o *CustomPlugin) Halt()
type Files ¶
type Files struct {
// contains filtered or unexported fields
}
Files hols a static failes checker.
func NewFiles ¶
func NewFiles(authOpts map[string]string, logLevel log.Level, hasher hashing.HashComparer) (*Files, error)
NewFiles initializes a files backend.
func (*Files) CheckAcl ¶
CheckAcl checks that the topic may be read/written by the given user/clientid.
func (*Files) GetSuperuser ¶
GetSuperuser returns false for files backend.
type GRPC ¶
type GRPC struct {
// contains filtered or unexported fields
}
GRPC holds a client for the service and implements the Backend interface.
func (*GRPC) GetSuperuser ¶
GetSuperuser checks that the user is a superuser.
type HTTP ¶
type HTTP struct { UserUri string SuperuserUri string AclUri string UserAgent string Host string Port string WithTLS bool VerifyPeer bool ParamsMode string ResponseMode string Timeout int Client *h.Client // contains filtered or unexported fields }
type HTTPResponse ¶
type JWT ¶
type JWT struct {
// contains filtered or unexported fields
}
func (*JWT) GetSuperuser ¶
GetSuperuser checks if the given user is a superuser.
type Javascript ¶
type Javascript struct {
// contains filtered or unexported fields
}
func NewJavascript ¶
func (*Javascript) CheckAcl ¶
func (o *Javascript) CheckAcl(username, topic, clientid string, acc int32) (bool, error)
func (*Javascript) GetName ¶
func (o *Javascript) GetName() string
GetName returns the backend's name
func (*Javascript) GetSuperuser ¶
func (o *Javascript) GetSuperuser(username string) (bool, error)
func (*Javascript) GetUser ¶
func (o *Javascript) GetUser(username, password, clientid string) (bool, error)
func (*Javascript) Halt ¶
func (o *Javascript) Halt()
type Mongo ¶
type Mongo struct { Host string Port string Username string Password string SaltEncoding string DBName string AuthSource string UsersCollection string AclsCollection string Conn *mongo.Client // contains filtered or unexported fields }
func (Mongo) CheckAcl ¶
CheckAcl gets all acls for the username and tries to match against topic, acc, and username/clientid if needed.
func (Mongo) GetSuperuser ¶
GetSuperuser checks that the key username:su exists and has value "true".
type Mysql ¶
type Mysql struct { DB *sqlx.DB Host string Port string DBName string User string Password string UserQuery string SuperuserQuery string AclQuery string SSLMode string SSLCert string SSLKey string SSLRootCert string Protocol string SocketPath string AllowNativePasswords bool // contains filtered or unexported fields }
Mysql holds all fields of the Mysql db connection.
func (Mysql) CheckAcl ¶
CheckAcl gets all acls for the username and tries to match against topic, acc, and username/clientid if needed.
func (Mysql) GetSuperuser ¶
GetSuperuser checks that the username meets the superuser query.
type Postgres ¶
type Postgres struct { DB *sqlx.DB Host string Port string DBName string User string Password string UserQuery string SuperuserQuery string AclQuery string SSLMode string SSLCert string SSLKey string SSLRootCert string // contains filtered or unexported fields }
Postgres holds all fields of the postgres db connection.
func NewPostgres ¶
func (Postgres) CheckAcl ¶
CheckAcl gets all acls for the username and tries to match against topic, acc, and username/clientid if needed.
func (Postgres) GetSuperuser ¶
GetSuperuser checks that the username meets the superuser query.
type Redis ¶
type Redis struct { Host string Port string Password string SaltEncoding string DB int32 // contains filtered or unexported fields }
func (Redis) GetSuperuser ¶
GetSuperuser checks that the key username:su exists and has value "true".
type RedisClient ¶
type RedisClient interface { Get(ctx context.Context, key string) *goredis.StringCmd SMembers(ctx context.Context, key string) *goredis.StringSliceCmd Ping(ctx context.Context) *goredis.StatusCmd Close() error FlushDB(ctx context.Context) *goredis.StatusCmd Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *goredis.StatusCmd SAdd(ctx context.Context, key string, members ...interface{}) *goredis.IntCmd Expire(ctx context.Context, key string, expiration time.Duration) *goredis.BoolCmd ReloadState(ctx context.Context) }
type SingleRedisClient ¶
func (SingleRedisClient) ReloadState ¶
func (c SingleRedisClient) ReloadState(ctx context.Context)
type Sqlite ¶
type Sqlite struct { DB *sqlx.DB Source string UserQuery string SuperuserQuery string AclQuery string // contains filtered or unexported fields }
Sqlite holds all fields of the sqlite db connection.
func (Sqlite) CheckAcl ¶
CheckAcl gets all acls for the username and tries to match against topic, acc, and username/clientid if needed.
func (Sqlite) GetSuperuser ¶
GetSuperuser checks that the username meets the superuser query.