httpapi

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthMiddleware

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

AuthMiddleware validates agent identity on intercepted HTTP API calls.

Agents include X-Agent-ID and X-Agent-Signature headers so shield-agent can verify who is making the outbound API call before forwarding it upstream.

mode "closed": reject requests with invalid or missing signatures (HTTP 401). mode "open": log failures but pass all requests through.

func NewAuthMiddleware

func NewAuthMiddleware(store auth.KeyStore, mode string, logger *slog.Logger, onAuth func(string)) *AuthMiddleware

NewAuthMiddleware creates an AuthMiddleware. onAuth is called with "verified", "failed", or "unsigned" for each request.

func (*AuthMiddleware) WrapHandler

func (a *AuthMiddleware) WrapHandler(next http.Handler) http.Handler

WrapHandler returns an http.Handler that authenticates agent HTTP API calls.

type Chain

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

Chain applies a list of Middlewares in order (first = outermost wrapper).

func NewChain

func NewChain(items ...Middleware) *Chain

NewChain creates a new Chain from the provided middlewares.

func (*Chain) Handler

func (c *Chain) Handler(final http.Handler) http.Handler

Handler wraps final with all middlewares and returns the combined http.Handler.

type LogMiddleware

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

LogMiddleware records agent→HTTP API request/response pairs to the database.

func NewLogMiddleware

func NewLogMiddleware(db *storage.DB, logger *slog.Logger, recorder Recorder) *LogMiddleware

NewLogMiddleware creates a LogMiddleware and starts its background writer. recorder may be nil to disable telemetry forwarding.

func (*LogMiddleware) Close

func (lm *LogMiddleware) Close()

Close shuts down the background writer.

func (*LogMiddleware) WrapHandler

func (lm *LogMiddleware) WrapHandler(next http.Handler) http.Handler

WrapHandler returns an http.Handler that logs agent→API request/response pairs.

type Middleware

type Middleware interface {
	WrapHandler(next http.Handler) http.Handler
}

Middleware wraps an http.Handler to intercept agent→HTTP API calls.

type Recorder

type Recorder interface {
	Record(event telemetry.Event)
}

Recorder forwards telemetry events to an external collector. Satisfied by *telemetry.Collector.

Jump to

Keyboard shortcuts

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