auth

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2018 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AccessTypeRead  AccessType = 0x1
	AccessTypeWrite            = 0x2
	AccessTypeAll              = 0x3
	AccessTypeNone             = 0x4
)

nolint: golint

View Source
const (
	StatusAllow Status = 0
	StatusDeny         = 1
	StatusNone         = 2
)

nolint: golint

Variables

This section is empty.

Functions

func Register

func Register(name string, provider Provider) error

Register auth provider

func UnRegister

func UnRegister(name string)

UnRegister authenticator

Types

type AccessType

type AccessType int

AccessType acl type

func (AccessType) Type

func (t AccessType) Type() string

Type return string representation of the type

type Error

type Error int

Error auth provider errors

const (
	ErrInvalidArgs Error = iota
	ErrUnknownProvider
	ErrAlreadyExists
	ErrNotFound
	ErrNotOpen
	ErrInternal
)

nolint: golint

func (Error) Error

func (e Error) Error() string

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager auth

func NewManager

func NewManager(p string) (*Manager, error)

NewManager new auth manager

func (*Manager) ACL

func (m *Manager) ACL(clientID, user, topic string, access AccessType) Status

ACL check permissions

func (*Manager) AddUser added in v0.0.4

func (m *Manager) AddUser(param *UserParam) error

func (*Manager) DelUser added in v0.0.4

func (m *Manager) DelUser(user string) error

func (*Manager) ListUsers added in v0.0.4

func (m *Manager) ListUsers(handle func(string, string, string, string, string)) error

func (*Manager) Password

func (m *Manager) Password(user, password string) Status

Password authentication

type Provider

type Provider interface {
	// Password try authenticate with username and password
	Password(string, string) Status
	// ACL check access type for client id with username
	ACL(id string, username string, topic string, accessType AccessType) Status

	ListUsers(handle func(string, string, string, string, string)) error
	AddUser(param *UserParam) error
	DelUser(user string) error
}

Provider interface

type SessionPermissions

type SessionPermissions interface {
	ACL(id string, username string, topic string, accessType AccessType) Status
}

SessionPermissions check session permissions

type Status

type Status int

Status auth

func (Status) Error

func (e Status) Error() string

type UserParam added in v0.0.4

type UserParam struct {
	User     string `json:user`
	Password string `json:password`
	Status   string `json:status`
	Topic    string `json:topic`
	Access   string `json:access`
}

Jump to

Keyboard shortcuts

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