Documentation ¶
Index ¶
- func Close() error
- func Initialise(server *mattrax.Server) error
- type DeviceStore
- func (ds DeviceStore) EditOrCreate(device devices.Device) error
- func (ds DeviceStore) Get(uuid string) (devices.Device, error)
- func (ds DeviceStore) GetAll() ([]devices.Device, error)
- func (ds DeviceStore) GetXDevices(firstDeviceUUID *string, count int64) ([]devices.Device, error)
- func (ds DeviceStore) Search(query string) ([]devices.Device, error)
- type PolicyService
- type UserService
- func (us UserService) CreateOrEdit(email string, user types.User) error
- func (us UserService) Get(email string) (types.User, error)
- func (us UserService) GetAll() ([]types.User, error)
- func (us UserService) HasPermission(email string, permission string) (bool, error)
- func (us UserService) HashPassword(password []byte) (types.RawPassword, error)
- func (us UserService) VerifyLogin(email string, password string) (bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Initialise ¶
Initialise the database connection and mount the services to the server
Types ¶
type DeviceStore ¶
type DeviceStore struct {
// contains filtered or unexported fields
}
DeviceStore saves and loads devices
func NewDeviceStore ¶
func NewDeviceStore(db *bolt.DB) (DeviceStore, error)
NewDeviceStore creates and initialises a new DeviceStore from a DB connection
func (DeviceStore) EditOrCreate ¶
func (ds DeviceStore) EditOrCreate(device devices.Device) error
EditOrCreate adds a new device or edits the existing device in the DB
func (DeviceStore) Get ¶
func (ds DeviceStore) Get(uuid string) (devices.Device, error)
Get returns a device from its UUID
func (DeviceStore) GetAll ¶
func (ds DeviceStore) GetAll() ([]devices.Device, error)
GetAll returns all devices
func (DeviceStore) GetXDevices ¶
GetXDevices returns X (set by count) devices starting at the firstDeviceUUID
type PolicyService ¶
type PolicyService struct {
// contains filtered or unexported fields
}
PolicyService contains the implemented functionality for policies
func NewPolicyService ¶
func NewPolicyService(db *bolt.DB) (PolicyService, error)
NewPolicyService creates and initialises a new PolicyService from a DB connection
func (PolicyService) CreateOrEdit ¶
func (ps PolicyService) CreateOrEdit(uuid types.PolicyUUID, policy types.Policy) error
CreateOrEdit creates or edits an existing policy if one exists
func (PolicyService) Get ¶
func (ps PolicyService) Get(uuid types.PolicyUUID) (types.Policy, error)
Get returns a policy by its uuid
type UserService ¶
type UserService struct {
// contains filtered or unexported fields
}
UserService contains the implemented functionality for users
func NewUserService ¶
func NewUserService(db *bolt.DB) (UserService, error)
NewUserService creates and initialises a new UserService from a DB connection
func (UserService) CreateOrEdit ¶
func (us UserService) CreateOrEdit(email string, user types.User) error
CreateOrEdit creates or edits an existing user if one exists
func (UserService) Get ¶
func (us UserService) Get(email string) (types.User, error)
Get returns a user by their email
func (UserService) GetAll ¶
func (us UserService) GetAll() ([]types.User, error)
GetAll returns all users
func (UserService) HasPermission ¶
func (us UserService) HasPermission(email string, permission string) (bool, error)
HasPermission takes a users email & a permission and checks if the user contains that permission. It also handles wildcard permissions that can be given to a user.
func (UserService) HashPassword ¶
func (us UserService) HashPassword(password []byte) (types.RawPassword, error)
HashPassword returns a password in hashed form ready to be stored into the DB
func (UserService) VerifyLogin ¶
func (us UserService) VerifyLogin(email string, password string) (bool, error)
VerifyLogin takes in a users email & password and checks if they match the users hashed password