server

package
v0.29.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: Apache-2.0 Imports: 21 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

Overview

Package server assembles the single HTTP listener: health endpoints, the Prometheus exposition, the REST API, and the MCP streamable-HTTP endpoint (the latter two optionally behind OAuth).

Index

Constants

View Source
const (
	ProviderDex    = "dex"
	ProviderGoogle = "google"
)

OAuth providers.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Addr    string
	MCPPath string
	// OAuth, when set, makes the server an OAuth 2.1 resource server: the MCP
	// endpoint and the REST API require a bearer token the platform IdP
	// issued (forwarded by muster / sent by the portal) or this server's own,
	// and every call carries the caller's identity. Off: anonymous — only for
	// a listener nothing but a trusted proxy or the local user can reach.
	OAuth *OAuthConfig
	// Metrics, when set, is served at GET /metrics outside the OAuth guard
	// like the probes: Prometheus scrapers do not do OAuth flows, and the
	// exposition holds no secrets (VM ids, names, states, counters).
	// Operators who need it private firewall the path or disable it with
	// --metrics-enabled=false.
	Metrics http.Handler
}

Config configures the listener.

type OAuthConfig

type OAuthConfig struct {
	// BaseURL is the public URL of this server: the OAuth issuer identifier
	// of its own authorization-server metadata (https, or http on loopback).
	BaseURL string
	// Provider is the IdP: dex (default) or google.
	Provider string

	// Dex provider (Provider == dex).
	DexIssuerURL    string
	DexClientID     string
	DexClientSecret string
	// DexCAFile is a PEM CA bundle for an IdP with a private certificate;
	// verifies discovery, token and JWKS calls. Empty: system trust.
	DexCAFile string

	// Google provider (Provider == google).
	GoogleClientID     string
	GoogleClientSecret string

	// TrustedAudiences are the OAuth client ids whose IdP id_tokens are
	// accepted as bearer tokens (SSO token forwarding): the platform client
	// MCP clients and the muster CLI log in with. Empty: only tokens this
	// server issued itself.
	TrustedAudiences []string
	// AllowPrivateIPJWKSHosts lists the hosts, other than the issuer's own,
	// whose JWKS may resolve to RFC 1918 and RFC 4193 addresses: a jwks_uri
	// the IdP's discovery document puts on another host. The issuer host needs
	// no entry. Loopback, link-local and metadata addresses stay refused.
	AllowPrivateIPJWKSHosts []string
	// AllowPublicClientRegistration lets MCP clients register over DCR
	// without a token (labs only).
	AllowPublicClientRegistration bool
}

OAuthConfig makes vm-manager an OAuth 2.1 resource server (mcp-oauth) in front of the MCP endpoint and the REST API. The platform's identity provider is the authority: on the Agent Platform, muster forwards the session's IdP id_token byte-identical (MCPServer auth.forwardToken) and the portal sends the signed-in user's id_token through the gateway; both are validated here against the IdP's JWKS when their audience is one of TrustedAudiences (the platform's OAuth client). The caller's identity then travels with the request (identity package).

func (OAuthConfig) Validate

func (c OAuthConfig) Validate() error

Validate checks required fields.

type Server

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

Server is the assembled HTTP server.

func New

func New(cfg Config, svc api.Services, mcpSrv *mcpserver.MCPServer, log *slog.Logger) (*Server, error)

New builds the server.

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler exposes the mux (tests).

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Run serves until ctx is done, then shuts down gracefully.

Jump to

Keyboard shortcuts

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