Documentation
¶
Overview ¶
Package plugin adapters for compatibility
Package plugin base implementation ¶
Package plugin lifecycle management ¶
Package plugin manager implementation ¶
Package plugin registry implementation ¶
Package plugin types and configuration structures
Index ¶
- Constants
- func HTTPHandlerAdapter(handler http.HandlerFunc) httprouter.Handle
- func HTTPHandlerWithParamsAdapter(handler func(http.ResponseWriter, *http.Request, httprouter.Params)) httprouter.Handle
- func Register(plugin Plugin)
- func SetHost(host PluginHost)
- func WrapStandardHandler(handler http.HandlerFunc) httprouter.Handle
- type Alert
- type AlertConfig
- type AlertProvider
- type AuditConfig
- type AuditEvent
- type AuditLogger
- type AuthConfig
- type AuthProvider
- type BasePlugin
- func (p *BasePlugin) Dependencies() []PluginDependency
- func (p *BasePlugin) Description() string
- func (p *BasePlugin) IsInitialized() bool
- func (p *BasePlugin) Name() string
- func (p *BasePlugin) SetInfo(name, version, description string)
- func (p *BasePlugin) SetInitialized(initialized bool)
- func (p *BasePlugin) Shutdown(ctx context.Context) error
- func (p *BasePlugin) Version() string
- type CoreExtensionPlugin
- type DashboardConfig
- type DashboardProvider
- type DependencyGraph
- type DependencyType
- type EncryptionConfig
- type EncryptionProvider
- type EndpointProtectionRequest
- type Logger
- type MetricsCollector
- type MetricsConfig
- type MiddlewareConfig
- type MiddlewarePlugin
- type MonitoringPlugin
- type Plugin
- type PluginDependency
- type PluginEvent
- type PluginEventHandler
- type PluginHost
- type PluginLifecycle
- type PluginManager
- func (pm *PluginManager) GetPlugin(name string) (Plugin, bool)
- func (pm *PluginManager) GetRoutes() map[string]http.HandlerFunc
- func (pm *PluginManager) Initialize(ctx context.Context, configs map[string]map[string]interface{}) error
- func (pm *PluginManager) ListPlugins() []Plugin
- func (pm *PluginManager) LoadPlugin(ctx context.Context, plugin Plugin, config map[string]interface{}) error
- func (pm *PluginManager) Register(plugin Plugin) error
- func (pm *PluginManager) Shutdown(ctx context.Context) error
- type PluginRegistry
- func (r *PluginRegistry) Get(name string) (Plugin, bool)
- func (r *PluginRegistry) Initialize(ctx context.Context, configs map[string]map[string]interface{}) error
- func (r *PluginRegistry) List() []Plugin
- func (r *PluginRegistry) Register(plugin Plugin) error
- func (r *PluginRegistry) Shutdown(ctx context.Context) error
- type SecurityPlugin
- type Server
- type Settings
- type StorageConfig
- type StoragePlugin
Constants ¶
const ( EventEndpointProtectionRequest = events.EventEndpointProtectionRequest EventEndpointProtectionUpdate = events.EventEndpointProtectionUpdate EventEndpointAccessDenied = events.EventEndpointAccessDenied EventEndpointAccessGranted = events.EventEndpointAccessGranted EventSecurityThreatDetected = events.EventSecurityThreatDetected EventSecurityAnomalyDetected = events.EventSecurityAnomalyDetected )
Legacy constants - use events package instead
Variables ¶
This section is empty.
Functions ¶
func HTTPHandlerAdapter ¶ added in v0.0.4
func HTTPHandlerAdapter(handler http.HandlerFunc) httprouter.Handle
HTTPHandlerAdapter adapts a standard http.HandlerFunc to httprouter.Handle This allows plugins to use standard http handlers with httprouter-based hosts
func HTTPHandlerWithParamsAdapter ¶ added in v0.0.4
func HTTPHandlerWithParamsAdapter(handler func(http.ResponseWriter, *http.Request, httprouter.Params)) httprouter.Handle
HTTPHandlerWithParamsAdapter adapts a handler that needs access to httprouter params Example usage:
host.RegisterHandler("/user/:id", HTTPHandlerWithParamsAdapter(func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
userID := ps.ByName("id")
// ... handle request
}))
func WrapStandardHandler ¶ added in v0.0.4
func WrapStandardHandler(handler http.HandlerFunc) httprouter.Handle
WrapStandardHandler is a convenience method that wraps a standard http.HandlerFunc for use with httprouter-based plugin hosts
Types ¶
type Alert ¶
type Alert struct {
Level string `json:"level"`
Title string `json:"title"`
Description string `json:"description"`
Timestamp time.Time `json:"timestamp"`
Tags map[string]string `json:"tags"`
Data map[string]interface{} `json:"data"`
}
Alert represents an alert
type AlertConfig ¶
type AlertConfig struct {
Provider string `json:"provider"`
Webhook string `json:"webhook"`
Config map[string]interface{} `json:"config"`
}
AlertConfig provides configuration for alert providers
type AlertProvider ¶
AlertProvider interface for alerting
type AuditConfig ¶
type AuditConfig struct {
Level string `json:"level"`
Output string `json:"output"`
Config map[string]interface{} `json:"config"`
}
AuditConfig provides configuration for audit logging
type AuditEvent ¶
type AuditEvent struct {
Timestamp time.Time `json:"timestamp"`
User string `json:"user"`
Action string `json:"action"`
Resource string `json:"resource"`
Result string `json:"result"`
Details map[string]interface{} `json:"details"`
}
AuditEvent represents an audit event
type AuditLogger ¶
type AuditLogger interface {
LogEvent(event AuditEvent) error
}
AuditLogger interface for audit logging
type AuthConfig ¶
type AuthConfig struct {
Type string `json:"type"`
Provider string `json:"provider"`
Config map[string]interface{} `json:"config"`
}
AuthConfig provides configuration for authentication providers
type AuthProvider ¶
type AuthProvider interface {
Authenticate(username, password string) (bool, error)
ValidateToken(token string) (bool, error)
}
AuthProvider interface for authentication providers
type BasePlugin ¶
type BasePlugin struct {
// contains filtered or unexported fields
}
BasePlugin provides a base implementation for plugins
func (*BasePlugin) Dependencies ¶
func (p *BasePlugin) Dependencies() []PluginDependency
Dependencies returns an empty dependency list by default
func (*BasePlugin) Description ¶
func (p *BasePlugin) Description() string
Description returns the plugin description
func (*BasePlugin) IsInitialized ¶
func (p *BasePlugin) IsInitialized() bool
IsInitialized returns whether the plugin is initialized
func (*BasePlugin) SetInfo ¶
func (p *BasePlugin) SetInfo(name, version, description string)
SetInfo sets the plugin information
func (*BasePlugin) SetInitialized ¶
func (p *BasePlugin) SetInitialized(initialized bool)
SetInitialized sets the initialization status
func (*BasePlugin) Shutdown ¶
func (p *BasePlugin) Shutdown(ctx context.Context) error
Default implementation of Shutdown
func (*BasePlugin) Version ¶
func (p *BasePlugin) Version() string
Version returns the plugin version
type CoreExtensionPlugin ¶
type CoreExtensionPlugin interface {
Plugin
// Extend server initialization
ExtendServerInit(server *Server) error
// Modify server configuration
ModifyConfig(config *Settings) error
// Register custom services
RegisterServices(host PluginHost) error
}
CoreExtensionPlugin extends fundamental server capabilities
type DashboardConfig ¶
type DashboardConfig struct {
Type string `json:"type"`
Endpoint string `json:"endpoint"`
Config map[string]interface{} `json:"config"`
}
DashboardConfig provides configuration for dashboard providers
type DashboardProvider ¶
type DashboardProvider interface {
CreateDashboard(config DashboardConfig) error
UpdateDashboard(id string, config DashboardConfig) error
}
DashboardProvider interface for dashboard providers
type DependencyGraph ¶
type DependencyGraph struct {
// contains filtered or unexported fields
}
DependencyGraph represents a dependency graph for plugins
func NewDependencyGraph ¶
func NewDependencyGraph() *DependencyGraph
NewDependencyGraph creates a new dependency graph
func (*DependencyGraph) AddEdge ¶
func (g *DependencyGraph) AddEdge(from, to string)
AddEdge adds an edge from 'from' to 'to'
func (*DependencyGraph) AddNode ¶
func (g *DependencyGraph) AddNode(name string)
AddNode adds a node to the graph
func (*DependencyGraph) TopologicalSort ¶
func (g *DependencyGraph) TopologicalSort() ([]string, error)
TopologicalSort returns a topologically sorted list of nodes
type DependencyType ¶
type DependencyType string
DependencyType represents the type of dependency
const ( DependencyRequired DependencyType = "required" DependencyOptional DependencyType = "optional" DependencyConflict DependencyType = "conflict" )
type EncryptionConfig ¶
type EncryptionConfig struct {
Algorithm string `json:"algorithm"`
KeySize int `json:"key_size"`
Config map[string]interface{} `json:"config"`
}
EncryptionConfig provides configuration for encryption providers
type EncryptionProvider ¶
type EncryptionProvider interface {
Encrypt(data []byte) ([]byte, error)
Decrypt(data []byte) ([]byte, error)
}
EncryptionProvider interface for encryption providers
type EndpointProtectionRequest ¶
type EndpointProtectionRequest = events.EndpointProtectionRequest
type Logger ¶
type Logger interface {
Info(msg string, args ...interface{})
Warn(msg string, args ...interface{})
Error(msg string, args ...interface{})
Debug(msg string, args ...interface{})
}
Logger interface for plugin logging
type MetricsCollector ¶
MetricsCollector interface for custom metrics
type MetricsConfig ¶
type MetricsConfig struct {
Type string `json:"type"`
Endpoint string `json:"endpoint"`
Config map[string]interface{} `json:"config"`
}
MetricsConfig provides configuration for metrics collectors
type MiddlewareConfig ¶
type MiddlewareConfig struct {
Path string `json:"path"`
Priority int `json:"priority"`
Config map[string]interface{} `json:"config"`
}
MiddlewareConfig provides configuration for middleware creation
type MiddlewarePlugin ¶
type MiddlewarePlugin interface {
Plugin
// Create middleware handler
CreateMiddleware(config MiddlewareConfig) (func(http.Handler) http.Handler, error)
// Middleware priority (lower numbers run first)
Priority() int
// Paths this middleware applies to
ApplicablePaths() []string
}
MiddlewarePlugin provides HTTP request/response processing
type MonitoringPlugin ¶
type MonitoringPlugin interface {
Plugin
// Custom metrics collectors
CreateMetricsCollector(config MetricsConfig) (MetricsCollector, error)
// Alert providers
CreateAlertProvider(config AlertConfig) (AlertProvider, error)
// Dashboard providers
CreateDashboardProvider(config DashboardConfig) (DashboardProvider, error)
}
MonitoringPlugin provides observability enhancements
type Plugin ¶
type Plugin interface {
// Initialize the plugin with server context and configuration
Initialize(ctx context.Context, server PluginHost, config map[string]interface{}) error
// Name returns the unique plugin identifier
Name() string
// Version returns the plugin version
Version() string
// Description returns human-readable plugin description
Description() string
// Dependencies returns required plugin dependencies
Dependencies() []PluginDependency
// Shutdown gracefully stops the plugin
Shutdown(ctx context.Context) error
}
Plugin represents a loadable module that extends Hockeypuck functionality
type PluginDependency ¶
type PluginDependency struct {
Name string `json:"name"`
Version string `json:"version"`
Type DependencyType `json:"type"`
Optional bool `json:"optional"`
}
PluginDependency represents a plugin dependency
type PluginEventHandler ¶
type PluginEventHandler = events.PluginEventHandler
type PluginHost ¶
type PluginHost interface {
// Register middleware handlers (still uses http.Handler for interpose compatibility)
RegisterMiddleware(path string, middleware func(http.Handler) http.Handler) error
// Register API endpoints using httprouter.Handle
RegisterHandler(pattern string, handler httprouter.Handle) error
// Access storage backend
Storage() hkpstorage.Storage
// Access configuration
Config() *config.Settings
// Access metrics system
Metrics() *metrics.Metrics
// Access logger
Logger() *log.Logger
// Register periodic tasks
RegisterTask(name string, interval time.Duration, task func(context.Context) error) error
// Publish events to plugin system
PublishEvent(event events.PluginEvent) error
// Subscribe to plugin events
SubscribeEvent(eventType string, handler events.PluginEventHandler) error
// Subscribe to Hockeypuck-style key change notifications
SubscribeKeyChanges(callback func(hkpstorage.KeyChange) error) error
// Convenience methods for common events
PublishThreatDetected(threat events.ThreatInfo) error
PublishRateLimitViolation(violation events.RateLimitViolation) error
PublishZTNAEvent(eventType string, ztnaEvent events.ZTNAEvent) error
}
PluginHost provides server context and services to plugins
type PluginLifecycle ¶
type PluginLifecycle struct {
// contains filtered or unexported fields
}
PluginLifecycle manages plugin initialization and shutdown
func NewPluginLifecycle ¶
func NewPluginLifecycle(registry *PluginRegistry) *PluginLifecycle
NewPluginLifecycle creates a new plugin lifecycle manager
func (*PluginLifecycle) Initialize ¶
func (l *PluginLifecycle) Initialize(ctx context.Context, configs map[string]map[string]interface{}) error
Initialize initializes plugins in dependency order
type PluginManager ¶
type PluginManager struct {
// contains filtered or unexported fields
}
PluginManager manages the entire plugin system
func NewPluginManager ¶
func NewPluginManager(host PluginHost, logger Logger) *PluginManager
NewPluginManager creates a new plugin manager
func (*PluginManager) GetPlugin ¶
func (pm *PluginManager) GetPlugin(name string) (Plugin, bool)
GetPlugin gets a plugin by name
func (*PluginManager) GetRoutes ¶
func (pm *PluginManager) GetRoutes() map[string]http.HandlerFunc
GetRoutes returns HTTP routes from all plugins
func (*PluginManager) Initialize ¶
func (pm *PluginManager) Initialize(ctx context.Context, configs map[string]map[string]interface{}) error
Initialize initializes all registered plugins
func (*PluginManager) ListPlugins ¶
func (pm *PluginManager) ListPlugins() []Plugin
ListPlugins lists all registered plugins
func (*PluginManager) LoadPlugin ¶
func (pm *PluginManager) LoadPlugin(ctx context.Context, plugin Plugin, config map[string]interface{}) error
LoadPlugin loads and initializes a plugin
func (*PluginManager) Register ¶
func (pm *PluginManager) Register(plugin Plugin) error
Register registers a plugin with the manager
type PluginRegistry ¶
type PluginRegistry struct {
// contains filtered or unexported fields
}
PluginRegistry manages plugins for a host system
func GetRegistry ¶
func GetRegistry() *PluginRegistry
GetRegistry returns the global plugin registry
func NewPluginRegistry ¶
func NewPluginRegistry(host PluginHost) *PluginRegistry
NewPluginRegistry creates a new plugin registry
func (*PluginRegistry) Get ¶
func (r *PluginRegistry) Get(name string) (Plugin, bool)
Get retrieves a plugin by name
func (*PluginRegistry) Initialize ¶
func (r *PluginRegistry) Initialize(ctx context.Context, configs map[string]map[string]interface{}) error
Initialize initializes all plugins
func (*PluginRegistry) List ¶
func (r *PluginRegistry) List() []Plugin
List returns all registered plugins
func (*PluginRegistry) Register ¶
func (r *PluginRegistry) Register(plugin Plugin) error
Register registers a plugin
type SecurityPlugin ¶
type SecurityPlugin interface {
Plugin
// Authentication providers
CreateAuthProvider(config AuthConfig) (AuthProvider, error)
// Audit logging enhancements
CreateAuditLogger(config AuditConfig) (AuditLogger, error)
// Encryption providers
CreateEncryptionProvider(config EncryptionConfig) (EncryptionProvider, error)
}
SecurityPlugin provides security enhancements
type Server ¶
type Server struct {
}
Server represents the Hockeypuck server (placeholder interface)
type Settings ¶
Legacy Settings type - deprecated, use config.Settings instead Kept for backward compatibility
type StorageConfig ¶
type StorageConfig struct {
Type string `json:"type"`
Config map[string]interface{} `json:"config"`
}
StorageConfig provides configuration for storage backend creation
type StoragePlugin ¶
type StoragePlugin interface {
Plugin
// Create storage backend instance
CreateStorage(config StorageConfig) (hkpstorage.Storage, error)
// Backend type identifier
BackendType() string
// Required configuration schema
ConfigSchema() map[string]interface{}
}
StoragePlugin provides custom storage implementations