principal

package module
v0.0.0-...-8acf5a8 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2021 License: NCSA Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPermissionDenied = errors.New("permission denied")
)

Functions

func NewAnonymousByteIdentity

func NewAnonymousByteIdentity() *byteIdentity

func NewAnonymousIdentity

func NewAnonymousIdentity() *identity

func NewByteIdentity

func NewByteIdentity(id []byte) *byteIdentity

func NewByteIdentityProvides

func NewByteIdentityProvides(id []byte, capabilities ...*Capability) *byteIdentity

func NewByteIdentitySet

func NewByteIdentitySet(id []byte, set *Set) *byteIdentity

func NewIdentity

func NewIdentity(id int64) *identity

func NewIdentityProvides

func NewIdentityProvides(id int64, capabilities ...*Capability) *identity

func NewIdentitySet

func NewIdentitySet(id int64, set *Set) *identity

Types

type Capability

type Capability struct {
	Method  string      `json:"method"`
	Value   interface{} `json:"value"`
	Subject string      `json:"subject"`
}

func NewCapability

func NewCapability(method string, value interface{}) *Capability

func NewCapabilitySubject

func NewCapabilitySubject(method string, value interface{}, subject string) *Capability

func (*Capability) Hash

func (o *Capability) Hash() string

func (*Capability) Is

func (o *Capability) Is(capability *Capability) bool

func (*Capability) String

func (o *Capability) String() string

type Identity

type Identity interface {
	Can(*Permission) bool
	Provides() *Set
}

type Permission

type Permission struct {
	Requires *Set
	Excludes *Set
}

func NewEmptyPermission

func NewEmptyPermission() *Permission

func NewPermission

func NewPermission(capabilities ...*Capability) *Permission

func NewPermissionSet

func NewPermissionSet(requires *Set) *Permission

func NewPermissionSetFull

func NewPermissionSetFull(requires, excludes *Set) *Permission

func (*Permission) Allows

func (p *Permission) Allows(id Identity) bool

func (*Permission) DecodeFrom

func (p *Permission) DecodeFrom(js string) error

func (*Permission) Difference

func (p *Permission) Difference(other *Permission) *Permission

func (*Permission) Encode

func (p *Permission) Encode() string

func (*Permission) IsSubset

func (p *Permission) IsSubset(other *Permission) bool

func (*Permission) Reverse

func (p *Permission) Reverse() *Permission

func (*Permission) String

func (p *Permission) String() string

func (*Permission) Union

func (p *Permission) Union(other *Permission) *Permission

type Set

type Set struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewSet

func NewSet(capabilities ...*Capability) *Set

func (*Set) Add

func (s *Set) Add(capability *Capability) bool

func (*Set) AddItems

func (s *Set) AddItems(capabilities ...*Capability)

func (*Set) Cardinality

func (s *Set) Cardinality() int

func (*Set) Contains

func (s *Set) Contains(capability *Capability) bool

func (*Set) Difference

func (s *Set) Difference(other *Set) *Set

func (*Set) Equals

func (s *Set) Equals(other *Set) bool

func (*Set) Intersection

func (s *Set) Intersection(other *Set) *Set

func (*Set) IsSubset

func (s *Set) IsSubset(other *Set) bool

func (*Set) IsSuperset

func (s *Set) IsSuperset(other *Set) bool

func (*Set) Iterator

func (s *Set) Iterator(it chan *Capability)

func (*Set) Slice

func (s *Set) Slice() []*Capability

func (*Set) String

func (s *Set) String() string

func (*Set) Union

func (s *Set) Union(other *Set) *Set

Jump to

Keyboard shortcuts

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