Help us shape the future of Go! Take the 2026 Go Developer Survey

plugin

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetStringConfig

func GetStringConfig(config map[string]interface{}, key string) string

func WithIdentity

func WithIdentity(ctx context.Context, identity *Identity) context.Context

Types

type Action

type Action struct {
	Method   string
	Action   string // read, write, execute, delete
	Resource string // e.g., "stack:web", "container:nginx"
}

Action represents an operation being performed

type AuditEntry

type AuditEntry struct {
	Timestamp      time.Time
	AgentID        string
	Identity       *Identity
	Action         string
	Resource       string
	Result         string
	Duration       time.Duration
	Metadata       map[string]string
	TranscriptHash string // For terminal sessions
}

type AuditFilter

type AuditFilter struct {
	AgentID   string
	UserID    string
	Action    string
	StartTime *time.Time
	EndTime   *time.Time
	Limit     int
}

AuditFilter for querying audit logs

type AuditPlugin

type AuditPlugin interface {
	Plugin

	// Log writes an audit entry (must not fail)
	Log(ctx context.Context, entry *AuditEntry)

	// Query retrieves audit logs
	Query(ctx context.Context, filter *AuditFilter) ([]AuditEntry, error)
}

AuditPlugin logs all security-relevant events

type AuthPlugin

type AuthPlugin interface {
	Plugin

	// Authenticate validates credentials and returns identity
	Authenticate(ctx context.Context, req *AuthRequest) (*Identity, error)

	// Authorize checks if identity can perform action
	Authorize(ctx context.Context, identity *Identity, action *Action) error
}

AuthPlugin handles authentication and authorization

type AuthRequest

type AuthRequest struct {
	Identity *Identity
	Method   string
	Token    string
}

AuthRequest for authentication

type Capability

type Capability string
const (
	CapabilityAuth     Capability = "auth"
	CapabilityAudit    Capability = "audit"
	CapabilitySecrets  Capability = "secrets"
	CapabilityPolicy   Capability = "policy"
	CapabilityStorage  Capability = "storage"
	CapabilityMonitor  Capability = "monitoring"
	CapabilityNotify   Capability = "notifications"
	CapabilitySecurity Capability = "security"
)

type Identity

type Identity struct {
	UserID      string
	DeviceID    string
	Roles       []string
	Attributes  map[string]string
	Certificate []byte
}

Identity represents an authenticated entity

func IdentityFromContext

func IdentityFromContext(ctx context.Context) *Identity

type Plugin

type Plugin interface {
	// Name returns unique plugin identifier
	Name() string

	// Version returns semantic version
	Version() string

	// Init is called once during plugin load
	Init(ctx context.Context, config map[string]interface{}) error

	// Shutdown gracefully stops the plugin
	Shutdown(ctx context.Context) error

	// Capabilities returns what this plugin provides
	Capabilities() []Capability
}

Plugin is the core interface all Mandau plugins must implement

type PolicyDecision

type PolicyDecision struct {
	Allowed     bool
	Reason      string
	Obligations []string // Additional requirements
}

type PolicyPlugin

type PolicyPlugin interface {
	Plugin

	// Evaluate checks if action is permitted
	Evaluate(ctx context.Context, req *PolicyRequest) (*PolicyDecision, error)
}

PolicyPlugin enforces fine-grained access control

type PolicyRequest

type PolicyRequest struct {
	Identity *Identity
	Action   *Action
	Resource *Resource
	Context  map[string]interface{}
}

type Registry

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

Registry manages plugin lifecycle

func NewRegistry

func NewRegistry() *Registry

func (*Registry) AuditAll

func (r *Registry) AuditAll(ctx context.Context, entry *AuditEntry)

AuditAll logs to all audit plugins

func (*Registry) Auth

func (r *Registry) Auth() AuthPlugin

Auth returns the first auth plugin (chain support later)

func (*Registry) Init

func (r *Registry) Init(ctx context.Context, configs map[string]map[string]interface{}) error

Init initializes all registered plugins

func (*Registry) ListAll

func (r *Registry) ListAll() []Plugin

ListAll returns all registered plugins

func (*Registry) Policy

func (r *Registry) Policy() PolicyPlugin

Policy returns the first policy plugin

func (*Registry) Register

func (r *Registry) Register(p Plugin) error

Register adds a plugin to the registry

func (*Registry) ShutdownAll

func (r *Registry) ShutdownAll(ctx context.Context) error

ShutdownAll shuts down all plugins

type Resource

type Resource struct {
	Type       string // stack, container, image, file
	Identifier string
	Labels     map[string]string
}

Resource represents the target of an action

type SecretsPlugin

type SecretsPlugin interface {
	Plugin

	// Get retrieves a secret by key
	Get(ctx context.Context, key string) ([]byte, error)

	// Set stores a secret
	Set(ctx context.Context, key string, value []byte) error

	// Delete removes a secret
	Delete(ctx context.Context, key string) error

	// InjectEnv injects secrets into environment map
	InjectEnv(ctx context.Context, env map[string]string) error
}

SecretsPlugin manages secret injection

Jump to

Keyboard shortcuts

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