graph

package
v0.0.0-...-6b0088a Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package graph contains groups graph definitions and operations.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoSuchGroup = errors.New("no such group")

ErrNoSuchGroup is returned when a group is not found in the groups graph.

Functions

This section is empty.

Types

type Graph

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

Graph represents a traversable group graph.

func NewGraph

func NewGraph(groups []*model.AuthGroup) *Graph

NewGraph creates all groupNode(s) that are available in the graph.

func (*Graph) GetExpandedGroup

func (g *Graph) GetExpandedGroup(ctx context.Context,
	name string, skipFilter bool) (*rpcpb.AuthGroup, error)

GetExpandedGroup returns the explicit membership rules for the group.

Note: a privacy filter for members was added in Auth Service v2. To support legacy endpoints and maintain the existing behavior of Auth Service v1, the privacy filter can be disabled with `skipFilter` set to `true`.

If the group exists in the Graph, the returned AuthGroup shall have the following fields:

  • Name, the name of the group;
  • Members, containing all unique members from both direct and indirect inclusions;
  • Globs, containing all unique globs from both direct and indirect inclusions; and
  • Nested, containing all unique nested groups from both direct and indirect inclusions.
  • NumRedacted, the number of members redacted.

func (*Graph) GetRelevantSubgraph

func (g *Graph) GetRelevantSubgraph(principal NodeKey) (*Subgraph, error)

GetRelevantSubgraph returns a Subgraph of groups that include the principal.

Subgraph is represented as series of nodes connected by labeled edges representing inclusion.

type NodeKey

type NodeKey struct {
	// Type of Node, (identity, group, glob).
	Kind NodeKind
	// Name of node, group-name usually.
	Value string
}

NodeKey represents a key to identify Nodes.

func (*NodeKey) ToProto

func (nk *NodeKey) ToProto() *rpcpb.Principal

ToProto converts the NodeKey for the internal subgraph representation to the protobuffer equivalent Principal for rpc.

type NodeKind

type NodeKind string
const (
	Identity NodeKind = "IDENTITY"
	Glob     NodeKind = "GLOB"
	Group    NodeKind = "GROUP"
)

type Subgraph

type Subgraph struct {
	// All nodes in Subgraph.
	Nodes []*SubgraphNode
	// contains filtered or unexported fields
}

Subgraph is directed multigraph with labeled edges and a designated root node. Nodes are assigned integer IDs and edges are stored as a map {node_from_id => label => node_to_id}.

func (*Subgraph) ToProto

func (s *Subgraph) ToProto() *rpcpb.Subgraph

ToProto converts the Subgraph to the protobuffer equivalent Subgraph for rpc.

type SubgraphNode

type SubgraphNode struct {
	NodeKey

	// IncludedBy represents nodes that include this node.
	IncludedBy []int32
}

SubgraphNode represents individual Nodes inside the Subgraph

func (*SubgraphNode) ToProto

func (sn *SubgraphNode) ToProto() *rpcpb.Node

ToProto converts the SubgraphNode to the protobuffer equivalent Node for rpc.

Jump to

Keyboard shortcuts

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