models

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorReadingBody = errors.New("failed to read message body")
	ErrorParsingBody = errors.New("failed to parse json body")
)

A list of errors returned from package

Functions

This section is empty.

Types

type Bundle added in v0.5.0

type Bundle map[string]EntityIDToPolicies

Bundle is the optimised lookup table for permissions.

type BundlePolicy added in v0.5.0

type BundlePolicy struct {
	ID         string      `bson:"_id"          json:"id,omitempty"`
	Entities   []string    `bson:"entities"   json:"-"`
	Role       string      `bson:"role"      json:"-"`
	Conditions []Condition `bson:"conditions" json:"conditions,omitempty"`
}

BundlePolicy represents a policy tailored for the permissions bundle. The permissions bundle json does not include the entities and role fields.

type Condition added in v0.5.0

type Condition struct {
	Attributes []string `bson:"attributes"          json:"attributes"`
	Operator   string   `bson:"operator"          json:"operator"`
	Values     []string `bson:"Values"          json:"values"`
}

type EntityIDToPolicies added in v0.5.0

type EntityIDToPolicies map[string][]*BundlePolicy

EntityIDToPolicies maps an entity ID to a slice of policies.

type NewPolicy added in v0.5.0

type NewPolicy struct {
	Entities   []string    `json:"entities"`
	Role       string      `json:"role"`
	Conditions []Condition `json:"conditions,omitempty"`
}

func CreateNewPolicy added in v0.5.0

func CreateNewPolicy(reader io.Reader) (*NewPolicy, error)

CreateNewPolicy manages the creation of a filter from reader

func (*NewPolicy) ValidateNewPolicy added in v0.5.0

func (policy *NewPolicy) ValidateNewPolicy() error

ValidateNewPolicy checks that all the mandatory fields are non-empty

type Policy added in v0.5.0

type Policy struct {
	ID         string      `bson:"_id"          json:"id,omitempty"`
	Entities   []string    `bson:"entities"   json:"entities"`
	Role       string      `bson:"role"      json:"role"`
	Conditions []Condition `bson:"conditions" json:"conditions,omitempty"`
}

type Role

type Role struct {
	ID          string   `bson:"_id" json:"id"`
	Name        string   `bson:"name" json:"name"`
	Permissions []string `bson:"permissions" json:"permissions"`
}

Role represents the structure for a role

type Roles

type Roles struct {
	Count      int    `json:"count"`
	Offset     int    `json:"offset"`
	Limit      int    `json:"limit"`
	Items      []Role `json:"items"`
	TotalCount int    `json:"total_count"`
}

Roles represents an array of the role model

Jump to

Keyboard shortcuts

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