diff --git a/pkg/go/graph/weighted_graph.go b/pkg/go/graph/weighted_graph.go index 27954f74..5f8a9285 100644 --- a/pkg/go/graph/weighted_graph.go +++ b/pkg/go/graph/weighted_graph.go @@ -25,8 +25,7 @@ func (wg *WeightedAuthorizationModelGraph) GetEdges() map[string][]*WeightedAuth return wg.edges } -// GetEdges returns the edges map. -func (wg *WeightedAuthorizationModelGraph) GetEdgesByNode(node *WeightedAuthorizationModelNode) ([]*WeightedAuthorizationModelEdge, bool) { +func (wg *WeightedAuthorizationModelGraph) GetEdgesFromNode(node *WeightedAuthorizationModelNode) ([]*WeightedAuthorizationModelEdge, bool) { v, ok := wg.edges[node.uniqueLabel] return v, ok } @@ -36,7 +35,6 @@ func (wg *WeightedAuthorizationModelGraph) GetNodes() map[string]*WeightedAuthor return wg.nodes } -// GetNodes returns the nodes map. func (wg *WeightedAuthorizationModelGraph) GetNodeByID(uniqueLabel string) (*WeightedAuthorizationModelNode, bool) { v, ok := wg.nodes[uniqueLabel] return v, ok @@ -50,7 +48,7 @@ func NewWeightedAuthorizationModelGraph() *WeightedAuthorizationModelGraph { } } -// AddNode adds a node to the graph with optional operationType and weight. +// AddNode adds a node to the graph with optional nodeType and weight. func (wg *WeightedAuthorizationModelGraph) AddNode(uniqueLabel, label string, nodeType NodeType) { wildcards := make([]string, 0) if nodeType == SpecificTypeWildcard { diff --git a/pkg/go/graph/weighted_graph_edge.go b/pkg/go/graph/weighted_graph_edge.go index 065601e6..28da3664 100644 --- a/pkg/go/graph/weighted_graph_edge.go +++ b/pkg/go/graph/weighted_graph_edge.go @@ -6,7 +6,7 @@ type WeightedAuthorizationModelEdge struct { conditionedOn string from *WeightedAuthorizationModelNode to *WeightedAuthorizationModelNode - wildcards []string + wildcards []string // e.g. "user". This means that in the direction of this edge there is a path to node user:* } // GetWeights returns the entire weights map. @@ -14,7 +14,7 @@ func (edge *WeightedAuthorizationModelEdge) GetWeights() map[string]int { return edge.weights } -// GetWeight returns the weight for a specific key. +// GetWeight returns the weight for a specific type. It can return Infinite to indicate recursion. func (edge *WeightedAuthorizationModelEdge) GetWeight(key string) (int, bool) { weight, exists := edge.weights[key] return weight, exists @@ -25,7 +25,7 @@ func (edge *WeightedAuthorizationModelEdge) GetEdgeType() EdgeType { return edge.edgeType } -// GetConditionedOn returns the conditionedOn field. +// GetConditionedOn returns the conditionedOn field, e.g. "document#parent". func (edge *WeightedAuthorizationModelEdge) GetConditionedOn() string { return edge.conditionedOn } @@ -40,7 +40,7 @@ func (edge *WeightedAuthorizationModelEdge) GetTo() *WeightedAuthorizationModelN return edge.to } -// GetWildcards returns the wildcards. +// GetWildcards returns an array of types, e.g. "user". This means that in the direction of this edge there is a path to node user:* func (edge *WeightedAuthorizationModelEdge) GetWildcards() []string { return edge.wildcards } diff --git a/pkg/go/graph/weighted_graph_node.go b/pkg/go/graph/weighted_graph_node.go index 8df4d436..b9ebab08 100644 --- a/pkg/go/graph/weighted_graph_node.go +++ b/pkg/go/graph/weighted_graph_node.go @@ -3,9 +3,9 @@ package graph type WeightedAuthorizationModelNode struct { weights map[string]int nodeType NodeType - label string // e.g. "group#member", UnionOperator, IntersectionOperator, ExclusionOperator - uniqueLabel string - wildcards []string + label string // e.g. "group#member", UnionOperator, IntersectionOperator, ExclusionOperator + uniqueLabel string // e.g. "group#member", or "union:01JH0MR4H1MBFGVN37E4PRMPM3" + wildcards []string // e.g. "user". This means that from this node there is a path to node user:* } // GetWeights returns the entire weights map. @@ -13,7 +13,7 @@ func (node *WeightedAuthorizationModelNode) GetWeights() map[string]int { return node.weights } -// GetWeight returns the weight for a specific key. +// GetWeight returns the weight for a specific type. It can return Infinite to indicate recursion. func (node *WeightedAuthorizationModelNode) GetWeight(key string) (int, bool) { weight, exists := node.weights[key] return weight, exists @@ -24,17 +24,18 @@ func (node *WeightedAuthorizationModelNode) GetNodeType() NodeType { return node.nodeType } -// GetLabel returns the label. +// GetLabel returns the label, e.g. "user", "group#member", UnionOperator, IntersectionOperator or ExclusionOperator. func (node *WeightedAuthorizationModelNode) GetLabel() string { return node.label } -// GetUniqueLabel returns the unique label. +// GetUniqueLabel returns the unique label. It is the same as GetLabel, except for operation nodes, +// where it takes the form "operation:ULID". func (node *WeightedAuthorizationModelNode) GetUniqueLabel() string { return node.uniqueLabel } -// GetWildcards returns the wildcards. +// GetWildcards returns an array of types, e.g. "user". This means that from this node there is a path to node user:* func (node *WeightedAuthorizationModelNode) GetWildcards() []string { return node.wildcards }