graph

package
v0.2.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2024 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBuildingGraph = errors.New("cannot build graph")

Functions

This section is empty.

Types

type AuthorizationModelEdge

type AuthorizationModelEdge struct {
	graph.Line
	// contains filtered or unexported fields
}

func (*AuthorizationModelEdge) Attributes

func (n *AuthorizationModelEdge) Attributes() []encoding.Attribute

type AuthorizationModelGraph

type AuthorizationModelGraph struct {
	*multi.DirectedGraph
}

func NewAuthorizationModelGraph

func NewAuthorizationModelGraph(model *openfgav1.AuthorizationModel) (*AuthorizationModelGraph, error)

NewAuthorizationModelGraph builds an authorization model in graph form. For example, types such as `group`, usersets such as `group#member` and wildcards `group:*` are encoded as nodes.

The edges are defined by the assignments, e.g. `define viewer: [group]` defines an edge from group to document#viewer. Conditions are not encoded in the graph, and the two edges in an exclusion are not distinguished.

func (*AuthorizationModelGraph) Attributes

func (g *AuthorizationModelGraph) Attributes() []encoding.Attribute

func (*AuthorizationModelGraph) DOTAttributers

func (*AuthorizationModelGraph) GetDOT

func (g *AuthorizationModelGraph) GetDOT() string

GetDOT returns the DOT visualization. The output text is stable. It should only be used for debugging.

type AuthorizationModelGraphBuilder

type AuthorizationModelGraphBuilder struct {
	graph.DirectedMultigraphBuilder
	// contains filtered or unexported fields
}

func (*AuthorizationModelGraphBuilder) AddEdge

func (g *AuthorizationModelGraphBuilder) AddEdge(from, to graph.Node, edgeType EdgeType, conditionedOn string) *AuthorizationModelEdge

func (*AuthorizationModelGraphBuilder) GetNodeFor

func (g *AuthorizationModelGraphBuilder) GetNodeFor(uniqueLabel string) *AuthorizationModelNode

func (*AuthorizationModelGraphBuilder) GetOrAddNode

func (g *AuthorizationModelGraphBuilder) GetOrAddNode(uniqueLabel, label string, nodeType NodeType) *AuthorizationModelNode

func (*AuthorizationModelGraphBuilder) HasEdge

func (g *AuthorizationModelGraphBuilder) HasEdge(from, to graph.Node, edgeType EdgeType, conditionedOn string) bool

type AuthorizationModelNode

type AuthorizationModelNode struct {
	graph.Node
	// contains filtered or unexported fields
}

func (*AuthorizationModelNode) Attributes

func (n *AuthorizationModelNode) Attributes() []encoding.Attribute

type EdgeType

type EdgeType int64
const (
	DirectEdge  EdgeType = 0
	RewriteEdge EdgeType = 1
	TTUEdge     EdgeType = 2
)

type NodeType

type NodeType int64
const (
	SpecificType            NodeType = 0 // e.g. `group`
	SpecificTypeAndRelation NodeType = 1 // e.g. `group#viewer`
	OperatorNode            NodeType = 2 // e.g. union
)

Jump to

Keyboard shortcuts

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