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

api

package
v0.0.0-...-520fc63 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: Apache-2.0 Imports: 46 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RoutePolicyPublic            = "public"
	RoutePolicyAuthenticated     = "authenticated"
	RoutePolicyCapability        = "capability"
	RoutePolicyServiceCredential = "service-credential"
	RoutePolicyProtocol          = "protocol"
)

RoutePolicyPublic and friends name the policy kinds in the form the documentation uses. The internal constants are an unexported iota, which is right for a switch and useless in a table.

Variables

This section is empty.

Functions

func AllCapabilities

func AllCapabilities() []string

AllCapabilities lists every capability the middleware knows, sorted. Derived from the role table rather than restated, so a capability that exists but is granted to nobody cannot appear here and a new one needs no edit.

func AuthMiddleware

func AuthMiddleware(users *auth.UserStore, sessions *auth.BrowserSessions, cfg config.Config) echo.MiddlewareFunc

func ConfigureClientIP

func ConfigureClientIP(e *echo.Echo, rawCIDRs string) error

ConfigureClientIP trusts forwarded client addresses only from explicitly configured proxy networks. Direct clients cannot opt themselves into trust.

func GetCurrentUser

func GetCurrentUser(c *echo.Context) *auth.User

func HTTPErrorHandler

func HTTPErrorHandler(c *echo.Context, err error)

HTTPErrorHandler is the product error boundary, including router failures. Protocol handlers and operational probes write their own responses.

func HasCapability

func HasCapability(user auth.User, capability Capability) bool

func RegisterAlertRoutes

func RegisterAlertRoutes(e *echo.Echo, store *alert.Store, engine *alert.Engine)

RegisterAlertRoutes registers alert management REST endpoints.

func RegisterAnnotationRoutes

func RegisterAnnotationRoutes(e *echo.Echo, service AnnotationReader)

func RegisterAuthMiddleware

func RegisterAuthMiddleware(e *echo.Echo, users *auth.UserStore, sessions *auth.BrowserSessions, audit *auth.AuditStore, cfg config.Config)

func RegisterAuthRoutes

func RegisterAuthRoutes(e *echo.Echo, users *auth.UserStore, codes *auth.CodeStore, setup *auth.Setup, settingsStore *settings.Store, sessions *auth.BrowserSessions, audit *auth.AuditStore, smtp auth.SMTPConfig, cfg config.Config)

func RegisterDashboardRoutes

func RegisterDashboardRoutes(e *echo.Echo, dashboards *dashboard.Service)

func RegisterFanQLRoutes

func RegisterFanQLRoutes(e *echo.Echo, parser query.Parser, engine QueryEngine)

func RegisterHealthRoutes

func RegisterHealthRoutes(e *echo.Echo, duck *engine.Duck, cfg config.Config)

RegisterHealthRoutes registers health check endpoints

func RegisterIntelligenceRoutes

func RegisterIntelligenceRoutes(e *echo.Echo, snapshots IntelligenceSnapshots)

RegisterIntelligenceRoutes exposes the detector's latest completed snapshot.

func RegisterOIDCRoutes

func RegisterOIDCRoutes(ctx context.Context, e *echo.Echo, cfg config.Config, users *appauth.UserStore, identities *appauth.IdentityStore, sessions *appauth.BrowserSessions, audit *appauth.AuditStore) error

func RegisterQueryRoutes

func RegisterQueryRoutes(e *echo.Echo, engine QueryEngine)

func RegisterSettingsRoutes

func RegisterSettingsRoutes(e *echo.Echo, cfg config.Config, store *settings.Store, audit *auth.AuditStore)

func RegisterTraceRoutes

func RegisterTraceRoutes(e *echo.Echo, queries TraceQueries, retentionDays int)

func RegisterUserRoutes

func RegisterUserRoutes(e *echo.Echo, users *auth.UserStore, smtp auth.SMTPConfig, cfg config.Config)

