server

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package server assembles the single HTTP listener: health endpoints, the REST API and the MCP streamable-HTTP endpoint, both behind the same OAuth guard when configured. Without OAuth there is no authentication here: only a server nothing but a trusted proxy can reach (the agentgateway JWT policy in front of the route, muster in front of the MCP endpoint) runs that way, and it then acts as its ServiceAccount.

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
	MCPEnabled bool
	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, acting as
	// the ServiceAccount.
	OAuth *OAuthConfig
}

Config configures the listener.

type OAuthConfig added in v0.2.0

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
	// DexAllowPrivateIP lets the issuer resolve to a private/loopback address
	// (an in-cluster Dex).
	DexAllowPrivateIP bool

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

	// TrustedAudiences are the OAuth client ids whose IdP id_tokens are
	// accepted as bearers (SSO token forwarding): the platform client, and
	// the audiences the MCPServer requires — what the kube-apiserver trusts,
	// which every token muster forwards carries by construction (the chart
	// unions both). A portal session's id_token names the portal's own
	// client, not the platform client. Empty: only tokens this server issued
	// itself.
	TrustedAudiences []string
	// SSOAllowPrivateIPs lets the JWKS endpoint used for forwarded tokens
	// resolve to a private address (an in-cluster Dex).
	SSOAllowPrivateIPs bool
	// AllowPublicClientRegistration lets MCP clients register over DCR
	// without a token (labs only).
	AllowPublicClientRegistration bool
	// DownstreamOAuth puts the caller's IdP token on the request so every
	// Kubernetes API call is made as the caller instead of the ServiceAccount
	// (the apiserver must trust the IdP and the token's audience). The
	// ServiceAccount then holds no permissions, so a request whose caller has
	// no IdP token to present is refused (401) rather than run as nobody.
	DownstreamOAuth bool
}

OAuthConfig makes agent-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) and, with DownstreamOAuth, so does the token — every Kubernetes call is made as the caller.

func (OAuthConfig) Validate added in v0.2.0

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 *agents.Service, 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