auth

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Interfaces = iota
	Controllers
	Doors
	Cards
	Groups
	Events
	Logs
	Users
)

Variables

View Source
var GRULES embed.FS
View Source
var Unauthorised = errors.New("not authorised")

Functions

func Init

func Init(rules map[RuleSet]string) error

func UID

func UID(a *Authorizator) string

Types

type Authorizator

type Authorizator struct {
	OpAuth
	// contains filtered or unexported fields
}

func NewAuthorizator

func NewAuthorizator(uid, role string) *Authorizator

type IAuthenticate

type IAuthenticate interface {
	Preauthenticate() (string, error)
	Authenticate(uid, pwd string) (string, error)
	Validate(uid, pwd string) error
	Verify(tokenType TokenType, token string) error
	Authenticated(token string) (string, string, string, error)
	Invalidate(tokenType TokenType, token string) error
}

type IUser

type IUser interface {
	Password() ([]byte, string)
	Role() string
}

type OpAuth

type OpAuth interface {
	CanView(o Operant, field string, value interface{}, rulesets ...RuleSet) error
	CanAdd(o Operant, rulesets ...RuleSet) error
	CanUpdate(o Operant, field string, value interface{}, rulesets ...RuleSet) error
	CanDelete(o Operant, rulesets ...RuleSet) error
}

type Operant

type Operant interface {
	AsRuleEntity() (string, interface{})
}

type RuleSet

type RuleSet int

func (RuleSet) String

func (r RuleSet) String() string

type TokenType

type TokenType int
const (
	Login   TokenType = iota // 0
	Session                  // 1
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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