role

package
v0.0.0-...-9b5cd94 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2024 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrLinkedToUser = errors.New("role is linked to user")

Functions

func TransformBitmaskToActions

func TransformBitmaskToActions(bitmask int64, permType string) []string

Types

type API

type API interface {
	common.CrudAPI
	ListTemplates(c *gin.Context)
}

func NewApi

func NewApi(
	store Store,
	actionLogger logger.ActionLogger,
) API

type AggregationResult

type AggregationResult struct {
	Data       []Response `bson:"data" json:"data"`
	TotalCount int64      `bson:"total_count" json:"total_count"`
}

func (*AggregationResult) GetData

func (r *AggregationResult) GetData() interface{}

func (*AggregationResult) GetTotal

func (r *AggregationResult) GetTotal() int64

type CreateRequest

type CreateRequest struct {
	EditRequest
	Name string `json:"name" binding:"required,max=255"`
}

type EditRequest

type EditRequest struct {
	Description string              `json:"description" binding:"max=255"`
	DefaultView string              `json:"defaultview"`
	Permissions map[string][]string `json:"permissions"`

	AuthConfig security.AuthMethodConf `json:"auth_config"`
}

type ListRequest

type ListRequest struct {
	pagination.FilteredQuery
	SortBy     string `form:"sort_by" binding:"oneoforempty=name"`
	Permission string `form:"permission"`
}

type Permission

type Permission struct {
	ID          string   `bson:"_id" json:"_id"`
	Name        string   `bson:"name" json:"name"`
	Description string   `bson:"description" json:"description"`
	Type        string   `bson:"type" json:"type"`
	Bitmask     int64    `bson:"bitmask" json:"-"`
	Actions     []string `bson:"actions" json:"actions"`
}

type Response

type Response struct {
	ID          string       `bson:"_id" json:"_id"`
	Name        string       `bson:"name" json:"name"`
	Description string       `bson:"description" json:"description"`
	DefaultView *View        `bson:"defaultview" json:"defaultview"`
	Permissions []Permission `bson:"permissions" json:"permissions"`
	Editable    *bool        `bson:"editable,omitempty" json:"editable,omitempty"`
	Deletable   *bool        `bson:"deletable,omitempty" json:"deletable,omitempty"`

	AuthConfig security.AuthMethodConf `bson:"auth_config" json:"auth_config"`
}

type Store

type Store interface {
	Find(ctx context.Context, r ListRequest) (*AggregationResult, error)
	GetOneBy(ctx context.Context, id string) (*Response, error)
	Insert(ctx context.Context, r CreateRequest) (*Response, error)
	Update(ctx context.Context, id string, r EditRequest) (*Response, error)
	Delete(ctx context.Context, id string) (bool, error)
	GetTemplates(ctx context.Context) ([]Template, error)
}

func NewStore

func NewStore(dbClient mongo.DbClient) Store

type Template

type Template struct {
	ID          string       `bson:"_id" json:"_id"`
	Name        string       `bson:"name" json:"name"`
	Description string       `bson:"description" json:"description"`
	Permissions []Permission `bson:"permissions" json:"permissions"`
}

type TemplateResponse

type TemplateResponse struct {
	Data []Template `json:"data"`
}

type Validator

type Validator interface {
	ValidateCreateRequest(ctx context.Context, sl validator.StructLevel)
	ValidateEditRequest(ctx context.Context, sl validator.StructLevel)
}

func NewValidator

func NewValidator(dbClient mongo.DbClient) Validator

type View

type View struct {
	ID    string `bson:"_id" json:"_id"`
	Title string `bson:"title" json:"title"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL