Documentation ¶
Index ¶
- Variables
- func EncodeString(s string) string
- func Exists(file string) bool
- func GetEnv() string
- func ReadFile(file string, obj interface{}) ([]byte, error)
- func ReadFileLines(file string) ([]string, error)
- func WriteFile(file string, obj interface{}) error
- type Acl
- type AclConfig
- type AclOption
- type Allowed
- type AppConfig
- type Categories
- type Category
- type CheckAclMiddleware
- type CheckEndpointAccessRequest
- type CheckEndpointAccessResponse
- type Controller
- func (c *Controller) CheckEndpointAccessHandler(ctx *web.Context) error
- func (c *Controller) DummyHandler(ctx *web.Context) error
- func (c *Controller) GetResourceCategoriesHandler(ctx *web.Context) error
- func (c *Controller) GetResourceCategoryPageHandler(ctx *web.Context) error
- func (c *Controller) GetResourceCategoryPagesHandler(ctx *web.Context) error
- func (c *Controller) GetResourcesByTypeHandler(ctx *web.Context) error
- func (c *Controller) GetResourcesHandler(ctx *web.Context) error
- func (c *Controller) MiddlewareAcl() web.MiddlewareFunc
- func (c *Controller) RegisterRoutes(w manager.IWeb) error
- type ErrorResponse
- type GetPageResourcesByTypeRequest
- type GetPageResourcesRequest
- type GetResourceCategoriesRequest
- type GetResourceCategoryPageRequest
- type GetResourceCategoryPagesRequest
- type IStorageDB
- type Interactor
- func (i *Interactor) CheckAcl(request *CheckAclMiddleware) (bool, error)
- func (i *Interactor) CheckEndpointAccess(request *CheckEndpointAccessRequest) (bool, error)
- func (i *Interactor) GetPageResources(request *GetPageResourcesRequest) (Resources, error)
- func (i *Interactor) GetResourceCategories(request *GetResourceCategoriesRequest) (Categories, error)
- func (i *Interactor) GetResourceCategoryPage(request *GetResourceCategoryPageRequest) (*Page, error)
- func (i *Interactor) GetResourceCategoryPages(request *GetResourceCategoryPagesRequest) (Pages, error)
- func (i *Interactor) GetResourcesByType(request *GetPageResourcesByTypeRequest) (Resources, error)
- type Page
- type Pages
- type Resource
- type Resources
- type StoragePostgres
- func (storage *StoragePostgres) CheckEndpointAccess(roleKey, resourceTypeKey, method, endpoint, idUser string) (bool, error)
- func (storage *StoragePostgres) GetPageResources(roleKey, resourcePageKey, idUser string) (Resources, error)
- func (storage *StoragePostgres) GetPageResourcesByType(roleKey, resourcePageKey, resourceTypeKey, idUser string) (Resources, error)
- func (storage *StoragePostgres) GetResourceCategories(domainKey string) (Categories, error)
- func (storage *StoragePostgres) GetResourceCategoryPage(domainKey, resourcePageKey string) (*Page, error)
- func (storage *StoragePostgres) GetResourceCategoryPages(domainKey, resourceCategoryKey string) (Pages, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrorGeneric = errors.New(errors.LevelError, int(web.StatusForbidden), "%s") ErrorAclAccessDenied = errors.New(errors.LevelError, int(web.StatusForbidden), "acl access denied") )
Functions ¶
func EncodeString ¶
func ReadFileLines ¶
Types ¶
type AclConfig ¶
type AclConfig struct { Host string `json:"host"` Dbr *dbr.DbrConfig `json:"dbr"` TokenKey string `json:"token_key"` ExpirationMinutes int64 `json:"expiration_minutes"` Migration *migration.MigrationConfig `json:"migration"` Log struct { Level string `json:"level"` } `json:"log"` }
AclConfig ...
type Categories ¶
type Categories []*Category
type Category ¶
type Category struct { Name string `json:"name" db:"name"` Key string `json:"key" db:"key"` Description string `json:"description" db:"description"` ParentResourceCategoryKey *string `json:"parent_resource_category_key,omitempty" db:"parent_resource_category_key"` Active bool `json:"active" db:"active"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` }
type CheckAclMiddleware ¶
type CheckAclMiddleware struct { Method string `json:"method" validate:"notzero"` Endpoint string `json:"endpoint" validate:"notzero"` Params struct { RoleKey string `json:"role_key" validate:"notzero"` ResourceTypeKey string `json:"resource_type_key" validate:"notzero"` User string `json:"user" validate:"notzero"` } }
type CheckEndpointAccessRequest ¶
type CheckEndpointAccessRequest struct { UrlParams struct { RoleKey string `json:"role_key" validate:"notzero"` ResourceTypeKey string `json:"resource_type_key" validate:"notzero"` } Params struct { Method string `json:"method" validate:"notzero"` Endpoint string `json:"endpoint" validate:"notzero"` User string `json:"user" validate:"notzero"` } }
type CheckEndpointAccessResponse ¶
type CheckEndpointAccessResponse struct {
IsAllowed bool `json:"is_allowed"`
}
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
func NewController ¶
func NewController(config *AclConfig, interactor *Interactor) *Controller
func (*Controller) CheckEndpointAccessHandler ¶
func (c *Controller) CheckEndpointAccessHandler(ctx *web.Context) error
func (*Controller) DummyHandler ¶
func (c *Controller) DummyHandler(ctx *web.Context) error
func (*Controller) GetResourceCategoriesHandler ¶
func (c *Controller) GetResourceCategoriesHandler(ctx *web.Context) error
func (*Controller) GetResourceCategoryPageHandler ¶
func (c *Controller) GetResourceCategoryPageHandler(ctx *web.Context) error
func (*Controller) GetResourceCategoryPagesHandler ¶
func (c *Controller) GetResourceCategoryPagesHandler(ctx *web.Context) error
func (*Controller) GetResourcesByTypeHandler ¶
func (c *Controller) GetResourcesByTypeHandler(ctx *web.Context) error
func (*Controller) GetResourcesHandler ¶
func (c *Controller) GetResourcesHandler(ctx *web.Context) error
func (*Controller) MiddlewareAcl ¶
func (c *Controller) MiddlewareAcl() web.MiddlewareFunc
func (*Controller) RegisterRoutes ¶
func (c *Controller) RegisterRoutes(w manager.IWeb) error
type ErrorResponse ¶
type GetPageResourcesByTypeRequest ¶
type GetPageResourcesByTypeRequest struct { UrlParams struct { RoleKey string `json:"role_key" validate:"notzero"` ResourcePageKey string `json:"resource_page_key" validate:"notzero"` ResourceTypeKey string `json:"resource_type_key" validate:"notzero"` } Params struct { User string `json:"user" validate:"notzero"` } }
type GetPageResourcesRequest ¶
type GetResourceCategoriesRequest ¶
type GetResourceCategoriesRequest struct {
DomainKey string `json:"domain_key" validate:"notzero"`
}
type IStorageDB ¶
type IStorageDB interface { GetResourceCategories(domainKey string) (Categories, error) GetResourceCategoryPages(domainKey, resourceCategoryKey string) (Pages, error) GetResourceCategoryPage(domainKey, resourcePageKey string) (*Page, error) GetPageResources(roleKey, resourcePageKey, user string) (Resources, error) GetPageResourcesByType(roleKey, resourcePageKey string, resourceTypeKey, user string) (Resources, error) CheckEndpointAccess(roleKey, resourceTypeKey, method, endpoint, user string) (isAllowed bool, err error) }
type Interactor ¶
type Interactor struct {
// contains filtered or unexported fields
}
func NewInteractor ¶
func NewInteractor(config *AclConfig, storageDB IStorageDB) *Interactor
func (*Interactor) CheckAcl ¶
func (i *Interactor) CheckAcl(request *CheckAclMiddleware) (bool, error)
func (*Interactor) CheckEndpointAccess ¶
func (i *Interactor) CheckEndpointAccess(request *CheckEndpointAccessRequest) (bool, error)
func (*Interactor) GetPageResources ¶
func (i *Interactor) GetPageResources(request *GetPageResourcesRequest) (Resources, error)
func (*Interactor) GetResourceCategories ¶
func (i *Interactor) GetResourceCategories(request *GetResourceCategoriesRequest) (Categories, error)
func (*Interactor) GetResourceCategoryPage ¶
func (i *Interactor) GetResourceCategoryPage(request *GetResourceCategoryPageRequest) (*Page, error)
func (*Interactor) GetResourceCategoryPages ¶
func (i *Interactor) GetResourceCategoryPages(request *GetResourceCategoryPagesRequest) (Pages, error)
func (*Interactor) GetResourcesByType ¶
func (i *Interactor) GetResourcesByType(request *GetPageResourcesByTypeRequest) (Resources, error)
type Page ¶
type Page struct { Name string `json:"name" db:"name"` Key string `json:"key" db:"key"` Description string `json:"description" db:"description"` ParentResourcePageKey *string `json:"parent_resource_page_key,omitempty" db:"parent_resource_page_key"` Active bool `json:"active" db:"active"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` }
type Resource ¶
type Resource struct { Name string `json:"name" db:"name"` Key string `json:"key" db:"key"` ResourceCategoryKey string `json:"resource_category_key" db:"resource_category_key"` ResourcePageKey string `json:"resource_page_key" db:"resource_page_key"` ResourceTypeKey string `json:"resource_type_key" db:"resource_type_key"` Description string `json:"description" db:"description"` Active bool `json:"active" db:"active"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` }
type StoragePostgres ¶
type StoragePostgres struct {
// contains filtered or unexported fields
}
func NewStoragePostgres ¶
func NewStoragePostgres(config *AclConfig) (*StoragePostgres, error)
func (*StoragePostgres) CheckEndpointAccess ¶
func (storage *StoragePostgres) CheckEndpointAccess(roleKey, resourceTypeKey, method, endpoint, idUser string) (bool, error)
func (*StoragePostgres) GetPageResources ¶
func (storage *StoragePostgres) GetPageResources(roleKey, resourcePageKey, idUser string) (Resources, error)
func (*StoragePostgres) GetPageResourcesByType ¶
func (storage *StoragePostgres) GetPageResourcesByType(roleKey, resourcePageKey, resourceTypeKey, idUser string) (Resources, error)
func (*StoragePostgres) GetResourceCategories ¶
func (storage *StoragePostgres) GetResourceCategories(domainKey string) (Categories, error)
func (*StoragePostgres) GetResourceCategoryPage ¶
func (storage *StoragePostgres) GetResourceCategoryPage(domainKey, resourcePageKey string) (*Page, error)
func (*StoragePostgres) GetResourceCategoryPages ¶
func (storage *StoragePostgres) GetResourceCategoryPages(domainKey, resourceCategoryKey string) (Pages, error)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.