azm

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

README

azm

Authorization Model

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrModelNodeNotFound     = cerr.NewAsertoError("E10000", codes.NotFound, http.StatusNotFound, "manifest does not contain a model node")
	ErrSchemaVersionNotFound = cerr.NewAsertoError("E10001", codes.NotFound, http.StatusNotFound, "manifest does not contain a model.version field")
	ErrInvalidSchemaVersion  = cerr.NewAsertoError("E10002", codes.InvalidArgument, http.StatusBadRequest, "invalid or unsupported schema version")
)

Functions

This section is empty.

Types

type Exclusion

type Exclusion struct {
	Base     string `json:"base"`
	Subtract string `json:"subtract"`
}

type Model

type Model struct {
	ObjectTypes map[string]*ObjectType `json:"object_types"`
	Permissions map[string]struct{}    `json:"permissions"`
	// contains filtered or unexported fields
}

func NewModel

func NewModel() *Model

func (*Model) Dump

func (c *Model) Dump(filepath string)

Dump serializes the model cache to a JSON file, used for validation and testing.

func (*Model) ExpandPermission

func (c *Model) ExpandPermission(objectType, permission string) []string

ExpandPermission returns list of relations which cover the given permission for the given object type.

func (*Model) ExpandRelation

func (c *Model) ExpandRelation(objectType, relation string) []string

ExpandRelation, returns list of relations which are a union of the given relation. For example, when a writer relation inherits reader, the expansion of a reader = reader + writer.

func (*Model) GetObjectType

func (c *Model) GetObjectType(objectType string) (*dsc2.ObjectType, error)

GetObjectType, v2 backwards-compatibility accessor function, returns v2 ObjectType by name.

func (*Model) GetObjectTypes

func (c *Model) GetObjectTypes() ([]*dsc2.ObjectType, error)

GetObjectTypes, v2 backwards-compatibility accessor function, returns list of v2.ObjectType instances.

func (*Model) GetPermission

func (c *Model) GetPermission(permission string) (*dsc2.Permission, error)

GetPermission, v2 backwards-compatibility accessor function, returns v2 Permission by permission name.

func (*Model) GetPermissions

func (c *Model) GetPermissions() ([]*dsc2.Permission, error)

GetPermissions, v2 backwards-compatibility accessor function, returns list of v2 Permission instances.

func (*Model) GetRelationType

func (c *Model) GetRelationType(objectType, relation string) (*dsc2.RelationType, error)

GetRelationType, v2 backwards-compatibility accessor function, returns v2 RelationType by object type and relation name.

func (*Model) GetRelationTypes

func (c *Model) GetRelationTypes(objectType string) ([]*dsc2.RelationType, error)

GetRelationTypes, v2 backwards-compatibility accessor function, returns list of v2 RelationType instances, optionally filtered by by object type.

func (*Model) ObjectTypeExists

func (c *Model) ObjectTypeExists(ot string) bool

ObjectTypeExists, checks if given object type name exists in the model cache.

func (*Model) PermissionExists

func (c *Model) PermissionExists(ot, p string) bool

PermissionExists, checks if given permission, for the given object type, exists in the model cache.

func (*Model) RelationTypeExists

func (c *Model) RelationTypeExists(ot, rt string) bool

RelationTypeExists, checks if given relation type, for the given object type, exists in the model cache.

func (*Model) SetObjectTypes

func (c *Model) SetObjectTypes(objectTypes map[string]*ObjectType)

func (*Model) SetPermissions

func (c *Model) SetPermissions(permissions map[string]struct{})

type ObjectType

type ObjectType struct {
	RelationTypes map[string]*RelationType `json:"relation_types,omitempty"`
	Permissions   map[string]*RelationType `json:"permissions,omitempty"`
}

type RelationType

type RelationType struct {
	Union     map[string]struct{} `json:"union,omitempty"`     // OR
	Intersect map[string]struct{} `json:"intersect,omitempty"` // AND
	Exclude   *Exclusion          `json:"exclude,omitempty"`   // NOT
}

Directories

Path Synopsis
cmd
azmcmd Module

Jump to

Keyboard shortcuts

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