Documentation ¶
Index ¶
- Variables
- func CreateUser(u *User) error
- func GetUserSalt() string
- func IsEmailUsed(email string) (bool, error)
- func LoadDefaultSavedQueries() error
- func NewDatabase(c *config.Config) (*xorm.Engine, error)
- func NewSavedQuery(s SavedQuery) error
- func UniqueKey() string
- type AllNodeOptions
- type Category
- type Config
- type Node
- func AllNodes(options *AllNodeOptions) ([]*Node, error)
- func CreateOrUpdateNode(req *osquery.EnrollReq) (*Node, error)
- func FindAndUpdateNode(req *osquery.KeyReq) (*Node, error)
- func FindNodeByNodeKey(key string) (*Node, error)
- func FindNodeByRequest(c *gin.Context, req *osquery.KeyReq) (*Node, error)
- type SavedQuery
- type User
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUserNotExist user not found error message ErrUserNotExist = errors.New("User does not exist") )
Functions ¶
func IsEmailUsed ¶
IsEmailUsed returns true if the e-mail has been used.
func LoadDefaultSavedQueries ¶
func LoadDefaultSavedQueries() error
LoadDefaultSavedQueries Load all of the default saved queries. This will only run once on initial database creation.
func NewDatabase ¶
NewDatabase will create, connect return a postgres connection pool
func NewSavedQuery ¶
func NewSavedQuery(s SavedQuery) error
NewSavedQuery will iadd a new saved query to the database.
Types ¶
type AllNodeOptions ¶
type AllNodeOptions struct {
OnlyEnabled bool
}
AllNodeOptions for AllNodes query
type Node ¶
type Node struct { Id int64 `json:"id"` Key string `xorm:"UNIQUE NOT NULL" json:"key"` Address string `json:"address"` Name string `xorm:"INDEX NOT NULL" json:"name"` Enabled bool `xorm:"INDEX NOT NULL" json:"enabled"` Created time.Time `xorm:"CREATED" json:"created"` Updated time.Time `xorm:"UPDATED" json:"updated"` }
Node database table schema
func AllNodes ¶
func AllNodes(options *AllNodeOptions) ([]*Node, error)
AllNodes Return all nodes in the database
func CreateOrUpdateNode ¶
CreateOrUpdateNode will create or update a node from a enroll request
func FindAndUpdateNode ¶
FindAndUpdateNode node by node key which is also the osquery host id
func FindNodeByNodeKey ¶
FindNodeByNodeKey node by node key which is also the osquery host id
func FindNodeByRequest ¶
FindNodeByRequest takes the osquery request and returns a node from the database
type SavedQuery ¶
type SavedQuery struct { Id int64 `json:"id"` Name string `xorm:"NOT NULL" from:"name" binding:"required"` Query string `xorm:"NOT NULL" from:"query" binding:"required"` Type string `xorm:"NOT NULL" form:"type" binding:"required"` }
SavedQuery database table.
func AllSavedQueries ¶
func AllSavedQueries() ([]*SavedQuery, error)
AllSavedQueries returns all saved queries in the database.
func FindSavedQueryById ¶
func FindSavedQueryById(id int64) (*SavedQuery, error)
FindSavedQueryById a saved query by its id.
type User ¶
type User struct { Id int64 Name string `xorm:"NOT NULL" json:"name"` Key string `xorm:"UNIQUE INDEX NOT NULL" json:"key"` Email string `xorm:"UNIQUE NOT NULL" json:"email"` Avatar string `xorm:"VARCHAR(2048) NOT NULL" json:"avatar"` AvatarEmail string `xorm:"NOT NULL" json:"-"` Password string `xorm:"NOT NULL" json:"-"` Hash string `xorm:"VARCHAR(10)" json:"-"` Salt string `xorm:"VARCHAR(10)" json:"-"` Admin bool `json:"admin"` Enabled bool `json:"enabled"` }
User database table schema
func GetUserByEmail ¶
GetUserByEmail returns the user object by given e-mail if exists.
func GetUserById ¶
GetUserById returns the user object by given ID if exists.
func (*User) AvatarLink ¶
AvatarLink Users avatar link. Using gravatar
func (*User) EncodePassword ¶
func (u *User) EncodePassword()
EncodePassword encodes password to safe format.
func (*User) ValidatePassword ¶
ValidatePassword checks if given password matches the one belongs to the user.