RegisterUserRoutes registers user management endpoints.

func RequestOwner

func RequestOwner(c *echo.Context) (string, error)

func RequireCapability

func RequireCapability(capability Capability) echo.MiddlewareFunc

func RoleCapabilities

func RoleCapabilities() map[string][]string

RoleCapabilities returns each role's capabilities, sorted, in the string form a table wants. The underlying map is a set of empty structs keyed by type, which is the right shape for a lookup and the wrong shape for a document.

Types

type AnnotationReader

type AnnotationReader interface {
	Read(context.Context, annotations.Request) (annotations.Response, error)
}

type AuthHandler

type AuthHandler struct {
	// contains filtered or unexported fields
}
func (h *AuthHandler) LoginLink(c *echo.Context) error

func (*AuthHandler) Logout

func (h *AuthHandler) Logout(c *echo.Context) error

func (*AuthHandler) Me

func (h *AuthHandler) Me(c *echo.Context) error

func (*AuthHandler) Setup

func (h *AuthHandler) Setup(c *echo.Context) error

func (*AuthHandler) Start

func (h *AuthHandler) Start(c *echo.Context) error

func (*AuthHandler) Status

func (h *AuthHandler) Status(c *echo.Context) error

func (*AuthHandler) Verify

func (h *AuthHandler) Verify(c *echo.Context) error

type Capability

type Capability string
const (
	ReadTelemetry       Capability = "telemetry:read"
	ManageOwnDashboards Capability = "dashboards:manage-own"
	ManageAlerts        Capability = "alerts:manage"
	RunAgent            Capability = "agent:run"
	ReadIngestMetadata  Capability = "ingest:read-metadata"
	ManageIngest        Capability = "ingest:manage"
	ManageUsers         Capability = "users:manage"
	ReadOperations      Capability = "operations:read"
)

type CheckResult

type CheckResult struct {
	Status    string `json:"status"`
	LatencyMs int64  `json:"latency_ms,omitempty"`
	Error     string `json:"error,omitempty"`
	Detail    string `json:"detail,omitempty"`
	UpdatedAt string `json:"updated_at,omitempty"`
}

CheckResult represents a single health check result

type DashboardHandler

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

type FanQLHandler

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

type HealthHandler

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

HealthHandler handles health check endpoints

func NewHealthHandler

func NewHealthHandler(duck *engine.Duck, cfg config.Config) *HealthHandler

NewHealthHandler creates a new health handler

func (*HealthHandler) Liveness

func (h *HealthHandler) Liveness(c *echo.Context) error

Liveness returns 200 if process is running (Kubernetes liveness probe)

func (*HealthHandler) Readiness

func (h *HealthHandler) Readiness(c *echo.Context) error

Readiness checks all dependencies (Kubernetes readiness probe)

type HealthResponse

type HealthResponse struct {
	Status        string                 `json:"status"`
	Checks        map[string]CheckResult `json:"checks"`
	RuntimeSizing config.RuntimeSizing   `json:"runtime_sizing"`
}

HealthResponse represents the full health check response

type IntelligenceSnapshots

type IntelligenceSnapshots interface {
	LatestSnapshot() *intelligence.Snapshot
}

IntelligenceSnapshots is the read side of the detector used by HTTP and other consumers. Keeping the interface narrow makes the endpoint independent of how snapshots are generated or retained.

type MCPAuthorization

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

func NewMCPAuthorization

func NewMCPAuthorization(store *appauth.OAuthStore, users *appauth.UserStore, resourceURL string) (*MCPAuthorization, error)

func (*MCPAuthorization) AuthorizationServerMetadata

func (h *MCPAuthorization) AuthorizationServerMetadata(c *echo.Context) error

func (*MCPAuthorization) Authorize

func (h *MCPAuthorization) Authorize(c *echo.Context) error

func (*MCPAuthorization) ListConnections

