data

package
v0.0.0-...-34c6a2e Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PlaceHolderGroup  = "$g"
	PlaceHolderBridge = "$b"
	PlaceHolderLight  = "$l"
)

Variables

View Source
var ErrAccessDenied = errors.New("access denied")

Functions

func AddMacro

func AddMacro(name string, description string, sequence ...string) error

AddMacro adds a macro to the database, the description is optional.

func AddSequence

func AddSequence(sequence string, commands []string) error

func CheckPasswordHash

func CheckPasswordHash(password, hash string) bool

func Close

func Close()

func DelUser

func DelUser(username string) error

func DeleteMacro

func DeleteMacro(name string) error

func FakeCycle

func FakeCycle()

FakeCycle chooses the first known user and cycles through all their auth methods to avoid time based user enumeration.

func HashPassword

func HashPassword(password string) (string, error)

func ParseRunSequence

func ParseRunSequence(input string) (sequence string, targets map[TargetType]map[int]string, err error)

func RunSequence

func RunSequence(sequence string, targets map[TargetType]map[int]string) ([]string, error)

func Start

func Start()

func StartTest

func StartTest()

Types

type AuthMethod

type AuthMethod interface {
	json.Marshaler
	StringMapper
	// Authenticate authenticates the user.
	Authenticate() error
	// Name returns the name of the authentication method.
	Name() string
}

func AuthMethodFromMap

func AuthMethodFromMap(m map[string]string) AuthMethod

type Macro

type Macro struct {
	Name        string   `json:"name"`
	Description string   `json:"description,omitempty"`
	Sequence    []string `json:"sequence"`
}

func GetMacro

func GetMacro(name string) (mcro *Macro, err error)

type PubKey

type PubKey struct {
	Username string        `json:"pub_username"`
	Pub      ssh.PublicKey `json:"pubkey"`
}

func NewPubKey

func NewPubKey(username string, pubkey ssh.PublicKey) *PubKey

func (*PubKey) Authenticate

func (pk *PubKey) Authenticate() error

func (*PubKey) Map

func (pk *PubKey) Map() map[string]string

func (*PubKey) MarshalJSON

func (pk *PubKey) MarshalJSON() ([]byte, error)

func (*PubKey) Name

func (pk *PubKey) Name() string

type Sequence

type Sequence struct {
	Lines         []string               `json:"lines"`
	TargetsNeeded map[TargetType]Targets `json:"targets_needed,omitempty"`
}

type StringMapper

type StringMapper interface {
	Map() map[string]string
}

type TargetType

type TargetType uint16
const (
	TargetTypeBridge TargetType = iota
	TargetTypeGroup
	TargetTypeLight
)

type Targets

type Targets map[int]string

type User

type User struct {
	Username    string              `json:"username"`
	AuthMethods []map[string]string `json:"auth_methods"`
	*sync.Mutex
}

func GetUser

func GetUser(username string) (*User, error)

func NewUser

func NewUser(username string, authMethods ...AuthMethod) (*User, error)

func (*User) AddAuthMethod

func (user *User) AddAuthMethod(method AuthMethod) (*User, error)

func (*User) ChangePassword

func (user *User) ChangePassword(newPassword string) (*User, error)

func (*User) DelPubKey

func (user *User) DelPubKey(pubkey ssh.PublicKey) (*User, error)

type UserPass

type UserPass struct {
	Username string `json:"pass_username"`
	Password string `json:"password"`
}

func NewUserPass

func NewUserPass(hashIt bool, username, password string) *UserPass

func (*UserPass) Authenticate

func (up *UserPass) Authenticate() error

func (*UserPass) Map

func (up *UserPass) Map() map[string]string

func (*UserPass) MarshalJSON

func (up *UserPass) MarshalJSON() ([]byte, error)

func (*UserPass) Name

func (up *UserPass) Name() string

Jump to

Keyboard shortcuts

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