blocks

package
v1.19.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: Apache-2.0 Imports: 14 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Assertion

type Assertion struct {
	// RelationshipWithContextString is the string form of the assertion, including optional context.
	// Forms:
	// `document:firstdoc#view@user:tom`
	// `document:seconddoc#view@user:sarah with {"some":"contexthere"}`
	RelationshipWithContextString string

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

	// CaveatContext is the caveat context for the assertion, if any.
	CaveatContext map[string]any

	// SourcePosition is the position of the assertion in the file.
	SourcePosition spiceerrors.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"`

	// AssertCaveated is the set of relationships to assert that are caveated.
	AssertCaveated []Assertion `yaml:"assertCaveated"`

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

	// SourcePosition is the position of the assertions in the file.
	SourcePosition spiceerrors.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 spiceerrors.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 spiceerrors.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 spiceerrors.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 spiceerrors.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 spiceerrors.SourcePosition

	// CompiledSchema is the compiled schema.
	CompiledSchema *compiler.CompiledSchema
}

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 SubjectAndCaveat added in v1.16.0

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

	// IsCaveated indicates whether the subject is caveated.
	IsCaveated bool
}

SubjectAndCaveat returns a subject and whether it is caveated.

type SubjectWithExceptions

type SubjectWithExceptions struct {
	// Subject is the subject found.
	Subject SubjectAndCaveat

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

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