role

package
v0.0.0-...-7ff62be Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDeleteAdminRole = errors.New("admin cannot be deleted")
View Source
var ErrLinkedToUser = errors.New("role is linked to user")
View Source
var ErrUpdateAdminRole = errors.New("admin cannot be updated")

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,
) 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"`
	Author     string                  `json:"author" swaggerignore:"true"`
}

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"`

	Author  *author.Author    `bson:"author,omitempty" json:"author,omitempty"`
	Created *datetime.CpsTime `bson:"created,omitempty" json:"created,omitempty" swaggertype:"integer"`
	Updated *datetime.CpsTime `bson:"updated,omitempty" json:"updated,omitempty" swaggertype:"integer"`
}

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, userID string) (bool, error)
	GetTemplates(ctx context.Context) ([]Template, error)
}

func NewStore

func NewStore(dbClient mongo.DbClient, authorProvider author.Provider) 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 {
	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