blocks

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: May 2, 2022 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Assertion

type Assertion struct {
	// RelationshipString is the string form of the assertion.
	RelationshipString string

	// Relationship is the parsed relationship on which the assertion is being
	// run.
	Relationship *v1.Relationship

	// SourcePosition is the position of the assertion in the file.
	SourcePosition commonerrors.SourcePosition
}

Assertion is a parsed assertion.

func (*Assertion) UnmarshalYAML

func (a *Assertion) UnmarshalYAML(node *yamlv3.Node) error

UnmarshalYAML is a custom unmarshaller.

type Assertions

type Assertions struct {
	// AssertTrue is the set of relationships to assert true.
	AssertTrue []Assertion `yaml:"assertTrue"`

	// AssertFalse is the set of relationships to assert false.
	AssertFalse []Assertion `yaml:"assertFalse"`

	// SourcePosition is the position of the assertions in the file.
	SourcePosition commonerrors.SourcePosition
}

Assertions represents assertions defined in the validation file.

func ParseAssertionsBlock

func ParseAssertionsBlock(contents []byte) (*Assertions, error)

ParseAssertionsBlock parses the given contents as an assertions block.

func (*Assertions) UnmarshalYAML

func (a *Assertions) UnmarshalYAML(node *yamlv3.Node) error

UnmarshalYAML is a custom unmarshaller.

type ExpectedSubject

type ExpectedSubject struct {
	// ValidationString holds a validation string containing a Subject and one or
	// more Relations to the parent Object.
	// Example: `[tenant/user:someuser#...] is <tenant/document:example#viewer>`
	ValidationString ValidationString

	// Subject is the subject expected. May be nil if not defined in the line.
	SubjectWithExceptions *SubjectWithExceptions

	// Resources are the resources under which the subject is found.
	Resources []*core.ObjectAndRelation

	// SourcePosition is the position of the expected subject in the file.
	SourcePosition commonerrors.SourcePosition
}

ExpectedSubject is a subject expected for the ObjectAndRelation.

func (*ExpectedSubject) UnmarshalYAML

func (es *ExpectedSubject) UnmarshalYAML(node *yamlv3.Node) error

UnmarshalYAML is a custom unmarshaller.

type ObjectRelation

type ObjectRelation struct {
	// ObjectRelationString is the string form of the object relation.
	ObjectRelationString string

	// ObjectAndRelation is the parsed object and relation.
	ObjectAndRelation *core.ObjectAndRelation

	// SourcePosition is the position of the expected relations in the file.
	SourcePosition commonerrors.SourcePosition
}

ObjectRelation represents an ONR defined as a string in the key for the ValidationMap.

func (*ObjectRelation) UnmarshalYAML

func (ors *ObjectRelation) UnmarshalYAML(node *yamlv3.Node) error

UnmarshalYAML is a custom unmarshaller.

type ParsedExpectedRelations

type ParsedExpectedRelations struct {
	// ValidationMap is the parsed expected relations validation map.
	ValidationMap ValidationMap

	// SourcePosition is the position of the expected relations in the file.
	SourcePosition commonerrors.SourcePosition
}

ParsedExpectedRelations represents the expected relations defined in the validation file.

func ParseExpectedRelationsBlock

func ParseExpectedRelationsBlock(contents []byte) (*ParsedExpectedRelations, error)

ParseExpectedRelationsBlock parses the given contents as an expected relations block.

func (*ParsedExpectedRelations) UnmarshalYAML

func (per *ParsedExpectedRelations) UnmarshalYAML(node *yamlv3.Node) error

UnmarshalYAML is a custom unmarshaller.

type ParsedRelationships

type ParsedRelationships struct {
	// RelationshipsString is the found string of newline-separated relationships.
	RelationshipsString string

	// SourcePosition is the position of the schema in the file.
	SourcePosition commonerrors.SourcePosition

	// Relationships are the fully parsed relationships.
	Relationships []*v1.Relationship
}

ParsedRelationships is the parsed relationships in a validationfile.

func (*ParsedRelationships) UnmarshalYAML

func (pr *ParsedRelationships) UnmarshalYAML(node *yamlv3.Node) error

UnmarshalYAML is a custom unmarshaller.

type ParsedSchema

type ParsedSchema struct {
	// Schema is the schema found.
	Schema string

	// SourcePosition is the position of the schema in the file.
	SourcePosition commonerrors.SourcePosition

	// Definitions are the compiled definitions for the schema.
	Definitions []*core.NamespaceDefinition
}

ParsedSchema is the parsed schema in a validationfile.

func (*ParsedSchema) UnmarshalYAML

func (ps *ParsedSchema) UnmarshalYAML(node *yamlv3.Node) error

UnmarshalYAML is a custom unmarshaller.

type SubjectWithExceptions

type SubjectWithExceptions struct {
	// Subject is the subject found.
	Subject *core.ObjectAndRelation

	// Exceptions are those subjects removed from the subject, if it is a wildcard.
	Exceptions []*core.ObjectAndRelation
}

SubjectWithExceptions returns the subject found in a validation string, along with any exceptions.

type ValidationMap

type ValidationMap map[ObjectRelation][]ExpectedSubject

ValidationMap is a map from an Object Relation (as a Relationship) to the validation strings containing the Subjects for that Object Relation.

type ValidationString

type ValidationString string

ValidationString holds a validation string containing a Subject and one or more Relations to the parent Object. Example: `[tenant/user:someuser#...] is <tenant/document:example#viewer>`

func (ValidationString) ONRS

ONRS returns the subject ONRs in the ValidationString, if any.

func (ValidationString) ONRStrings

func (vs ValidationString) ONRStrings() []string

ONRStrings returns the ONRs contained in the ValidationString, if any.

func (ValidationString) Subject

Subject returns the subject contained in the ValidationString, if any. If none, returns nil.

func (ValidationString) SubjectString

func (vs ValidationString) SubjectString() (string, bool)

SubjectString returns the subject contained in the ValidationString, if any.

Jump to

Keyboard shortcuts

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