Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoContent = errors.New("no such content") ErrNoAccess = errors.New("no such access") )
Possible errors ErrNoContent in case there is no such content in the policy ErrNoAccess in case there is no such access in the policy(s)
Functions ¶
func MapFill ¶
func MapFill[M ~map[K]V, K comparable, V any](dict M, keys []K, val V) M
fill map with same values
func SliceToBoolMap ¶
func SliceToBoolMap[S ~[]K, K comparable](slice S) map[K]bool
convert slice to the map where each element of a slice is the key and values is bool
Types ¶
type AccessSetter ¶
type AccessSetter[A, C comparable] func(content C, access A) bool
PoliciesSetter function which populates policies for the list of content, error will be passed to the executor (e.g. GetPolicies) AccessSetter function which populates access for the peace of content
type CBAC ¶
type CBAC[A, C comparable, O any] interface { GetPolicies(ContentList []C, On O, Accesses ...A) (Policies[A, C], error) GetPolicy(Content C, On O, Accesses ...A) (Policy[A], error) GetAccess(Content C, On O, Access A) (bool, error) }
GetPolicies get the list of policies for the list of content on On instance (optionally for the list of accesses) GetPolicy get the policy for the content on On instance (optionally for the list of accesses) GetAccess get the access for the content on On instance for the specific access
func InitCBAC ¶
func InitCBAC[A, C comparable, O any](Setter PoliciesSetter[A, C, O], Accesses ...A) CBAC[A, C, O]
Init CBAC where: A - type of access C - type of content O - type of instance of which access should be checked Setter - policies setter function Accesses - list of needed accesses
type Policies ¶
type Policies[A comparable, C comparable] map[C]Policy[A]
type PoliciesSetter ¶
type PoliciesSetter[A, C comparable, O any] func(ContentList []C, On O, requestedAccesses []A) (AccessSetter[A, C], error)
PoliciesSetter function which populates policies for the list of content, error will be passed to the executor (e.g. GetPolicies) AccessSetter function which populates access for the peace of content
type Policy ¶
type Policy[A comparable] map[A]bool
policy is the simple map of accesses and their bool values