models

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2021 License: MIT Imports: 6 Imported by: 2

Documentation

Index

Constants

View Source
const (
	PoliciesRead   string = "policies:read"
	PoliciesCreate        = "policies:create"
	PoliciesUpdate        = "policies:update"
	PoliciesDelete        = "policies:delete"
)

policies permissions

View Source
const (
	RolesRead   string = "roles:read"
	RolesCreate        = "roles:create"
	RolesUpdate        = "roles:update"
	RolesDelete        = "roles:delete"
)

roles permissions

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

Condition represents the conditions to be applied for a policy

type EntityIDToPolicies added in v0.5.0

type EntityIDToPolicies map[string][]*BundlePolicy

EntityIDToPolicies maps an entity ID to a slice of policies.

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

Policy represent a structure for a policy in DB

type PolicyInfo added in v0.8.0

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

PolicyInfo contains properties required to create or update a policy

func CreatePolicy added in v0.8.0

func CreatePolicy(reader io.Reader) (*PolicyInfo, error)

CreatePolicy manages the creation of a filter from reader

func (*PolicyInfo) GetPolicy added in v0.8.0

func (policy *PolicyInfo) GetPolicy(id string) *Policy

GetPolicy creates a policy object with ID

func (*PolicyInfo) ValidatePolicy added in v0.8.0

func (policy *PolicyInfo) ValidatePolicy() error

ValidatePolicy checks that all the mandatory fields are non-empty

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

type UpdateResult added in v0.8.0

type UpdateResult struct {
	ModifiedCount int
	UpsertedCount int
}

UpdateResult represent a result of the upsert policy

Jump to

Keyboard shortcuts

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