Documentation ¶
Index ¶
- Variables
- func FormatError(err error) interface{}
- func HandleError(c *gin.Context, code int, err error)
- type APIControllerDefinitions
- type APIControllerMaker
- type APIPlugin
- type AccessToken
- type AssociateAdaptor
- type BaseController
- func (b *BaseController) APIDefinitions() *Definitions
- func (b *BaseController) CanAccess(user *User, object kodex.Model, objectRoles []string) (bool, error)
- func (b *BaseController) ObjectRolesForUser(objectType string, user *User) ([]ObjectRole, error)
- func (b *BaseController) RegisterAPIPlugin(plugin APIPlugin) error
- func (b *BaseController) UserProvider() UserProvider
- type BaseObjectRole
- type BaseOrganization
- type Blueprint
- type Controller
- type CreateObjectAdaptor
- type CreateUserProvider
- type Definitions
- type In
- type ListAllObjectAdaptor
- type ObjectAdaptor
- type ObjectRole
- type ObjectRoleSpec
- type Organization
- type OrganizationRoles
- type Routes
- type Settings
- type SettingsValidator
- type UpdateObjectAdaptor
- type User
- type UserOrganization
- type UserProvider
- type UserProviderDefinition
- type UserProviderDefinitions
- type UserProviderMaker
- type UserProviderSettings
- type UsersAndRoles
Constants ¶
This section is empty.
Variables ¶
View Source
var AccessTokenForm = forms.Form{ Fields: []forms.Field{ { Name: "token", Validators: []forms.Validator{ forms.IsBytes{Encoding: "hex"}, }, }, { Name: "scopes", Validators: []forms.Validator{ forms.IsList{ Validators: []forms.Validator{ forms.IsString{}, }, }, }, }, }, }
View Source
var BPObjectRoleForm = forms.Form{ Fields: []forms.Field{ { Name: "objectType", Validators: []forms.Validator{ forms.IsString{}, }, }, { Name: "organizationID", Validators: []forms.Validator{ forms.IsBytes{Encoding: "hex"}, }, }, { Name: "objectID", Validators: []forms.Validator{ forms.IsBytes{Encoding: "hex"}, }, }, { Name: "organizationRole", Validators: []forms.Validator{ forms.IsString{}, }, }, { Name: "organizationSource", Validators: []forms.Validator{ forms.IsOptional{Default: "inMemory"}, forms.IsString{}, }, }, { Name: "objectRole", Validators: []forms.Validator{ forms.IsString{}, }, }, }, }
View Source
var BPOrganizationForm = forms.Form{ Fields: []forms.Field{ { Name: "source", Validators: []forms.Validator{ forms.IsOptional{Default: "inMemory"}, forms.IsIn{Choices: []interface{}{"inMemory"}}, }, }, { Name: "name", Validators: []forms.Validator{ forms.IsString{}, }, }, { Name: "id", Validators: []forms.Validator{ forms.IsBytes{Encoding: "hex"}, }, }, }, }
View Source
var BlueprintConfigForm = forms.Form{ Fields: []forms.Field{ { Name: "users", Validators: []forms.Validator{ forms.IsList{ Validators: []forms.Validator{ forms.IsStringMap{ Form: &UserForm, }, }, }, }, }, { Name: "roles", Validators: []forms.Validator{ forms.IsList{ Validators: []forms.Validator{ forms.IsStringMap{ Form: &BPObjectRoleForm, }, }, }, }, }, }, }
View Source
var ObjectRoleForm = forms.Form{ ErrorMsg: "invalid data encountered in the object role form", Fields: []forms.Field{ { Name: "organization_role", Validators: []forms.Validator{ forms.IsRequired{}, forms.IsString{MinLength: 2, MaxLength: 100}, forms.MatchesRegex{Regex: regexp.MustCompile(`^[\w\d\-\:\.]{2,100}$`)}, }, }, { Name: "role", Validators: []forms.Validator{ forms.IsRequired{}, forms.IsString{}, forms.IsIn{Choices: []interface{}{"superuser", "admin", "viewer"}}, }, }, }, }
View Source
var OrganizationForm = forms.Form{ ErrorMsg: "invalid data encountered in the organization form", Fields: []forms.Field{ { Name: "name", Validators: append([]forms.Validator{ forms.IsRequired{}}, kodex.NameValidators...), }, { Name: "description", Validators: append([]forms.Validator{ forms.IsOptional{Default: ""}}, kodex.DescriptionValidators...), }, { Name: "data", Validators: []forms.Validator{forms.IsOptional{}, forms.IsStringMap{}}, }, }, }
View Source
var RolesForm = forms.Form{ Fields: []forms.Field{ { Name: "roles", Validators: []forms.Validator{ forms.IsStringList{}, }, }, { Name: "organization", Validators: []forms.Validator{ forms.IsStringMap{ Form: &BPOrganizationForm, }, }, }, }, }
View Source
var UserForm = forms.Form{ Fields: []forms.Field{ { Name: "source", Validators: []forms.Validator{ forms.IsOptional{Default: "inMemory"}, forms.IsIn{Choices: []interface{}{"inMemory"}}, }, }, { Name: "email", Validators: []forms.Validator{ forms.IsOptional{}, forms.IsString{}, }, }, { Name: "displayName", Validators: []forms.Validator{ forms.IsOptional{}, forms.IsString{}, }, }, { Name: "superuser", Validators: []forms.Validator{ forms.IsOptional{Default: false}, forms.IsBoolean{}, }, }, { Name: "accessToken", Validators: []forms.Validator{ forms.IsStringMap{ Form: &AccessTokenForm, }, }, }, { Name: "roles", Validators: []forms.Validator{ forms.IsList{ Validators: []forms.Validator{ forms.IsStringMap{ Form: &RolesForm, }, }, }, }, }, }, }
Functions ¶
func FormatError ¶
func FormatError(err error) interface{}
Types ¶
type APIControllerDefinitions ¶
type APIControllerDefinitions map[string]APIControllerMaker
type APIControllerMaker ¶
type APIControllerMaker func( config map[string]interface{}, baseController kodex.Controller, definitions *Definitions) (Controller, error)
type APIPlugin ¶
type APIPlugin interface { InitializeAPI(*gin.RouterGroup, Controller, kodex.Meter) error InitializeAdaptors(map[string]ObjectAdaptor) error }
type AccessToken ¶
func MakeAccessToken ¶
func MakeAccessToken(scopes []string) *AccessToken
type AssociateAdaptor ¶
type BaseController ¶
type BaseController struct { Definitions_ *Definitions UserProvider_ UserProvider Self Controller }
func (*BaseController) APIDefinitions ¶
func (b *BaseController) APIDefinitions() *Definitions
func (*BaseController) ObjectRolesForUser ¶
func (b *BaseController) ObjectRolesForUser(objectType string, user *User) ([]ObjectRole, error)
func (*BaseController) RegisterAPIPlugin ¶
func (b *BaseController) RegisterAPIPlugin(plugin APIPlugin) error
func (*BaseController) UserProvider ¶
func (b *BaseController) UserProvider() UserProvider
type BaseObjectRole ¶
type BaseObjectRole struct {
Self ObjectRole
}
BaseObjectRole contains useful common functionality that should be shared by all implementations of the interface, such as validation.
func (*BaseObjectRole) Create ¶
func (b *BaseObjectRole) Create(values map[string]interface{}) error
func (*BaseObjectRole) MarshalJSON ¶
func (b *BaseObjectRole) MarshalJSON() ([]byte, error)
func (*BaseObjectRole) Type ¶
func (b *BaseObjectRole) Type() string
func (*BaseObjectRole) Update ¶
func (b *BaseObjectRole) Update(values map[string]interface{}) error
type BaseOrganization ¶
type BaseOrganization struct { Self Organization Controller_ Controller }
func (*BaseOrganization) Controller ¶
func (b *BaseOrganization) Controller() Controller
func (*BaseOrganization) Create ¶
func (b *BaseOrganization) Create(values map[string]interface{}) error
func (*BaseOrganization) MarshalJSON ¶
func (b *BaseOrganization) MarshalJSON() ([]byte, error)
func (*BaseOrganization) Type ¶
func (b *BaseOrganization) Type() string
func (*BaseOrganization) Update ¶
func (b *BaseOrganization) Update(values map[string]interface{}) error
type Blueprint ¶
type Blueprint struct {
// contains filtered or unexported fields
}
func MakeBlueprint ¶
func (*Blueprint) Create ¶
func (b *Blueprint) Create(controller Controller) error
type Controller ¶
type Controller interface { kodex.Controller KodexController() kodex.Controller RegisterAPIPlugin(APIPlugin) error APIDefinitions() *Definitions // User provider UserProvider() UserProvider // Object roles CanAccess(user *User, object kodex.Model, objectRoles []string) (bool, error) ObjectRole(id []byte) (ObjectRole, error) RolesForObject(object kodex.Model) ([]ObjectRole, error) ObjectRolesForUser(objectType string, user *User) ([]ObjectRole, error) ObjectRolesForOrganizationRoles(objectType string, organizationRoles []string, organizationID []byte) ([]ObjectRole, error) MakeObjectRole(object kodex.Model, organization Organization) ObjectRole // Organizations MakeOrganization() Organization Organization(source string, sourceID []byte) (Organization, error) Organizations(filters map[string]interface{}) ([]Organization, error) }
type CreateObjectAdaptor ¶
type CreateUserProvider ¶
type Definitions ¶
type Definitions struct { kodex.Definitions APIControllerDefinitions APIControllerDefinitions Routes []Routes ObjectAdaptors map[string]ObjectAdaptor AssociateAdaptors map[string]AssociateAdaptor UserProviders map[string]UserProviderDefinition }
func MergeDefinitions ¶
func MergeDefinitions(a, b Definitions) Definitions
func (Definitions) Marshal ¶
func (d Definitions) Marshal() map[string]interface{}
func (Definitions) MarshalJSON ¶
func (d Definitions) MarshalJSON() ([]byte, error)
type ListAllObjectAdaptor ¶
type ObjectAdaptor ¶
type ObjectRole ¶
type ObjectRoleSpec ¶
type Organization ¶
type OrganizationRoles ¶
type OrganizationRoles struct { Roles []string `json:"roles"` Organization *UserOrganization `json:"organization"` }
func MakeOrganizationRoles ¶
func MakeOrganizationRoles(org *UserOrganization, roles []string) *OrganizationRoles
type Routes ¶
type Routes func(*gin.RouterGroup, Controller, kodex.Meter) error
type Settings ¶
type Settings struct {
UserProvider *UserProviderSettings `json:"userProvider"`
}
type SettingsValidator ¶
type UpdateObjectAdaptor ¶
type User ¶
type User struct { Source string `json:"source"` SourceID []byte `json:"sourceID"` EMail string `json:"email"` DisplayName string `json:"displayName"` Superuser bool `json:"superuser"` AccessToken *AccessToken `json:"accessToken"` Roles []*OrganizationRoles `json:"roles"` Limits map[string]interface{} `json:"limits"` }
func MakeUser ¶
func MakeUser(source, email string, superuser bool, roles []*OrganizationRoles, limits map[string]interface{}, token *AccessToken) *User
type UserOrganization ¶
type UserOrganization struct { Source string `json:"source"` Name string `json:"name"` Default bool `json:"default"` Description string `json:"description"` ID []byte `json:"id"` // contains filtered or unexported fields }
func MakeUserOrganization ¶
func MakeUserOrganization(source, name, description string, id []byte) *UserOrganization
func (*UserOrganization) ApiOrganization ¶
func (i *UserOrganization) ApiOrganization(controller Controller) (Organization, error)
type UserProvider ¶
type UserProviderDefinition ¶
type UserProviderDefinition struct { Name string `json:"name"` Description string `json:"description"` Maker UserProviderMaker `json:"-"` SettingsValidator SettingsValidator `json:"-"` }
type UserProviderDefinitions ¶
type UserProviderDefinitions map[string]UserProviderDefinition
type UserProviderMaker ¶
type UserProviderMaker func(settings kodex.Settings) (UserProvider, error)
type UserProviderSettings ¶
type UserProviderSettings struct { Type string `json:"type"` Settings interface{} `json:"settings"` }
type UsersAndRoles ¶
type UsersAndRoles struct { Users []*User `json:"users"` Roles []*ObjectRoleSpec `json:"roles"` }
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
resources/pcap/pcapgo
Package pcapgo provides some native PCAP support, not requiring C libpcap to be installed.
|
Package pcapgo provides some native PCAP support, not requiring C libpcap to be installed. |
Click to show internal directories.
Click to hide internal directories.