policies

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2023 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Overview

The keys module containing the keys CRUD operation and relationship CRUD

hcl.go: Policy HCL Parser

models.go: definition of orm based data model

routers.go: router binding and core logic

serializers.go: definition the schema of return data

validators.go: definition the validator of form data

Index

Constants

View Source
const (
	DenyCapability   = "deny"
	CreateCapability = "create"
	ReadCapability   = "read"
	UpdateCapability = "update"
	DeleteCapability = "delete"
	ListCapability   = "list"
	SudoCapability   = "sudo"
	RootCapability   = "root"
	PatchCapability  = "patch"
)
View Source
const (
	DenyCapabilityInt uint32 = 1 << iota
	CreateCapabilityInt
	ReadCapabilityInt
	UpdateCapabilityInt
	DeleteCapabilityInt
	ListCapabilityInt
	SudoCapabilityInt
	PatchCapabilityInt
)

Variables

This section is empty.

Functions

func DeletePolicyModel

func DeletePolicyModel(condition interface{}) error

func GetCapabilitiesFromBitmap

func GetCapabilitiesFromBitmap(bitmap uint32) map[string]bool

func PolicyCreateOrUpdate

func PolicyCreateOrUpdate(c *gin.Context)

func PolicyDelete

func PolicyDelete(c *gin.Context)

func PolicyList

func PolicyList(c *gin.Context)

func PolicyRegister

func PolicyRegister(router *gin.RouterGroup)

func PolicyRetrieve

func PolicyRetrieve(c *gin.Context)

func SaveOne

func SaveOne(data interface{}) error

func SeedDB

func SeedDB(c *common.Config) error

Function executed if DB is just created

Types

type ACLPermissions

type ACLPermissions struct {
	CapabilitiesBitmap uint32
	AllowedParameters  map[string][]interface{}
	DeniedParameters   map[string][]interface{}
	RequiredParameters []string
}

type HCLPolicy

type HCLPolicy struct {
	Name  string                `hcl:"name"`
	Paths []*HCLPolicyPathRules `hcl:"-"`
	Raw   string
}

func ParseHCLPolicy

func ParseHCLPolicy(src string) (*HCLPolicy, error)

type HCLPolicyPathRules

type HCLPolicyPathRules struct {
	Path                string
	Policy              string
	Permissions         *ACLPermissions
	IsPrefix            bool
	HasSegmentWildcards bool
	Capabilities        []string
}

type PoliciesResponse

type PoliciesResponse struct {
	Policies []string `json:"keys"`
}

type PoliciesSerializer

type PoliciesSerializer struct {
	C        *gin.Context
	Policies []PolicyModel
}

func (*PoliciesSerializer) Response

func (s *PoliciesSerializer) Response() PoliciesResponse

type PolicyModel

type PolicyModel struct {
	gorm.Model
	Name string `gorm:"column:name,unique_index"`
	Text string `gorm:"column:text,size:4096"`
}

func FindManyPolicies

func FindManyPolicies() ([]PolicyModel, int64, error)

func FindOnePolicy

func FindOnePolicy(condition interface{}) (PolicyModel, error)

func NewDefaultPolicy

func NewDefaultPolicy() *PolicyModel

func NewRootPolicy

func NewRootPolicy() *PolicyModel

func (*PolicyModel) Update

func (p *PolicyModel) Update(data interface{}) error

type PolicyModelValidator

type PolicyModelValidator struct {
	Name string `json:"-"`
	Text string `form:"policy" json:"policy"`
	// contains filtered or unexported fields
}

func NewPolicyModelValidator

func NewPolicyModelValidator() PolicyModelValidator

func NewPolicyModelValidatorFillWith

func NewPolicyModelValidatorFillWith(policyModel PolicyModel) PolicyModelValidator

func (*PolicyModelValidator) Bind

func (s *PolicyModelValidator) Bind(c *gin.Context) error

type PolicyResponse

type PolicyResponse struct {
	ID   uint   `json:"-"`
	Name string `json:"name"`
	Text string `json:"policy"`
}

type PolicySerializer

type PolicySerializer struct {
	C *gin.Context
	PolicyModel
}

func (*PolicySerializer) Response

func (s *PolicySerializer) Response() PolicyResponse

Jump to

Keyboard shortcuts

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