policyInfoModel

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package pim (application Policy Information Model) is used by Hexa tools to validate that a policy is valid for a particular application. The model is based on [Cedar Schema](https://docs.cedarpolicy.com/schema/schema.html).

Index

Constants

View Source
const (
	TypePerson    string = "PersonType"
	TypeRecord    string = "Record"
	TypeSet       string = "Set"
	TypeBool      string = "Bool"
	TypeString    string = "String"
	TypeDate      string = "Date"
	TypeNumeric   string = "Numeric"
	TypeLong      string = "Long"
	TypeExtension string = "Extension"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionType

type ActionType struct {
	MemberOf  []string    `json:"memberOf,omitempty"`
	AppliesTo AppliesType `json:"appliesTo,omitempty"`
}

Action ::= STR ':' '{' [ '"memberOf"' ':' '[' [ STR { ',' STR } ] ']' ] ',' [ '"appliesTo"' ':' '{' PrincipalTypes ',' ResourceTypes ',' [Context] '}' ] '}'

type AppliesType

type AppliesType struct {
	PrincipalTypes *PrincipalTypes `json:"principalTypes,omitempty"`
	ResourceTypes  *ResourceTypes  `json:"resourceTypes,omitempty"`
	Context        *ContextType    `json:"context,omitempty"`
}

type AttrType

type AttrType struct {
	Type     string `json:"type"`
	Name     string `json:"name,omitempty"`
	Required bool   `json:"required"`
	SetType
	RecordType
}

func (AttrType) FindAttrTypes

func (h AttrType) FindAttrTypes(path string, schema SchemaType) *AttrType

type ContextType

type ContextType struct {
	Type       string              `json:"type"` // fixed as "RecordType"
	Attributes map[string]AttrType `json:"attributes"`
}

func (ContextType) FindAttrTypes

func (c ContextType) FindAttrTypes(path string, schema SchemaType) *AttrType

type EntityType

type EntityType struct {
	MemberOfTypes []string   `json:"memberOfTypes,omitempty"`
	Shape         ShapeTypes `json:"shape,omitempty"`
}

EntityType ::= IDENT ':' '{' [ 'memberOfTypes' ':' '[' [ IDENT { ',' IDENT } ] ']' ] ',' [ 'shape': TypeJson ] '}'

func (EntityType) FindAttrType

func (e EntityType) FindAttrType(path string, schema SchemaType) *AttrType

type Namespaces

type Namespaces map[string]SchemaType

func ParseSchemaFile

func ParseSchemaFile(schemaBytes []byte) (*Namespaces, error)

type PrincipalTypes

type PrincipalTypes []string

type RecordType

type RecordType struct {
	Attributes map[string]AttrType `json:"attributes"`
}

type ResourceTypes

type ResourceTypes []string

type SchemaType

type SchemaType struct {
	EntityTypes map[string]EntityType  `json:"entityTypes,omitempty"`
	Actions     map[string]ActionType  `json:"actions,omitempty"`
	CommonTypes map[string]ContextType `json:"commonTypes,omitempty"`
}

func (SchemaType) FindAttrType

func (s SchemaType) FindAttrType(entity hexaTypes.Entity) *AttrType

FindAttrType locates an AttrType definition by using the path format: <entityType>:<attr>.<subAttribute>

type SetType

type SetType struct {
	Element *AttrType `json:"element"`
}

type ShapeTypes

type ShapeTypes struct {
	Type       string              `json:"type"`
	Attributes map[string]AttrType `json:"attributes"`
}

func (ShapeTypes) FindAttrType

func (s ShapeTypes) FindAttrType(path string, schema SchemaType) *AttrType

Jump to

Keyboard shortcuts

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