policyenforcer

package
v0.0.0-...-aec1c34 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// this error is returned when an implementation of policy storage
	// interface is required but nil was provided instead
	ErrNilPolicyStorage = errors.New("nil policy storage")

	// policy storage returns this error when update policy for the resource type
	// is requested but the resource type is not supported by the service
	ErrUnsupportedRtype = errors.New("unsupported resource type")

	// policy storage returns this error when update policy for the sub
	// is requested but the sub is not found in the local storage
	ErrSubNotCached = errors.New("sub is not cached")

	// this errors is returned when policy is of invalid type
	ErrInvalidPolicy = errors.New("invalid policy")
)

Functions

This section is empty.

Types

type Policy

type Policy struct {
	// contains filtered or unexported fields
}

type PolicyEnforcer

type PolicyEnforcer interface {
	Enforce(ctx context.Context, s string, matcher matcherFunc) bool
	GetResourceIDs(ctx context.Context, sub, rtype, act string) []string
}

func NewPolicyEnforcer

func NewPolicyEnforcer(ps PolicyStorage) (PolicyEnforcer, error)

type PolicyStorage

type PolicyStorage interface {
	GetPolicyForSub(ctx context.Context, sub string) []Policy
	UpdatePolicy(method, sub, rtype, rid, act string) error
}

func NewCachedPolicyStorageMW

func NewCachedPolicyStorageMW(url string, rtype []string, c *cache.Cache) (PolicyStorage, error)

type PolicyStorageMW

type PolicyStorageMW func(PolicyStorage) PolicyStorage

Jump to

Keyboard shortcuts

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