Documentation ¶
Overview ¶
Package types contains generic definitions for working with policies.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MapFromAttributes ¶
func MapFromAttributes(in AttributeSet) map[string]any
MapFromAttributes returns a standard map from the given attribute set.
Types ¶
type Attribute ¶
Attribute is a convenience type to represent a single attribute.
type AttributeIterator ¶
AttributeIterator is the function prototype to iterate through a set of attributes.
type AttributeSet ¶
type AttributeSet interface { AddAttribute(key string, value any) // add or replace an attribute. GetAttribute(key string) any // retrieve an attribute. RemoveAttribute(key string) // remove an attribute. IterateAttributes(f AttributeIterator) // iterate through all attributes. MergeAttributes(in ...AttributeSet) // merge the given attribute sets into this one. }
AttributeSet represents the interface to work with a set of attributes.
An implementation must take care to protect against simultaneous use from concurrent go-routines.
func NewAttributeSet ¶
func NewAttributeSet(in ...any) AttributeSet
NewAttributeSet instantiates a new set of attributes.
It matches the AttributesBuilder function signature.
The given attribute sets will be copied into the returned new attribute set. Duplicate keys from an input set will overwrite the previous value. E.g. only the last value with the duplicate key will be retained.
type AttributesBuilder ¶
type AttributesBuilder func(in ...any) AttributeSet
AttributesBuilder is the function prototype for creating a new set of attributes.
type EntitiesBuilder ¶
EntitiesBuilder is the function prototype for creating a new set of entities.
type Entity ¶
type Entity interface { UID() string // retrieve the Unique ID (UID) of the entity. Type() string // retrieve the Type of the entity (e,g, name-space). ID() string // retrieve the ID of the entity (unique ID within the name-space). Attributes() AttributeSet // retrieve attributes of the entity. Parents() []string // retrieve unique identifiers (UID) of parent entities. }
Entity represents the interface to work with the details of an entity.
An Entity is a read-only object and does not require protection against simultaneous use from concurrent go-routines.
func NewEntity ¶
func NewEntity(ns, id string, attrs AttributeSet, parents ...string) Entity
NewEntity instanties a new standard entity.
type EntityIterator ¶
type EntityIterator func(entity Entity)
EntityIterator is the function prototype to iterate through a set of entities.
type EntitySet ¶
type EntitySet interface { AddEntity(entity Entity) // add or replace an entity. GetEntity(uid string) Entity // retrieve an entity. RemoveEntity(uid string) // remove an entity. IterateEntities(f EntityIterator) // iterate through all entities. MergeEntities(in ...EntitySet) // merge the given entity sets into this one. }
EntitySet represents the interface to work with a set of entities.
An implementation must take care to protect against simultaneous use from concurrent go-routines.
func NewEntitySet ¶
NewEntitySet instantiates a new standard set of attributes.
It matches the EntitiesBuilder function signature.
Input parameters should be of type Entity or EntitySet! Other types of parameters are ignored.
The given entities and/or entity-sets will be copied into the returned new attribute-set. Duplicate keys from an input set will overwrite the previous value. E.g. only the last value with the duplicate key will be retained.
type Format ¶
type Format uint8
Format represents the format for policy files.
ListAllKeys of supported policy file formats.
Note that the policy language (Language) limits the choices for the file format of a policy.
func FormatFromString ¶
FormatFromString returns the corresponding Format type from the given input.
type Language ¶
type Language uint8
Language represents a policy language.
func LanguageFromString ¶
LanguageFromString returns the corresponding Language type from the given input.
type Request ¶
type Request struct { UID *uuid.UUID `json:"uid,omitempty"` URL *url.URL `json:"url,omitempty"` Method string `json:"method,omitempty"` RequestTime *time.Time `json:"requestTime,omitempty"` Headers map[string][]string `json:"headers,omitempty"` Body []byte `json:"body,omitempty"` Attributes map[string]any `json:"attributes,omitempty"` }
Request contains the details of an HTTP request required for access control.
type Response ¶
type Response struct { Allowed bool `json:"allowed,omitempty"` Message string `json:"message,omitempty"` NewURL *url.URL `json:"newURL,omitempty"` NewBody []byte `json:"newBody,omitempty"` Attributes map[string]any `json:"attributes,omitempty"` PolicyKey string `json:"policyKey,omitempty"` PolicyHash string `json:"policyHash,omitempty"` }
Response contains the result of an access control request.