membership

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FoundSubject

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

FoundSubject contains a single found subject and all the relationships in which that subject is a member which were found via the ONRs expansion.

func NewFoundSubject

func NewFoundSubject(subject *v0.ObjectAndRelation, resources ...*v0.ObjectAndRelation) FoundSubject

NewFoundSubject creates a new FoundSubject for a subject and a set of its resources.

func (FoundSubject) ExcludedSubjectsFromWildcard

func (fs FoundSubject) ExcludedSubjectsFromWildcard() ([]*v0.ObjectAndRelation, bool)

ExcludedSubjectsFromWildcard returns those subjects excluded from the wildcard subject. If not a wildcard subject, returns false.

func (FoundSubject) Relationships

func (fs FoundSubject) Relationships() []*v0.ObjectAndRelation

Relationships returns all the relationships in which the subject was found as per the expand.

func (FoundSubject) Subject

func (fs FoundSubject) Subject() *v0.ObjectAndRelation

Subject returns the Subject of the FoundSubject.

func (FoundSubject) ToValidationString

func (fs FoundSubject) ToValidationString() string

ToValidationString returns the FoundSubject in a format that is consumable by the validationfile package.

func (FoundSubject) WildcardType

func (fs FoundSubject) WildcardType() (string, bool)

WildcardType returns the object type for the wildcard subject, if this is a wildcard subject.

type FoundSubjects

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

FoundSubjects contains the subjects found for a specific ONR.

func (FoundSubjects) ListFound

func (fs FoundSubjects) ListFound() []FoundSubject

ListFound returns a slice of all the FoundSubject's.

func (FoundSubjects) LookupSubject

func (fs FoundSubjects) LookupSubject(subject *v0.ObjectAndRelation) (FoundSubject, bool)

LookupSubject returns the FoundSubject for a matching subject, if any.

type Set

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

Set represents the set of membership for one or more ONRs, based on expansion trees.

func NewMembershipSet

func NewMembershipSet() *Set

NewMembershipSet constructs a new membership set.

NOTE: This is designed solely for the developer API and should *not* be used in any performance sensitive code.

func (*Set) AddExpansion

func (ms *Set) AddExpansion(onr *v0.ObjectAndRelation, expansion *v0.RelationTupleTreeNode) (FoundSubjects, bool, error)

AddExpansion adds the expansion of an ONR to the membership set. Returns false if the ONR was already added.

NOTE: The expansion tree *should* be the fully recursive expansion.

func (*Set) SubjectsByONR

func (ms *Set) SubjectsByONR() map[string]FoundSubjects

SubjectsByONR returns a map from ONR (as a string) to the FoundSubjects for that ONR.

type TrackingSubjectSet

type TrackingSubjectSet map[string]FoundSubject

TrackingSubjectSet defines a set that tracks accessible subjects and their associated relationships.

NOTE: This is designed solely for the developer API and testing and should *not* be used in any performance sensitive code.

NOTE: Unlike a traditional set, unions between wildcards and a concrete subject will result in *both* being present in the set, to maintain the proper relationship tracking and reporting of concrete subjects.

TODO(jschorr): Once we have stable generics support, break into a standard SubjectSet and a tracking variant built on top of it.

func AccessibleExpansionSubjects

func AccessibleExpansionSubjects(treeNode *v0.RelationTupleTreeNode) (TrackingSubjectSet, error)

AccessibleExpansionSubjects returns a TrackingSubjectSet representing the set of accessible subjects in the expansion.

func NewTrackingSubjectSet

func NewTrackingSubjectSet(subjects ...FoundSubject) TrackingSubjectSet

NewTrackingSubjectSet creates a new TrackingSubjectSet, with optional initial subjects.

func (TrackingSubjectSet) Add

func (tss TrackingSubjectSet) Add(subjectsAndResources ...FoundSubject)

Add adds the given subjects to this set.

func (TrackingSubjectSet) AddFrom

func (tss TrackingSubjectSet) AddFrom(otherSet TrackingSubjectSet)

AddFrom adds the subjects found in the other set to this set.

func (TrackingSubjectSet) AddWithResources

func (tss TrackingSubjectSet) AddWithResources(subjectsAndResources []FoundSubject, additionalResources *tuple.ONRSet)

AddWithResources adds the given subjects to this set, with the additional resources appended for each subject to be included in their relationships.

func (TrackingSubjectSet) Contains

func (tss TrackingSubjectSet) Contains(subject *v0.ObjectAndRelation) bool

Contains returns true if the set contains the given subject.

func (TrackingSubjectSet) Exclude

Exclude returns a new set that contains the items in this set minus those in the other set.

func (TrackingSubjectSet) Get

Get returns the found subject in the set, if any.

func (TrackingSubjectSet) Intersect

Intersect returns a new set that contains the items in this set *and* the other set. Note that if wildcard is found in *both* sets, it will be returned *along* with any concrete subjects found on the other side of the intersection.

func (TrackingSubjectSet) Remove

func (tss TrackingSubjectSet) Remove(subjects ...*v0.ObjectAndRelation)

Remove removes the given subject(s) from the set. If the subject is a wildcard, all matching subjects are removed. If the subject matches a wildcard in the existing set, then it is added to that wildcard as an exclusion.

func (TrackingSubjectSet) RemoveFrom

func (tss TrackingSubjectSet) RemoveFrom(otherSet TrackingSubjectSet)

RemoveFrom removes any subjects found in the other set from this set.

func (TrackingSubjectSet) ToFoundSubjects

func (tss TrackingSubjectSet) ToFoundSubjects() FoundSubjects

ToFoundSubjects returns the set as a FoundSubjects struct.

func (TrackingSubjectSet) ToSlice

func (tss TrackingSubjectSet) ToSlice() []FoundSubject

ToSlice returns a slice of all subjects found in the set.

func (TrackingSubjectSet) WithType

func (tss TrackingSubjectSet) WithType(objectType string) []FoundSubject

WithType returns any subjects in the set with the given object type.

Jump to

Keyboard shortcuts

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