plugins

package
v0.2.19 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

README


title: Plugins

Gateway supports a plugin system that allows extending functionality through various types of plugins:

Plugin Types

  • Interceptor - Processes and modifies data before it reaches the connector
  • Wrapper - Wraps and enhances connector functionality
  • Swaggerer - Modifies OpenAPI documentation
  • HTTPServer - Adds HTTP endpoints to the gateway

Available Plugins

Plugin Type Description
api_keys Wrapper, Swaggerer API key authentication
lru_cache Wrapper LRU-based response caching
lua_rls Interceptor Row-level security using Lua scripts
oauth Wrapper, Swaggerer, HTTPServer OAuth 2.0 authentication with support for multiple providers (Google, GitHub, Auth0, Keycloak, Okta)
otel Wrapper OpenTelemetry integration
pii_remover Interceptor PII data removal/masking
presidio_anonymizer Interceptor Microsoft Presidio-based PII detection and anonymization

Plugin Configuration

Plugins are configured in the gateway configuration file under the plugins section:

plugins:
  plugin_name:
    # plugin specific configuration
    option1: value1
    option2: value2

Each plugin has its own specific configuration options. Below are some examples:

OAuth Plugin

oauth:
  provider: "github"           # OAuth provider (google, github, auth0, keycloak, okta)
  client_id: "xxx"            # OAuth Client ID
  client_secret: "xxx"        # OAuth Client Secret
  redirect_url: "http://localhost:8080/oauth/callback"
  scopes:                     # Required access scopes
    - "profile"
    - "email"

Presidio Anonymizer Plugin

presidio_anonymizer:
  presidio_url: "http://localhost:8080/api/v1/projects/1/anonymize"
  anonymizer_rules:
    email:
      - type: EMAIL_ADDRESS
        operator: mask
        masking_char: "*"
        chars_to_mask: 4
    name:
      - type: PERSON
        operator: replace
        new_value: "[REDACTED]"

See individual plugin documentation for complete configuration options.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Enrich

func Enrich(pluginsCfg map[string]any, schema *huma.OpenAPI) (*huma.OpenAPI, error)

func Plugins

func Plugins[TPlugin Plugin](pluginsCfg map[string]any) ([]TPlugin, error)

func Register

func Register[TConfig Config, TPlugin Plugin](f PluginF[TConfig, TPlugin])

func Routes

func Routes(pluginsCfg map[string]any, mux *http.ServeMux) error

func Wrap

func Wrap(pluginsCfg map[string]any, connector connectors.Connector) (connectors.Connector, error)

Types

type Config

type Config interface {
	// Tag returns the unique identifier for the plugin
	Tag() string
	Doc() string
}

Config defines the basic configuration interface that all plugin configs must implement

func KnownPlugin

func KnownPlugin(tag string) (Config, bool)

KnownPlugin returns configuration for a specific plugin by tag

func KnownPlugins

func KnownPlugins() []Config

KnownPlugins returns a list of all registered plugin configurations

type HTTPServer

type HTTPServer interface {
	Plugin
	RegisterRoutes(mux *http.ServeMux)
}

type Interceptor

type Interceptor interface {
	Plugin
	// Process handles the data transformation and returns processed data and a skip flag
	// data: the input data to be processed
	// context: additional context information as key-value pairs
	// Returns: processed data and a boolean indicating if further processing should be skipped
	Process(data map[string]any, context map[string][]string) (procesed map[string]any, skipped bool)
}

Interceptor represents a plugin that can process and modify data before it reaches the connector

type MCPToolEnricher added in v0.2.7

type MCPToolEnricher interface {
	Plugin
	EnrichMCP(tooler MCPTooler)
}

type MCPTooler added in v0.2.7

type MCPTooler interface {
	Server() *server.MCPServer
}

type Plugin

type Plugin interface {
	// Doc returns the documentation string describing plugin's purpose and configuration
	Doc() string
}

Plugin is the base interface that all plugins must implement

func New

func New(tag string, config any) (Plugin, error)

type PluginF added in v0.2.1

type PluginF[TConfig Config, TPlugin Plugin] func(cfg TConfig) (TPlugin, error)

type Swaggerer

type Swaggerer interface {
	Plugin
	// Enrich enhances the OpenAPI documentation with additional specifications
	// Returns: modified OpenAPI documentation
	Enrich(swag *huma.OpenAPI) *huma.OpenAPI
}

Swaggerer represents a plugin that can modify OpenAPI documentation

type Wrapper

type Wrapper interface {
	Plugin
	// Wrap takes a connector and returns an enhanced version of it
	// Returns: wrapped connector or error if wrapping fails
	Wrap(connector connectors.Connector) (connectors.Connector, error)
}

Wrapper represents a plugin that can wrap and enhance a connector's functionality

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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