api

package
v0.0.0-...-0301fe8 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 51 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

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

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 RegisterHealthRoutes

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

RegisterHealthRoutes registers health check endpoints

func RegisterIntelligenceRoutes

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

RegisterIntelligenceRoutes exposes the detector's latest completed snapshot.

func RegisterPitotQLRoutes

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

func RegisterQueryRoutes

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

func RegisterSCIMRoutes

func RegisterSCIMRoutes(e *echo.Echo, cfg config.Config, users *appauth.UserStore, identities *appauth.IdentityStore)

RegisterSCIMRoutes registers the routes only when a token is configured.

func RegisterSettingsRoutes

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

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 RequestLogger

func RequestLogger() echo.MiddlewareFunc

RequestLogger logs each request without credentials or directory lookups.

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 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 while the process can serve (Kubernetes liveness probe). It fails only for a stall in Pitot's own work that a restart would free: a Parquet publication holding reads out past its bound, or an idle engine that cannot answer a ping. An overloaded engine, however saturated, is alive, and so is one running a costly query past its deadline: a restart would only let the query run again.

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 OIDCDiscovery

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

OIDCDiscovery resolves the identity provider's metadata. An unreachable provider must not take ingest and existing sessions down with it, so a failed startup attempt is retried in the background while the login routes answer 503.

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) (*OIDCDiscovery, error)

RegisterOIDCRoutes makes one bounded discovery attempt and registers the login routes. It fails only on invalid configuration; if the provider is merely unavailable the routes answer 503 while discovery retries until ctx ends. The returned discovery is nil outside OIDC mode.

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 PitotQLHandler

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

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 SCIMHandler

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

SCIMHandler serves the narrow SCIM 2.0 subset used to provision accounts: create, look up, and patch a user. Requests are authenticated by the route policy in AuthMiddleware before they reach it.

type SettingsHandler

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

func (*SettingsHandler) CreateIngestToken

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

CreateIngestToken issues a named token. The plaintext appears only in this response, which must never be cached.

func (*SettingsHandler) GetIngest

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

GetIngest returns connection metadata and whether any token is active. Token names and hints are not part of it.

func (*SettingsHandler) ListIngestTokens

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

ListIngestTokens returns active tokens only: revoked rows are kept for audit and for the seed rule, but no longer identify anything an administrator can act on.

func (*SettingsHandler) RevokeIngestToken

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

RevokeIngestToken stops one token. Revoking the last active token is allowed; the browser warns first because ingest then rejects every export.

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