common

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// AutoEntityActions is a list of all actions which get
	// automatically generated hooks inserted into the tree
	// processing system.
	AutoEntityActions = [...]PluginAction{
		EntityCreate,
		EntityUpdate,
		EntityLock,
		EntityUnlock,
		EntityDestroy,

		PreSecretChange,
		PostSecretChange,
		PreAuthCheck,
		PostAuthCheck,
	}

	// AutoGroupActions is the same as AutoEntityActions, but has
	// been split out since entities and groups have different
	// signatures for their respective hooks.
	AutoGroupActions = [...]PluginAction{
		GroupCreate,
		GroupUpdate,
		GroupDestroy,
	}

	// AutoHookPriority is used to determine where a hook is to be
	// sequenced in to a chain based on priority.
	AutoHookPriority = map[PluginAction]int{
		EntityCreate:  70,
		EntityUpdate:  70,
		EntityLock:    70,
		EntityUnlock:  70,
		EntityDestroy: 70,

		GroupCreate:  70,
		GroupUpdate:  70,
		GroupDestroy: 70,

		PreSecretChange:  40,
		PostSecretChange: 60,
		PreAuthCheck:     15,
		PostAuthCheck:    60,
	}
)

Functions

This section is empty.

Types

type GoPlugin

type GoPlugin interface {
	ProcessEntity(context.Context, PluginOpts, *PluginResult) error
	ProcessGroup(context.Context, PluginOpts, *PluginResult) error
}

GoPlugin is the actual interface that's exposed across the link.

type GoPluginClient

type GoPluginClient struct {
	GoPlugin
	// contains filtered or unexported fields
}

GoPluginClient is an RPC Servable type that can be used with Hashicorp's go-plugin in order to provide the transport for the actual Plugin interface.

func (*GoPluginClient) ProcessEntity

func (c *GoPluginClient) ProcessEntity(ctx context.Context, opts PluginOpts) (PluginResult, error)

ProcessEntity on the GoPluginClient provides a much cleaner interface than a raw net/rpc connection. ProcessEntity handles modifications that handle entities only.

func (*GoPluginClient) ProcessGroup

func (c *GoPluginClient) ProcessGroup(ctx context.Context, opts PluginOpts) (PluginResult, error)

ProcessGroup on the GoPluginClient provides a much cleaner interface than a raw net/rpc connection. ProcessGroup handles modifications that handle entities only.

type GoPluginRPC

type GoPluginRPC struct {
	Mux pluginMux
}

GoPluginRPC is a binding only type that's used to provide the interface required by go-plugin.

func (GoPluginRPC) Client

func (GoPluginRPC) Client(b *plugin.MuxBroker, c *rpc.Client) (interface{}, error)

Client returns a go-plugin compliant interface that handles the consumer side of the interface.

func (*GoPluginRPC) Server

func (p *GoPluginRPC) Server(*plugin.MuxBroker) (interface{}, error)

Server returns a go-plugin compliant interface that handles the provider side of the interface.

type GoPluginServer

type GoPluginServer struct {
	Mux pluginMux
}

GoPluginServer implements the net/rpc server that GoPluginRPC talks to.

func (*GoPluginServer) ProcessEntity

func (p *GoPluginServer) ProcessEntity(ctx context.Context, opts PluginOpts, res *PluginResult) error

ProcessEntity on the GoPluginServer type implements a net/rpc server method that handles entities.

func (*GoPluginServer) ProcessGroup

func (p *GoPluginServer) ProcessGroup(ctx context.Context, opts PluginOpts, res *PluginResult) error

ProcessGroup on the GoPluginServer type implements a net/rpc server that handles groups.

type Plugin

type Plugin interface {
	EntityCreate(context.Context, pb.Entity, pb.Entity) (pb.Entity, error)
	EntityUpdate(context.Context, pb.Entity) (pb.Entity, error)
	EntityLock(context.Context, pb.Entity) (pb.Entity, error)
	EntityUnlock(context.Context, pb.Entity) (pb.Entity, error)
	EntityDestroy(context.Context, pb.Entity) (pb.Entity, error)

	GroupCreate(context.Context, pb.Group) (pb.Group, error)
	GroupUpdate(context.Context, pb.Group) (pb.Group, error)
	GroupDestroy(context.Context, pb.Group) (pb.Group, error)

	PreSecretChange(context.Context, pb.Entity, pb.Entity) (pb.Entity, error)
	PostSecretChange(context.Context, pb.Entity, pb.Entity) (pb.Entity, error)
	PreAuthCheck(context.Context, pb.Entity, pb.Entity) (pb.Entity, error)
	PostAuthCheck(context.Context, pb.Entity, pb.Entity) (pb.Entity, error)
}

Plugin is the type for plugins that extend the functionality of the built in tree management system. The most common type of plugin is one that will propagate changes to a system external to NetAuth.

type PluginAction

type PluginAction int

PluginAction is used to swich handlers inside a ProcessEntity or ProcessGroup handler.

const (
	EntityCreate PluginAction = iota
	EntityUpdate
	EntityLock
	EntityUnlock
	EntityDestroy

	GroupCreate
	GroupUpdate
	GroupDestroy

	PreSecretChange
	PostSecretChange
	PreAuthCheck
	PostAuthCheck
)

These constants are used to switch actions inside the plugins themselves.

func (PluginAction) String

func (i PluginAction) String() string

type PluginOpts

type PluginOpts struct {
	Action     PluginAction
	Entity     *pb.Entity
	DataEntity *pb.Entity
	Group      *pb.Group
	DataGroup  *pb.Group
}

PluginOpts provides a clean transport for data that needs to be fed into a plugin. Note that this is used for both group and entity operations, but not all fields are required to be populated.

type PluginResult

type PluginResult struct {
	Entity pb.Entity
	Group  pb.Group
}

PluginResult is returned by group and entity operations in plugins and provides a container for data to be passed back along the RPC connection.

Jump to

Keyboard shortcuts

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