Documentation
¶
Overview ¶
Package provision implements Account, User and Asset objects for use in txn2 projects.
Index ¶
- Constants
- func AccountAccessCheckHandler(checkAdmin bool) gin.HandlerFunc
- func GetAccountMapping(prefix string) es.IndexTemplate
- func GetAssetMapping(prefix string) es.IndexTemplate
- func GetUserMapping(prefix string) es.IndexTemplate
- func UserHasAccessHandler(c *gin.Context)
- func UserHasAdminAccessHandler(c *gin.Context)
- func UserTokenHandler() gin.HandlerFunc
- type AccessCheck
- type AccessCheckResult
- type AccessKey
- type Account
- type AccountModel
- type AccountResult
- type AccountResultAck
- type AccountSearchResults
- type AccountSearchResultsAck
- type Api
- func (a *Api) AuthUser(auth Auth) (*UserResult, bool, error)
- func (a *Api) AuthUserHandler(c *gin.Context)
- func (a *Api) CheckKey(accountId string, key AccessKey) (bool, error)
- func (a *Api) CheckKeyHandler(c *gin.Context)
- func (a *Api) GetAccount(id string) (int, *AccountResult, error)
- func (a *Api) GetAccountHandler(c *gin.Context)
- func (a *Api) GetAsset(id string) (int, *AssetResult, error)
- func (a *Api) GetAssetHandler(c *gin.Context)
- func (a *Api) GetUser(id string) (int, *UserResult, error)
- func (a *Api) GetUserHandler(c *gin.Context)
- func (a *Api) PrefixHandler(c *gin.Context)
- func (a *Api) SearchAccounts(searchObj *es.Obj) (int, AccountSearchResults, error)
- func (a *Api) SearchAccountsHandler(c *gin.Context)
- func (a *Api) SearchAssets(searchObj *es.Obj) (int, AssetSearchResults, error)
- func (a *Api) SearchAssetsHandler(c *gin.Context)
- func (a *Api) SearchUsers(searchObj *es.Obj) (int, UserSearchResults, error)
- func (a *Api) SearchUsersHandler(c *gin.Context)
- func (a *Api) SendEsMapping(mapping es.IndexTemplate) error
- func (a *Api) UpsertAccount(account *Account) (int, es.Result, error)
- func (a *Api) UpsertAccountHandler(c *gin.Context)
- func (a *Api) UpsertAsset(asset *Asset) (int, es.Result, error)
- func (a *Api) UpsertAssetHandler(c *gin.Context)
- func (a *Api) UpsertUser(user *User) (int, es.Result, error)
- func (a *Api) UpsertUserHandler(c *gin.Context)
- type Asset
- type AssetResult
- type AssetResultAck
- type AssetSearchResults
- type AssetSearchResultsAck
- type Auth
- type Config
- type User
- type UserResult
- type UserResultAck
- type UserSearchResults
- type UserSearchResultsAck
- type UserTokenResult
- type UserTokenResultAck
Constants ¶
const EncCost = 12
const IdxAccount = "account"
const IdxAsset = "asset"
const IdxUser = "user"
const RedactMsg = "REDACTED"
Variables ¶
This section is empty.
Functions ¶
func AccountAccessCheckHandler ¶ added in v0.0.8
func AccountAccessCheckHandler(checkAdmin bool) gin.HandlerFunc
AccountAccessCheckHandler
func GetAssetMapping ¶ added in v0.1.1
func GetAssetMapping(prefix string) es.IndexTemplate
GetAssetMapping
func UserHasAccessHandler ¶ added in v0.0.6
UserHasAccessHandler
func UserHasAdminAccessHandler ¶ added in v0.0.6
UserHasAdminAccessHandler
Types ¶
type AccessCheck ¶
AccessCheck is used to configure an access check
type AccessCheckResult ¶ added in v0.0.5
type AccessCheckResult struct {
AccessChecked *AccessCheck `json:"access_checked"`
Status bool `json:"status"`
Message string `json:"message"`
}
AccessCheckResult
type AccessKey ¶
type AccessKey struct {
Name string `json:"name"`
Description string `json:"description"`
Key string `json:"key"`
Active bool `json:"active"`
}
AccessKey
type Account ¶
type Account struct {
Id string `json:"id"`
Parent string `json:"parent"`
Description string `json:"description"`
DisplayName string `json:"display_name"`
Active bool `json:"active"`
Modules []string `json:"modules"`
OrgId int `json:"org_id"`
AccessKeys []AccessKey `json:"access_keys"`
}
User defines an account object
func (*Account) CheckEncryptKeys ¶ added in v0.0.11
CheckEncryptKeys checks and encrypts keys in the account object.
type AccountModel ¶ added in v0.1.1
AccountModel
type AccountResult ¶
AccountResult returned from Elastic
type AccountResultAck ¶ added in v0.0.11
type AccountResultAck struct {
ack.Ack
Payload AccountResult `json:"payload"`
}
AccountResultAck
type AccountSearchResults ¶ added in v0.0.2
type AccountSearchResults struct {
es.SearchResults
Hits struct {
Total int `json:"total"`
MaxScore float64 `json:"max_score"`
Hits []AccountResult `json:"hits"`
} `json:"hits"`
}
AccountSearchResults
type AccountSearchResultsAck ¶ added in v0.0.2
type AccountSearchResultsAck struct {
ack.Ack
Payload AccountSearchResults `json:"payload"`
}
AccountSearchResultsAck
type Api ¶
type Api struct {
*Config
}
Api
func (*Api) AuthUser ¶
func (a *Api) AuthUser(auth Auth) (*UserResult, bool, error)
AuthUser authenticates a user with id and password
func (*Api) CheckKey ¶ added in v0.0.13
CheckKey returns true if the provided key is valid for the account
func (*Api) CheckKeyHandler ¶ added in v0.0.13
CheckKeyHandler
func (*Api) GetAccount ¶
func (a *Api) GetAccount(id string) (int, *AccountResult, error)
GetAccount
func (*Api) GetAccountHandler ¶
GetAccountHandler gets an account by ID
func (*Api) GetAsset ¶ added in v0.1.1
func (a *Api) GetAsset(id string) (int, *AssetResult, error)
GetAsset
func (*Api) GetAssetHandler ¶ added in v0.1.1
GetAssetHandler gets an asset by ID
func (*Api) GetUserHandler ¶
GetUserHandler gets a user by ID
func (*Api) PrefixHandler ¶ added in v0.0.2
PrefixHandler
func (*Api) SearchAccounts ¶ added in v0.0.2
SearchAccounts
func (*Api) SearchAccountsHandler ¶ added in v0.0.2
SearchAccountsHandler
func (*Api) SearchAssets ¶ added in v0.1.1
SearchAssets
func (*Api) SearchAssetsHandler ¶ added in v0.1.1
SearchAssetsHandler
func (*Api) SearchUsers ¶ added in v0.0.2
SearchUsers
func (*Api) SearchUsersHandler ¶ added in v0.0.2
SearchUsersHandler
func (*Api) SendEsMapping ¶
func (a *Api) SendEsMapping(mapping es.IndexTemplate) error
SetupUserIndexTemplate
func (*Api) UpsertAccount ¶
UpsertAccount inserts or updates an account. Elasticsearch treats documents as immutable.
func (*Api) UpsertAccountHandler ¶
UpsertAccountHandler
func (*Api) UpsertAsset ¶ added in v0.1.1
UpsertAccount inserts or updates an asset. Elasticsearch treats documents as immutable.
func (*Api) UpsertAssetHandler ¶ added in v0.1.1
UpsertAssetHandler
func (*Api) UpsertUser ¶
UpsertUser inserts or updates a user record. Elasticsearch treats documents as immutable.
type Asset ¶ added in v0.1.1
type Asset struct {
Id string `json:"id"`
AccountId string `json:"account_id"`
Description string `json:"description"`
DisplayName string `json:"display_name"`
AssetClass string `json:"asset_class"`
AssetCfg string `json:"asset_cfg"`
Active bool `json:"active"`
AccountModels []AccountModel `json:"account_models"`
SystemModels []string `json:"system_models"`
}
Asset defines an asset object
type AssetResult ¶ added in v0.1.1
AssetResult returned from Elastic
type AssetResultAck ¶ added in v0.1.1
type AssetResultAck struct {
ack.Ack
Payload AssetResult `json:"payload"`
}
AssetResultAck
type AssetSearchResults ¶ added in v0.1.1
type AssetSearchResults struct {
es.SearchResults
Hits struct {
Total int `json:"total"`
MaxScore float64 `json:"max_score"`
Hits []AssetResult `json:"hits"`
} `json:"hits"`
}
AssetSearchResults
type AssetSearchResultsAck ¶ added in v0.1.1
type AssetSearchResultsAck struct {
ack.Ack
Payload AssetSearchResults `json:"payload"`
}
AssetSearchResultsAck
type Config ¶
type Config struct {
Logger *zap.Logger
HttpClient *micro.Client
// used for communication with Elasticsearch
// if nil, one will be created
Elastic *es.Client
ElasticServer string
// used to prefix the user and account indexes IdxPrefix_user, IdxPrefix_account
// defaults to system.
IdxPrefix string
// pre-configured from server (txn2/micro)
Token *token.Jwt
}
Config
type User ¶
type User struct {
Id string `json:"id" mapstructure:"id"`
Description string `json:"description" mapstructure:"description"`
DisplayName string `json:"display_name" mapstructure:"display_name"`
Active bool `json:"active" mapstructure:"active"`
Sysop bool `json:"sysop" mapstructure:"sysop"`
Password string `json:"password" mapstructure:"password"`
Sections []string `json:"sections" mapstructure:"sections"`
SectionsAll bool `json:"sections_all" mapstructure:"sections_all"`
Accounts []string `json:"accounts" mapstructure:"accounts"`
AdminAccounts []string `json:"admin_accounts" mapstructure:"admin_accounts"`
}
User defines a user object
func (*User) CheckEncryptPassword ¶
CheckEncryptPassword checks and encrypts the password in the user object.
func (*User) HasAccess ¶
func (u *User) HasAccess(ac *AccessCheck) bool
BasicAccess returns true is user is active and not locked
func (*User) HasBasicAccess ¶
BasicAccess returns true is user is active and not locked
type UserResult ¶
UserResult returned from Elastic
type UserResultAck ¶ added in v0.0.13
type UserResultAck struct {
ack.Ack
Payload UserResult `json:"payload"`
}
UserTokenResultAck
type UserSearchResults ¶ added in v0.0.2
type UserSearchResults struct {
es.SearchResults
Hits struct {
Total int `json:"total"`
MaxScore float64 `json:"max_score"`
Hits []UserResult `json:"hits"`
} `json:"hits"`
}
UserSearchResults
type UserSearchResultsAck ¶ added in v0.0.2
type UserSearchResultsAck struct {
ack.Ack
Payload UserSearchResults `json:"payload"`
}
UserSearchResultsAck
type UserTokenResult ¶ added in v0.0.2
UserTokenResult
type UserTokenResultAck ¶ added in v0.0.13
type UserTokenResultAck struct {
ack.Ack
Payload UserTokenResult `json:"payload"`
}
UserTokenResultAck