func (h *MCPAuthorization) ListConnections(c *echo.Context) error

func (*MCPAuthorization) ProtectBrowserMCP

func (h *MCPAuthorization) ProtectBrowserMCP(sessions *appauth.BrowserSessions, next http.Handler) echo.HandlerFunc

ProtectBrowserMCP adapts an already-authenticated browser session to the standard MCP transport identity consumed by the SDK. The public /mcp route remains OAuth bearer-only; this adapter is used only by the same-origin /api/mcp route after AuthMiddleware has validated the session and CSRF header.

func (*MCPAuthorization) ProtectMCP

func (h *MCPAuthorization) ProtectMCP(next http.Handler) http.Handler

func (*MCPAuthorization) ProtectedResourceMetadata

func (h *MCPAuthorization) ProtectedResourceMetadata(c *echo.Context) error

func (*MCPAuthorization) Register

func (h *MCPAuthorization) Register(e *echo.Echo)

func (*MCPAuthorization) RegisterClient

func (h *MCPAuthorization) RegisterClient(c *echo.Context) error

func (*MCPAuthorization) RevokeConnection

func (h *MCPAuthorization) RevokeConnection(c *echo.Context) error

func (*MCPAuthorization) Token

func (h *MCPAuthorization) Token(c *echo.Context) error

type OIDCHandler

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

func (*OIDCHandler) Callback

func (h *OIDCHandler) Callback(c *echo.Context) error

func (*OIDCHandler) Start

func (h *OIDCHandler) Start(c *echo.Context) error

type QueryHandler

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

type RouteDoc

type RouteDoc struct {
	Method string
	Path   string
	// Policy is one of the RoutePolicy* constants above.
	Policy string
	// Capability is set only when Policy is RoutePolicyCapability or
	// RoutePolicyServiceCredential; empty otherwise.
	Capability string
}

RouteDoc is what a reader needs to know before calling a route: whether it needs a credential, and if so which capability that credential must carry.

func DescribeRoute

func DescribeRoute(method, path string) (RouteDoc, bool)

DescribeRoute reports how the middleware would classify this method and path. The second return is false when the pair reaches no case — which for a registered route means the method is not permitted on it.

type SettingsHandler

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

func (*SettingsHandler) GetIngest

func (h *SettingsHandler) GetIngest(c *echo.Context) error

GetIngest returns the current ingest config: whether a token is set (but not the token itself) and the endpoint collectors should use.

func (*SettingsHandler) RotateIngestToken

func (h *SettingsHandler) RotateIngestToken(c *echo.Context) error

RotateIngestToken issues a new token, persists only its hash, and returns the plaintext exactly once in the response.

type TraceHandler

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

type UserHandler

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

UserHandler handles admin user management endpoints.

func (*UserHandler) CreateUser

func (h *UserHandler) CreateUser(c *echo.Context) error

CreateUser adds a new user (admin only).

func (*UserHandler) DeleteUser

func (h *UserHandler) DeleteUser(c *echo.Context) error

DeleteUser removes a user (admin only).

func (*UserHandler) ListUsers

func (h *UserHandler) ListUsers(c *echo.Context) error

ListUsers returns all users.

func (*UserHandler) RevokeAccess

func (h *UserHandler) RevokeAccess(c *echo.Context) error

RevokeAccess invalidates existing browser sessions and OAuth tokens. The account remains active and can sign in again.

func (*UserHandler) UpdateRole

func (h *UserHandler) UpdateRole(c *echo.Context) error

UpdateRole modifies a user's role (admin only).

func (*UserHandler) UpdateStatus

func (h *UserHandler) UpdateStatus(c *echo.Context) error

UpdateStatus modifies a user's status (admin only).

func (*UserHandler) UpdateUser

func (h *UserHandler) UpdateUser(c *echo.Context) error

UpdateUser modifies only a user's profile (admin only).

Jump to

Keyboard shortcuts

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