Documentation
¶
Overview ¶
Copyright 2019 txn2
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2019 txn2 ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2019 txn2 ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- func GetAccountMapping(prefix string) es.IndexTemplate
- func GetUserMapping(prefix string) es.IndexTemplate
- type AccessCheck
- type AccessKey
- type Account
- type AccountResult
- type Api
- func (a *Api) AuthUser(auth Auth) (bool, bool, error)
- func (a *Api) AuthUserHandler(c *gin.Context)
- func (a *Api) GetAccount(id string) (int, *AccountResult, error)
- func (a *Api) GetAccountHandler(c *gin.Context)
- func (a *Api) GetUser(id string) (int, *UserResult, error)
- func (a *Api) GetUserHandler(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) UpsertUser(user *User) (int, es.Result, error)
- func (a *Api) UpsertUserHandler(c *gin.Context)
- type Auth
- type Config
- type User
- type UserResult
Constants ¶
const EncCost = 12
const IdxAccount = "account"
const IdxUser = "user"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AccessCheck ¶
AccessCheck is used to configure an access check
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"`
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 a DCP user object
type AccountResult ¶
AccountResult returned from Elastic
type Api ¶
type Api struct {
*Config
}
Api
func (*Api) AuthUserHandler ¶
func (*Api) GetAccount ¶
func (a *Api) GetAccount(id string) (int, *AccountResult, error)
GetAccount
func (*Api) GetAccountHandler ¶
GetAccountHandler gets an account by ID
func (*Api) GetUserHandler ¶
GetUserHandler gets a user by ID
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) UpsertUser ¶
UpsertUser inserts or updates a user record. Elasticsearch treats documents as immutable.
type Config ¶
type Config struct {
Logger *zap.Logger
HttpClient *ack.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
}
Config
type User ¶
type User struct {
Id string `json:"id"`
Description string `json:"description"`
DisplayName string `json:"display_name"`
Active bool `json:"active"`
Sysop bool `json:"sysop"`
Password string `json:"password"`
Sections []string `json:"sections"`
SectionsAll bool `json:"sections_all"`
Accounts []string `json:"accounts"`
AdminAccounts []string `json:"admin_accounts"`
}
User defines a user object User defines a user object
func (*User) CheckEncryptPassword ¶
CheckEncryptPassword checks and encrypts the password inthe 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
